37 "org.mitk.modules.us.AbstractUltrasoundTrackerDevice";
42 "org.mitk.services.AbstractUltrasoundTrackerDevice";
49 NavigationDataSource::Pointer trackingDevice,
50 bool trackedUltrasoundActive)
51 : m_UltrasoundDevice(usDevice),
52 m_TrackingDeviceDataSource(trackingDevice),
56 m_LastFilterOfIGTPipeline(nullptr),
57 m_NumberOfSmoothingValues(0),
59 m_IsTrackedUltrasoundActive(trackedUltrasoundActive)
76 return mitk::AffineTransform3D::New();
83 MITK_WARN <<
"Combined modality not correctly initialized, aborting!";
90 <<
"Cannot freeze or unfreeze if device is not active.";
140 std::map<std::string, mitk::AffineTransform3D::Pointer>::iterator calibrationIterator =
148 return calibrationIterator->second;
153 if (calibration.IsNull())
155 MITK_WARN <<
"Null pointer passed to SetCalibration of mitk::USDevice. Ignoring call.";
160 if (calibrationKey.empty())
162 MITK_WARN <<
"Could not get a key for the calibration -> Calibration cannot be set.";
199 MITK_ERROR(
"AbstractUltrasoundTrackerDevice")(
"USDevice") <<
"UltrasoundDevice must not be null.";
200 mitkThrow() <<
"UltrasoundDevice must not be null.";
228 std::stringstream result;
229 result <<
"<calibrations>" << std::endl;
231 for (std::map<std::string, mitk::AffineTransform3D::Pointer>::iterator it =
m_Calibrations.begin();
235 mitk::AffineTransform3D::MatrixType matrix = it->second->GetMatrix();
236 mitk::AffineTransform3D::TranslationType translation = it->second->GetTranslation();
237 TiXmlElement elem(it->first);
239 elem.SetDoubleAttribute(
"M00", matrix[0][0]);
240 elem.SetDoubleAttribute(
"M01", matrix[0][1]);
241 elem.SetDoubleAttribute(
"M02", matrix[0][2]);
242 elem.SetDoubleAttribute(
"M10", matrix[1][0]);
243 elem.SetDoubleAttribute(
"M11", matrix[1][1]);
244 elem.SetDoubleAttribute(
"M12", matrix[1][2]);
245 elem.SetDoubleAttribute(
"M20", matrix[2][0]);
246 elem.SetDoubleAttribute(
"M21", matrix[2][1]);
247 elem.SetDoubleAttribute(
"M22", matrix[2][2]);
249 elem.SetDoubleAttribute(
"T0", translation[0]);
250 elem.SetDoubleAttribute(
"T1", translation[1]);
251 elem.SetDoubleAttribute(
"T2", translation[2]);
253 result << elem << std::endl;
255 result <<
"</calibrations>" << std::endl;
261 bool clearPreviousCalibrations)
266 MITK_ERROR <<
"Empty string passed to Deserialize() method of CombinedModality. Aborting...";
267 mitkThrow() <<
"Empty string passed to Deserialize() method of CombinedModality. Aborting...";
271 if (clearPreviousCalibrations)
276 if (!doc.Parse(xmlString.c_str()))
278 MITK_ERROR <<
"Unable to deserialize calibrations in CombinedModality. Error was: " << doc.ErrorDesc();
279 mitkThrow() <<
"Unable to deserialize calibrations in CombinedModality. Error was: " << doc.ErrorDesc();
282 TiXmlElement *root = doc.FirstChildElement();
285 MITK_ERROR <<
"Unable to deserialize calibrations in CombinedModality. String contained no root element.";
286 mitkThrow() <<
"Unable to deserialize calibrations in CombinedModality. String contained no root element.";
290 for (TiXmlElement *elem = root->FirstChildElement(); elem !=
nullptr; elem = elem->NextSiblingElement())
292 mitk::AffineTransform3D::MatrixType matrix;
293 mitk::AffineTransform3D::OffsetType translation;
295 std::string calibName = elem->Value();
298 elem->QueryDoubleAttribute(
"M00", &matrix[0][0]);
299 elem->QueryDoubleAttribute(
"M01", &matrix[0][1]);
300 elem->QueryDoubleAttribute(
"M02", &matrix[0][2]);
301 elem->QueryDoubleAttribute(
"M10", &matrix[1][0]);
302 elem->QueryDoubleAttribute(
"M11", &matrix[1][1]);
303 elem->QueryDoubleAttribute(
"M12", &matrix[1][2]);
304 elem->QueryDoubleAttribute(
"M20", &matrix[2][0]);
305 elem->QueryDoubleAttribute(
"M21", &matrix[2][1]);
306 elem->QueryDoubleAttribute(
"M22", &matrix[2][2]);
309 elem->QueryDoubleAttribute(
"T0", &translation[0]);
310 elem->QueryDoubleAttribute(
"T1", &translation[1]);
311 elem->QueryDoubleAttribute(
"T2", &translation[2]);
313 mitk::AffineTransform3D::Pointer calibration = mitk::AffineTransform3D::New();
314 calibration->SetMatrix(matrix);
315 calibration->SetTranslation(translation);
326 if ((oldNumber == 0 && numberOfSmoothingValues != 0) || (oldNumber != 0 && numberOfSmoothingValues == 0))
339 if ((oldCount == 0 && delayCount != 0) || (oldCount != 0 && delayCount == 0))
358 us::ServiceProperties::const_iterator probeIt =
363 if (probeIt != usdeviceProperties.end())
365 probeName = (probeIt->second).ToString();
369 std::replace(probeName.begin(), probeName.end(),
'/',
'-');
380 us::ServiceProperties::iterator depthIterator =
383 if (depthIterator != usdeviceProperties.end())
385 depth = depthIterator->second.ToString();
411 if (m_IsTrackedUltrasoundActive)
453 MITK_ERROR(
"USCombinedModality")(
"USDevice") <<
"UltrasoundDevice must not be null.";
454 mitkThrow() <<
"UltrasoundDevice must not be null.";
464 MITK_ERROR(
"USCombinedModality")(
"USDevice") <<
"UltrasoundDevice must not be null.";
465 mitkThrow() <<
"UltrasoundDevice must not be null.";
475 MITK_ERROR(
"USCombinedModality")(
"USDevice") <<
"UltrasoundDevice must not be null.";
476 mitkThrow() <<
"UltrasoundDevice must not be null.";
486 MITK_ERROR(
"USCombinedModality")(
"USDevice") <<
"UltrasoundDevice must not be null.";
487 mitkThrow() <<
"UltrasoundDevice must not be null.";
static const std::string US_PROPKEY_ID
std::string GetDeviceClass()
Returns the Class of the Device.
static const std::string US_PROPKEY_DEVICENAME
NavigationDataDelayFilter.
std::string SerializeCalibration()
Serializes all contained calibrations into an xml fragment.
NavigationDataDisplacementFilter adds an offset to navigation data objects.
unsigned int m_DelayCount
virtual AffineTransform3D::Pointer GetUSPlaneTransform()
virtual void SetIsFreezed(bool freeze)
Can toggle if the combined modality is currently updated or freezed.
DataCollection - Class to facilitate loading/accessing structured data.
static mitk::USDevice::PropertyKeys GetPropertyKeys()
void RebuildFilterPipeline()
std::string GetCurrentDepthValue()
void SetCalibration(AffineTransform3D::Pointer calibration)
Sets a transformation as calibration data. Calibration data is set for the currently activated probe ...
static const char * ProbeAndDepthSeperator
itk::SmartPointer< mitk::NavigationDataDelayFilter > m_DelayFilter
bool RemoveCalibration()
Removes the calibration data of the currently active depth and probe.
virtual void RegisterAsMicroservice()
void SetNumberOfSmoothingValues(unsigned int numberOfSmoothingValues)
void GenerateData() override
Grabs the next frame from the input. Must be implemented by the derived class. This method is called ...
itk::SmartPointer< mitk::NavigationDataSmoothingFilter > m_SmoothingFilter
itk::SmartPointer< mitk::NavigationDataDisplacementFilter > m_DisplacementFilter
bool GetContainsAtLeastOneCalibration()
AbstractUltrasoundTrackerDevice(USDevice::Pointer usDevice, itk::SmartPointer< NavigationDataSource > trackingDevice, bool trackedUltrasoundActive)
unsigned int m_NumberOfSmoothingValues
std::map< std::string, AffineTransform3D::Pointer > m_Calibrations
virtual bool GetIsFreezed()
This filter smoothes the navigation data by calculating the mean value of the last few input values a...
itk::SmartPointer< mitk::NavigationDataSource > GetNavigationDataSource()
static const std::string DeviceClassIdentifier
virtual void OnFreeze(bool)
Called when mitk::AbstractUltrasoundTrackerDevice::SetIsFreezed() is called. Subclasses can overwrite...
virtual itk::SmartPointer< USControlInterfaceBMode > GetControlInterfaceBMode()
Wrapper for returning B mode control interface of the UltrasoundDevice.
void UnregisterOnService()
Remove this device from the micro service. This method is public for mitk::USCombinedModality, because this devices can be completly removed. This is not possible for API devices, which should be available while their sub module is loaded.
~AbstractUltrasoundTrackerDevice() override
static const std::string US_PROPKEY_CLASS
virtual itk::SmartPointer< USControlInterfaceDoppler > GetControlInterfaceDoppler()
Wrapper for returning doppler control interface of the UltrasoundDevice.
AffineTransform3D::Pointer GetCalibration()
Getter for calibration data of the currently active depth and probe.
bool GetIsCalibratedForCurrentStatus()
USDevice::Pointer m_UltrasoundDevice
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties
virtual itk::SmartPointer< USAbstractControlInterface > GetControlInterfaceCustom()
Wrapper for returning custom control interface of the UltrasoundDevice.
std::string GetIdentifierForCurrentCalibration()
itk::SmartPointer< mitk::NavigationDataSource > m_LastFilterOfIGTPipeline
void DeserializeCalibration(const std::string &xmlString, bool clearPreviousCalibrations=true)
Deserializes a string provided by a prior call to Serialize(). If the bool flag is true...
static const std::string US_INTERFACE_NAME
static const char * DefaultProbeIdentifier
static const char * replace[]
This is a dictionary to replace long names of classes, modules, etc. to shorter versions in the conso...
us::ServiceRegistration< Self > m_ServiceRegistration
The device's ServiceRegistration object that allows to modify it's Microservice registraton details...
USImageSource::Pointer GetUSImageSource()
Wrapper for returning USImageSource of the UltrasoundDevice.
itk::SmartPointer< NavigationDataSource > m_TrackingDeviceDataSource
void SetDelayCount(unsigned int delayCount)
virtual itk::SmartPointer< USControlInterfaceProbes > GetControlInterfaceProbes()
Wrapper for returning probes control interface of the UltrasoundDevice.
std::string GetIdentifierForCurrentProbe()
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
us::ServiceProperties m_ServiceProperties
Properties of the device's Microservice.