Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 98 additions & 35 deletions src/PlusDataCollection/Capistrano/vtkPlusCapistranoVideoSource.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,6 @@ void vtkPlusCapistranoVideoSource::PrintSelf(ostream& os, vtkIndent indent)
os << indent << "ClockDivider: " << ClockDivider << std::endl;
os << indent << "CineBuffers: " << CineBuffers << std::endl;
os << indent << "SampleFrequency: " << SampleFrequency << std::endl;
os << indent << "PulseFrequency: " << PulseFrequency << std::endl;
os << indent << "WobbleRate: " << (int)GetWobbleRate() << std::endl;
os << indent << "JitterCompensation: " << (int)GetJitterCompensation() << std::endl;
os << indent << "PositionScale: " << (int)PositionScale << std::endl;
Expand Down Expand Up @@ -711,7 +710,6 @@ PlusStatus vtkPlusCapistranoVideoSource::ReadConfiguration(vtkXMLDataElement* ro
XML_READ_BOOL_ATTRIBUTE_OPTIONAL(BidirectionalMode, deviceConfig);
XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(int, CineBuffers, deviceConfig);
XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(float, SampleFrequency, deviceConfig);
XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(float, PulseFrequency, deviceConfig);
XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(int, WobbleRate, deviceConfig);
XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(int, JitterCompensation, deviceConfig);
XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(int, PositionScale, deviceConfig);
Expand Down Expand Up @@ -746,7 +744,6 @@ PlusStatus vtkPlusCapistranoVideoSource::WriteConfiguration(vtkXMLDataElement* r
deviceConfig->SetAttribute("BidirectionalMode", BidirectionalMode ? "TRUE" : "FALSE");
deviceConfig->SetAttribute("UpdateParameters", UpdateParameters ? "TRUE" : "FALSE");
deviceConfig->SetIntAttribute("CurrentBModeViewOption", this->CurrentBModeViewOption);
deviceConfig->SetFloatAttribute("PulseFrequency", this->PulseFrequency);
deviceConfig->SetIntAttribute("WobbleRate", this->GetWobbleRate());
deviceConfig->SetIntAttribute("JitterCompensation", this->GetJitterCompensation());
deviceConfig->SetIntAttribute("PositionScale", this->GetPositionScale());
Expand Down Expand Up @@ -849,8 +846,8 @@ vtkPlusCapistranoVideoSource::vtkPlusCapistranoVideoSource()
this->ClockDivider = 2; //1
this->CineBuffers = 32;
this->SampleFrequency = 40.0f;
this->PulseFrequency = 12.0f;
this->PositionScale = 0; // no function to read it from the SDK, has to be specified
this->ImagingParameters->SetFrequencyMhz(12.0f);
this->ImagingParameters->SetProbeVoltage(30.0f);
this->ImagingParameters->SetSoundVelocity(1532.0f);
this->ImagingParameters->SetDepthMm(36); // mm
Expand All @@ -877,6 +874,14 @@ vtkPlusCapistranoVideoSource::vtkPlusCapistranoVideoSource()
this->CurrentPixelSpacingMm[0] = 1.0;
this->CurrentPixelSpacingMm[1] = 1.0;
this->CurrentPixelSpacingMm[2] = 1.0;

// Initialize the rest of standard Plus imaging parameters, which are ignored in Capistrano's implementation
// This is to avoid errors in vtkPlusGetUsParameterCommand::Execute()
this->ImagingParameters->SetFocusDepthPercent(0.5);
this->ImagingParameters->SetSectorPercent(100);
this->ImagingParameters->SetGainPercent(100);
this->ImagingParameters->SetPowerDb(0.0);
this->ImagingParameters->SetDynRangeDb(100);
}

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -1545,8 +1550,10 @@ PlusStatus vtkPlusCapistranoVideoSource::SetSampleFrequency(float sf)
// ----------------------------------------------------------------------------
PlusStatus vtkPlusCapistranoVideoSource::SetPulseFrequency(float pf)
{
this->PulseFrequency = pf;
this->Internal->SetUSProbePulserParamsFromDB(this->PulseFrequency);
if (this->Internal->SetUSProbePulserParamsFromDB(pf)) // this frequency is supported
{
this->ImagingParameters->SetFrequencyMhz(pf);
}
return PLUS_SUCCESS;
}

Expand Down Expand Up @@ -1839,7 +1846,7 @@ PlusStatus vtkPlusCapistranoVideoSource::UpdateUSProbeParameters()
this->Internal->USProbeParams.probetype.Velocity = this->ImagingParameters->GetSoundVelocity();

// Update PulseFrequency
if (!this->Internal->SetUSProbePulserParamsFromDB(this->PulseFrequency))
if (!this->Internal->SetUSProbePulserParamsFromDB(this->ImagingParameters->GetFrequencyMhz()))
{
LOG_ERROR("Invalid pulse frequency. Possible pulse frequencies: 10.0, 12.0, 16.0, 18.0, 20.0, 25.0, 30.0, 35.0, 45.0, 50");
return PLUS_FAIL;
Expand Down Expand Up @@ -2003,82 +2010,138 @@ PlusStatus vtkPlusCapistranoVideoSource::InternalApplyImagingParameterChange()
return PLUS_SUCCESS;
}

if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_DEPTH))
PlusStatus status = PLUS_SUCCESS;

