Skip to content

Commit

Permalink
ENH: Set custom frame fields per Andor frame acquisition
Browse files Browse the repository at this point in the history
  • Loading branch information
adamaji authored and adamrankin committed Jan 20, 2021
1 parent c8220bb commit 8cdf475
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/PlusDataCollection/Andor/vtkPlusAndorVideoSource.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,37 @@ void vtkPlusAndorVideoSource::AdjustSpacing(int horizontalBins, int verticalBins
LOG_DEBUG("Adjusted spacing: " << spacingStream.str());
}

// ----------------------------------------------------------------------------
void vtkPlusAndorVideoSource::SetCustomFrameFields()
{
this->CustomFields["ExposureTime"].first = FRAMEFIELD_FORCE_SERVER_SEND;
this->CustomFields["ExposureTime"].second = std::to_string(this->effectiveExpTime);
this->CustomFields["HorizontalBins"].first = FRAMEFIELD_FORCE_SERVER_SEND;
this->CustomFields["HorizontalBins"].second = std::to_string(this->effectiveHBins);
this->CustomFields["VerticalBins"].first = FRAMEFIELD_FORCE_SERVER_SEND;
this->CustomFields["VerticalBins"].second = std::to_string(this->effectiveVBins);

std::ostringstream transformStream;
float transformValue;
for(unsigned i = 0; i < 15; i++)
{
transformValue = this->imageToReferenceTransform.at(i);
if (i == 0)
{
transformValue = transformValue * this->OutputSpacing[0] * this->effectiveHBins;
}
else if (i == 5) // 1,1 in the matrix
{
transformValue = transformValue * this->OutputSpacing[1] * this->effectiveVBins;
}
transformStream << this->imageToReferenceTransform.at(i) << " ";
}
transformStream << this->imageToReferenceTransform.back();

this->CustomFields["ImageToReferenceTransform"].first = FRAMEFIELD_FORCE_SERVER_SEND;
this->CustomFields["ImageToReferenceTransform"].second = transformStream.str();
}

// ----------------------------------------------------------------------------
PlusStatus vtkPlusAndorVideoSource::SetFrameFieldImageToReferenceTransform(std::array<float, 16> transform)
{
Expand Down Expand Up @@ -508,6 +539,8 @@ PlusStatus vtkPlusAndorVideoSource::AcquireFrame()
AdjustBuffers(this->effectiveHBins, this->effectiveVBins);
AdjustSpacing(this->effectiveHBins, this->effectiveVBins);

SetCustomFrameFields();

unsigned rawFrameSize = frameSize[0] * frameSize[1];
rawFrame.resize(rawFrameSize, 0);

Expand Down
3 changes: 3 additions & 0 deletions src/PlusDataCollection/Andor/vtkPlusAndorVideoSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ class vtkPlusDataCollectionExport vtkPlusAndorVideoSource: public vtkPlusDevice
void AdjustBuffers(int horizontalBins, int verticalBins);
void AdjustSpacing(int horizontalBins, int verticalBins);

/*! Set some acquisition parameters as per-frame header fields */
void SetCustomFrameFields();

/*! Acquire a single frame using current parameters. Data is put in the frameBuffer ivar. */
PlusStatus AcquireFrame();

Expand Down

0 comments on commit 8cdf475

Please sign in to comment.