if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_DEPTH)
&& this->ImagingParameters->IsPending(vtkPlusUsImagingParameters::KEY_DEPTH))
{
if (this->SetDepthMmDevice(float(this->ImagingParameters->GetDepthMm())) == PLUS_FAIL)
if (this->SetDepthMmDevice(this->ImagingParameters->GetDepthMm()) == PLUS_SUCCESS)
{
return PLUS_FAIL;
this->ImagingParameters->SetPending(vtkPlusUsImagingParameters::KEY_DEPTH, false);
}
else
{
LOG_ERROR("Failed to set depth imaging parameter");
status = PLUS_FAIL;
}
}

if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_FREQUENCY))
if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_FREQUENCY)
&& this->ImagingParameters->IsPending(vtkPlusUsImagingParameters::KEY_FREQUENCY))
{
if (this->SetPulseFrequency(this->ImagingParameters->GetFrequencyMhz()) == PLUS_FAIL)
if (this->SetPulseFrequency(this->ImagingParameters->GetFrequencyMhz()) == PLUS_SUCCESS)
{
return PLUS_FAIL;
this->ImagingParameters->SetPending(vtkPlusUsImagingParameters::KEY_FREQUENCY, false);
}
else
{
LOG_ERROR("Failed to set frequency imaging parameter");
status = PLUS_FAIL;
}
}

if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_TGC))
if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_TGC)
&& this->ImagingParameters->IsPending(vtkPlusUsImagingParameters::KEY_TGC))
{
std::vector<double> tgcVec;
this->ImagingParameters->GetTimeGainCompensation(tgcVec);
double tgc[3] = {tgcVec[0], tgcVec[1], tgcVec[2]};
double tgc[3] = { tgcVec[0], tgcVec[1], tgcVec[2] };

if (this->SetGainPercent(tgc) == PLUS_FAIL)
if (this->SetGainPercent(tgc) == PLUS_SUCCESS)
{
return PLUS_FAIL;
this->ImagingParameters->SetPending(vtkPlusUsImagingParameters::KEY_TGC, false);
}
else
{
LOG_ERROR("Failed to set time gain compensation parameter");
status = PLUS_FAIL;
}
}

if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_IMAGESIZE))
if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_IMAGESIZE)
&& this->ImagingParameters->IsPending(vtkPlusUsImagingParameters::KEY_IMAGESIZE))
{
FrameSizeType imageSizeVec;
this->ImagingParameters->GetImageSize(imageSizeVec);

if (this->SetImageSize(imageSizeVec) == PLUS_FAIL)
if (this->SetImageSize(imageSizeVec) == PLUS_SUCCESS)
{
return PLUS_FAIL;
this->ImagingParameters->SetPending(vtkPlusUsImagingParameters::KEY_IMAGESIZE, false);
}
else
{
LOG_ERROR("Failed to set image size parameter");
status = PLUS_FAIL;
}
}

if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_INTENSITY))
if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_INTENSITY)
&& this->ImagingParameters->IsPending(vtkPlusUsImagingParameters::KEY_INTENSITY))
{
if (this->SetIntensity(this->ImagingParameters->GetIntensity()) == PLUS_FAIL)
if (this->SetIntensity(this->ImagingParameters->GetIntensity()) == PLUS_SUCCESS)
{
return PLUS_FAIL;
this->ImagingParameters->SetPending(vtkPlusUsImagingParameters::KEY_INTENSITY, false);
}
else
{
LOG_ERROR("Failed to set intensity parameter");
status = PLUS_FAIL;
}
}

if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_CONTRAST))
if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_CONTRAST)
&& this->ImagingParameters->IsPending(vtkPlusUsImagingParameters::KEY_CONTRAST))
{
if (this->SetContrast(this->ImagingParameters->GetContrast()) == PLUS_FAIL)
if (this->SetContrast(this->ImagingParameters->GetContrast()) == PLUS_SUCCESS)
{
return PLUS_FAIL;
this->ImagingParameters->SetPending(vtkPlusUsImagingParameters::KEY_CONTRAST, false);
}
else
{
LOG_ERROR("Failed to set contrast parameter");
status = PLUS_FAIL;
}
}

if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_ZOOM))
if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_ZOOM)
&& this->ImagingParameters->IsPending(vtkPlusUsImagingParameters::KEY_ZOOM))
{
if (this->SetZoomFactor(this->ImagingParameters->GetZoomFactor()) == PLUS_FAIL)
if (this->SetZoomFactor(this->ImagingParameters->GetZoomFactor()) == PLUS_SUCCESS)
{
return PLUS_FAIL;
this->ImagingParameters->SetPending(vtkPlusUsImagingParameters::KEY_ZOOM, false);
}
else
{
LOG_ERROR("Failed to set zoom parameter");
status = PLUS_FAIL;
}
}

if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_SOUNDVELOCITY))
if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_SOUNDVELOCITY)
&& this->ImagingParameters->IsPending(vtkPlusUsImagingParameters::KEY_SOUNDVELOCITY))
{
if (this->SetSoundVelocity(this->ImagingParameters->GetSoundVelocity()) == PLUS_FAIL)
if (this->SetSoundVelocity(this->ImagingParameters->GetSoundVelocity()) == PLUS_SUCCESS)
{
return PLUS_FAIL;
this->ImagingParameters->SetPending(vtkPlusUsImagingParameters::KEY_SOUNDVELOCITY, false);
}
else
{
LOG_ERROR("Failed to set sound velocity parameter");
status = PLUS_FAIL;
}
}

if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_VOLTAGE))
if (this->ImagingParameters->IsSet(vtkPlusUsImagingParameters::KEY_VOLTAGE)
&& this->ImagingParameters->IsPending(vtkPlusUsImagingParameters::KEY_VOLTAGE))
{
if (this->SetPulseVoltage(this->ImagingParameters->GetProbeVoltage()) == PLUS_FAIL)
if (this->SetPulseVoltage(this->ImagingParameters->GetProbeVoltage()) == PLUS_SUCCESS)
{
return PLUS_FAIL;
this->ImagingParameters->SetPending(vtkPlusUsImagingParameters::KEY_VOLTAGE, false);
}
else
{
LOG_ERROR("Failed to set voltage parameter");
status = PLUS_FAIL;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ class vtkPlusDataCollectionExport vtkPlusCapistranoVideoSource: public vtkPlusUs
int ClockDivider;
int CineBuffers;
float SampleFrequency;
float PulseFrequency;
unsigned char PositionScale;
bool Interpolate;
bool AverageMode;
Expand Down