diff --git a/Modules/US/Testing/files.cmake b/Modules/US/Testing/files.cmake index 56b758c946..0a0987f2d8 100644 --- a/Modules/US/Testing/files.cmake +++ b/Modules/US/Testing/files.cmake @@ -1,14 +1,15 @@ SET(MODULE_TESTS + mitkUSImageTest.cpp mitkUSImage2DTest.cpp mitkUSImageVideoSourceTest.cpp mitkUSProbeTest.cpp mitkUSDeviceTest.cpp # ----------------------------------------------------------------------- # ------------------ Deavtivated Tests ---------------------------------- # ----------------------------------------------------------------------- ) diff --git a/Modules/US/Testing/mitkUSImage2DTest.cpp b/Modules/US/Testing/mitkUSImage2DTest.cpp index 0e50e8e6f8..89f73cfe27 100644 --- a/Modules/US/Testing/mitkUSImage2DTest.cpp +++ b/Modules/US/Testing/mitkUSImage2DTest.cpp @@ -1,49 +1,49 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2008-02-25 17:27:17 +0100 (Mo, 25 Feb 2008) $ Version: $Revision: 7837 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkUSImage2D.h" #include "mitkTestingMacros.h" class mitkUSImage2DTestClass { public: // Anm: Implementierung der einzelnen Testmethoden static void TestInstantiation() { // let's create an object of our class mitk::USImage2D::Pointer us2d = mitk::USImage2D::New(); - MITK_TEST_CONDITION_REQUIRED(us2d.IsNotNull(), "UsImage2D should not be null after instantiation"); + MITK_TEST_CONDITION_REQUIRED(us2d.IsNotNull(), "USImage2D should not be null after instantiation"); } }; /** * This function is testing methods of the class USImage2D. */ int mitkUSImage2DTest(int /* argc */, char* /*argv*/[]) { MITK_TEST_BEGIN("mitkUSImage2DTest"); mitkUSImage2DTestClass::TestInstantiation(); MITK_TEST_END(); } \ No newline at end of file diff --git a/Modules/US/Testing/mitkUSImageTest.cpp b/Modules/US/Testing/mitkUSImageTest.cpp new file mode 100644 index 0000000000..de06feb098 --- /dev/null +++ b/Modules/US/Testing/mitkUSImageTest.cpp @@ -0,0 +1,74 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2008-02-25 17:27:17 +0100 (Mo, 25 Feb 2008) $ +Version: $Revision: 7837 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "mitkUSImage.h" +#include "mitkTestingMacros.h" +#include "mitkUSImageMetadata.h" + + +class mitkUSImageTestClass +{ +public: + + // Anm: Implementierung der einzelnen Testmethoden + + static void TestInstantiation() + { + // let's create an object of our class + mitk::USImage::Pointer usImage = mitk::USImage::New(); + MITK_TEST_CONDITION_REQUIRED(usImage.IsNotNull(), "USImage should not be null after instantiation"); + } + + static void TestMetadataInProperties(){ + mitk::USImage::Pointer usImage = mitk::USImage::New(); + mitk::USImageMetadata::Pointer meta1 = mitk::USImageMetadata::New(); + // Create a complete metadataset and write it to the image + meta1->SetDeviceComment("comment"); + meta1->SetDeviceIsVideoOnly(true); + meta1->SetDeviceManufacturer("manufacturer"); + meta1->SetDeviceModel("model"); + meta1->SetProbeFrequency("7 MHz"); + meta1->SetProbeName("CA X3"); + meta1->SetZoom("3x"); + usImage->SetMetadata(meta1); + + //read metadata from image an compare for equality + mitk::USImageMetadata::Pointer meta2 = usImage->GetMetadata(); + MITK_TEST_CONDITION_REQUIRED(meta1->GetDeviceComment().compare(meta2->GetDeviceComment()) == 0, "Comparing Metadata after write & read: Device Comment"); + MITK_TEST_CONDITION_REQUIRED(meta1->GetDeviceManufacturer().compare(meta2->GetDeviceManufacturer()) == 0, "Comparing Metadata after write & read: Device Manufacturer"); + MITK_TEST_CONDITION_REQUIRED(meta1->GetDeviceModel().compare(meta2->GetDeviceModel()) == 0, "Comparing Metadata after write & read: Device Model"); + MITK_TEST_CONDITION_REQUIRED(meta1->GetDeviceIsVideoOnly() == meta2->GetDeviceIsVideoOnly() , "Comparing Metadata after write & read: IsVideoOnly"); + MITK_TEST_CONDITION_REQUIRED(meta1->GetProbeName().compare(meta2->GetProbeName()) == 0, "Comparing Metadata after write & read: Probe Name"); + MITK_TEST_CONDITION_REQUIRED(meta1->GetProbeFrequency().compare(meta2->GetProbeFrequency()) == 0, "Comparing Metadata after write & read: Frequency"); + MITK_TEST_CONDITION_REQUIRED(meta1->GetZoom().compare(meta2->GetZoom()) == 0, "Comparing Metadata after write & read: Zoom Factor"); + + } + +}; + +/** +* This function is testing methods of the class USImage2D. +*/ +int mitkUSImageTest(int /* argc */, char* /*argv*/[]) +{ + MITK_TEST_BEGIN("mitkUSImage2DTest"); + + mitkUSImageTestClass::TestInstantiation(); + mitkUSImageTestClass::TestMetadataInProperties(); + + MITK_TEST_END(); +} \ No newline at end of file diff --git a/Modules/US/USFilters/mitkUSDevice.H b/Modules/US/USFilters/mitkUSDevice.H index 81d94e968f..18b1fe98d6 100644 --- a/Modules/US/USFilters/mitkUSDevice.H +++ b/Modules/US/USFilters/mitkUSDevice.H @@ -1,94 +1,100 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKUSDevice_H_HEADER_INCLUDED_ #define MITKUSDevice_H_HEADER_INCLUDED_ #include #include "mitkUSProbe.h" #include "mitkUSImageMetadata.h" #include #include #include #include namespace mitk { /**Documentation * \brief A device holds information about it's model, make and the connected probes. It is the * common superclass for all Devices and acts as an image source for mitk Images as well as openCV Images. * if one of these functionalities is not supported by a subclass, it will throw an unsupported Operation Exception. * \ingroup US */ class MitkUS_EXPORT USDevice : public itk::Object { public: mitkClassMacro(USDevice, mitk::ImageSource); mitkNewMacro3Param(Self, std::string, std::string, bool); /** * \brief Add a probe to the device without connecting to it. * This should usually be done before connecting to the probe */ virtual void AddProbe(mitk::USProbe::Pointer probe); /** * \brief Connect to a probe and activate it. The probe should be added first. * Usually, a VideoDevice will just add a probe it want's to connect to, * but an SDK Device might require adding a probe first. */ virtual void ActivateProbe(mitk::USProbe::Pointer probe); /** * \brief Deactivates the currently active probe. */ virtual void DeactivateProbe(); /** * \brief Removes a probe from the ist of currently added probes. */ //virtual void removeProbe(mitk::USProbe::Pointer probe); std::vector GetConnectedProbes(); //########### GETTER & SETTER ##################// itkGetMacro(ActiveProbe, mitk::USProbe::Pointer); std::string GetDeviceManufacturer(); std::string GetDeviceModel(); std::string GetDeviceComment(); bool GetIsVideoOnly(); protected: mitk::USProbe::Pointer m_ActiveProbe; std::vector m_ConnectedProbes; + /** + * \brief This metadata set is privately used to imprint Images with Metadata later. + * At instantiation time, it only contains Information about the Device, + At scan time, it integrates this data with the probe information and imprints it on + the produced images. This field is intentionally hidden from outside interference. + */ mitk::USImageMetadata::Pointer m_Metadata; /** * \brief Enforces minimal Metadata to be set. The isVideoOnly flag indicates that this class * only handles a videostream and does not recieve Metadata from the physical device itself. */ USDevice(std::string manufacturer, std::string model, bool isVideoOnly); virtual ~USDevice(); }; } // namespace mitk #endif \ No newline at end of file diff --git a/Modules/US/USFilters/mitkUSDevice.cpp b/Modules/US/USFilters/mitkUSDevice.cpp index 821f6293f7..67c101e967 100644 --- a/Modules/US/USFilters/mitkUSDevice.cpp +++ b/Modules/US/USFilters/mitkUSDevice.cpp @@ -1,81 +1,81 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkUSDevice.h" #include "mitkUSImageMetadata.h" mitk::USDevice::USDevice(std::string manufacturer, std::string model, bool isVideoOnly) : itk::Object() { m_Metadata = mitk::USImageMetadata::New(); m_Metadata->SetDeviceManufacturer(manufacturer); m_Metadata->SetDeviceModel(model); - m_Metadata->SetIsVideoOnly(isVideoOnly); + m_Metadata->SetDeviceIsVideoOnly(isVideoOnly); } mitk::USDevice::~USDevice() { } void mitk::USDevice::AddProbe(mitk::USProbe::Pointer probe) { for(int i = 0; i < m_ConnectedProbes.size(); i++) { if (m_ConnectedProbes[i]->IsEqualToProbe(probe)) return; } this->m_ConnectedProbes.push_back(probe); } void mitk::USDevice::ActivateProbe(mitk::USProbe::Pointer probe){ // currently, we may just add the probe. This behaviour must be changed, should more complicated SDK applications emerge AddProbe(probe); int index = -1; for(int i = 0; i < m_ConnectedProbes.size(); i++) { if (m_ConnectedProbes[i]->IsEqualToProbe(probe)) index = i; } // index now contains the position of the original instance of this probe m_ActiveProbe = m_ConnectedProbes[index]; } void mitk::USDevice::DeactivateProbe(){ m_ActiveProbe = 0; } //########### GETTER & SETTER ##################// std::string mitk::USDevice::GetDeviceManufacturer(){ return this->m_Metadata->GetDeviceManufacturer(); } std::string mitk::USDevice::GetDeviceModel(){ return this->m_Metadata->GetDeviceModel(); } std::string mitk::USDevice::GetDeviceComment(){ return this->m_Metadata->GetDeviceComment(); } bool mitk::USDevice::GetIsVideoOnly(){ - return this->m_Metadata->GetIsVideoOnly(); + return this->m_Metadata->GetDeviceIsVideoOnly(); } std::vector mitk::USDevice::GetConnectedProbes() { return m_ConnectedProbes; } diff --git a/Modules/US/USFilters/mitkUSImage.cpp b/Modules/US/USFilters/mitkUSImage.cpp index 363abffade..c888eba45b 100644 --- a/Modules/US/USFilters/mitkUSImage.cpp +++ b/Modules/US/USFilters/mitkUSImage.cpp @@ -1,29 +1,57 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkUSImage.h" +#include +#include mitk::USImage::USImage() : mitk::Image() { } mitk::USImage::~USImage() { +} + +mitk::USImageMetadata::Pointer mitk::USImage::GetMetadata(){ + mitk::USImageMetadata::Pointer result = mitk::USImageMetadata::New(); + + result->SetDeviceManufacturer(this->GetProperty(mitk::USImageMetadata::PROP_DEV_MANUFACTURER)->GetValueAsString()); + result->SetDeviceModel( this->GetProperty(mitk::USImageMetadata::PROP_DEV_MODEL)->GetValueAsString()); + result->SetDeviceComment( this->GetProperty(mitk::USImageMetadata::PROP_DEV_COMMENT)->GetValueAsString()); + result->SetDeviceIsVideoOnly( this->GetProperty(mitk::USImageMetadata::PROP_DEV_ISVIDEOONLY)); + result->SetProbeName( this->GetProperty(mitk::USImageMetadata::PROP_PROBE_NAME)->GetValueAsString()); + result->SetProbeFrequency( this->GetProperty(mitk::USImageMetadata::PROP_PROBE_FREQUENCY)->GetValueAsString()); + result->SetZoom( this->GetProperty(mitk::USImageMetadata::PROP_ZOOM)->GetValueAsString()); + + + return result; +} + + +void mitk::USImage::SetMetadata(mitk::USImageMetadata::Pointer metadata){ + this->SetProperty(mitk::USImageMetadata::PROP_DEV_MANUFACTURER, mitk::StringProperty::New(metadata->GetDeviceManufacturer())); + this->SetProperty(mitk::USImageMetadata::PROP_DEV_MODEL, mitk::StringProperty::New(metadata->GetDeviceModel())); + this->SetProperty(mitk::USImageMetadata::PROP_DEV_COMMENT, mitk::StringProperty::New(metadata->GetDeviceComment())); + this->SetProperty(mitk::USImageMetadata::PROP_DEV_ISVIDEOONLY, mitk::BoolProperty::New(metadata->GetDeviceIsVideoOnly())); + this->SetProperty(mitk::USImageMetadata::PROP_PROBE_NAME, mitk::StringProperty::New(metadata->GetProbeName())); + this->SetProperty(mitk::USImageMetadata::PROP_PROBE_FREQUENCY, mitk::StringProperty::New(metadata->GetProbeFrequency())); + this->SetProperty(mitk::USImageMetadata::PROP_ZOOM, mitk::StringProperty::New(metadata->GetZoom())); } \ No newline at end of file diff --git a/Modules/US/USFilters/mitkUSImage.h b/Modules/US/USFilters/mitkUSImage.h index fb39e6a020..332a37738d 100644 --- a/Modules/US/USFilters/mitkUSImage.h +++ b/Modules/US/USFilters/mitkUSImage.h @@ -1,52 +1,57 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKUSIMAGE_H_HEADER_INCLUDED_ #define MITKUSIMAGE_H_HEADER_INCLUDED_ #include #include #include #include "mitkUSImageMetadata.h" namespace mitk { /**Documentation - * \brief This specialization of mitk::Image only appends necessary Metadata to an MITK image. Otherwise it can safely be treated it's mother class. + * \brief This specialization of mitk::Image only appends necessary Metadata to an MITK image. Otherwise it can safely be treated like it's mother class. * \ingroup US */ class MitkUS_EXPORT USImage : public mitk::Image { public: mitkClassMacro(USImage, mitk::Image); itkNewMacro(Self); - itkGetMacro(Metadata, mitk::USImageMetadata::Pointer); - itkSetMacro(Metadata, mitk::USImageMetadata::Pointer); + /** + * \brief reads out this image's Metadata set from the properties and returns a corresponding USImageMetadata object. + */ + mitk::USImageMetadata::Pointer GetMetadata(); + + /** + * \brief writes the information of the metadata object into the image's properties. + */ + void SetMetadata(mitk::USImageMetadata::Pointer metadata); + protected: USImage(); - virtual ~USImage(); - USImageMetadata::Pointer m_Metadata; + virtual ~USImage(); - - }; } // namespace mitk #endif \ No newline at end of file diff --git a/Modules/US/USFilters/mitkUSImageMetadata.cpp b/Modules/US/USFilters/mitkUSImageMetadata.cpp index 54a4c99641..389b66dccd 100644 --- a/Modules/US/USFilters/mitkUSImageMetadata.cpp +++ b/Modules/US/USFilters/mitkUSImageMetadata.cpp @@ -1,29 +1,38 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkUSImageMetadata.h" +const char* mitk::USImageMetadata::PROP_DEV_MANUFACTURER = "US_Device_Manufacturer"; +const char* mitk::USImageMetadata::PROP_DEV_MODEL = "US_Device_Model"; +const char* mitk::USImageMetadata::PROP_DEV_COMMENT = "US_Device_Comment"; +const char* mitk::USImageMetadata::PROP_DEV_ISVIDEOONLY = "US_Device_VideoOnly"; +const char* mitk::USImageMetadata::PROP_PROBE_NAME = "US_Probe_Name"; +const char* mitk::USImageMetadata::PROP_PROBE_FREQUENCY = "US_Probe_Frequency"; +const char* mitk::USImageMetadata::PROP_ZOOM = "US_Zoom_Factor"; + + mitk::USImageMetadata::USImageMetadata() : itk::Object() { } mitk::USImageMetadata::~USImageMetadata() { } \ No newline at end of file diff --git a/Modules/US/USFilters/mitkUSImageMetadata.h b/Modules/US/USFilters/mitkUSImageMetadata.h index 87f3920aba..a97fcee484 100644 --- a/Modules/US/USFilters/mitkUSImageMetadata.h +++ b/Modules/US/USFilters/mitkUSImageMetadata.h @@ -1,71 +1,85 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKUSIMAGEMETADATA_H_HEADER_INCLUDED_ #define MITKUSIMAGEMETADATA_H_HEADER_INCLUDED_ #include #include #include #include namespace mitk { /**Documentation * \brief TODO * \ingroup US */ class MitkUS_EXPORT USImageMetadata : public itk::Object { public: mitkClassMacro(USImageMetadata, itk::Object); itkNewMacro(Self); //## getter and setter ## itkGetMacro(DeviceManufacturer, std::string); itkSetMacro(DeviceManufacturer, std::string); itkGetMacro(DeviceModel, std::string); itkSetMacro(DeviceModel, std::string); itkGetMacro(DeviceComment, std::string); itkSetMacro(DeviceComment, std::string); itkGetMacro(ProbeName, std::string); itkSetMacro(ProbeName, std::string); itkGetMacro(ProbeFrequency, std::string); itkSetMacro(ProbeFrequency, std::string); itkGetMacro(Zoom, std::string); itkSetMacro(Zoom, std::string); - itkGetMacro(IsVideoOnly, bool); - itkSetMacro(IsVideoOnly, bool); + itkGetMacro(DeviceIsVideoOnly, bool); + itkSetMacro(DeviceIsVideoOnly, bool); + + // The following constants define how metadata is written to and read from an mitk image + // when defining new properties, add them here, define them in the cpp, and add them to + // USImage's getMetadata and setMetadata methods as well + static const char* PROP_DEV_MANUFACTURER; + static const char* PROP_DEV_MODEL; + static const char* PROP_DEV_COMMENT; + static const char* PROP_DEV_ISVIDEOONLY; + static const char* PROP_PROBE_NAME; + static const char* PROP_PROBE_FREQUENCY; + static const char* PROP_ZOOM; + protected: USImageMetadata(); virtual ~USImageMetadata(); std::string m_DeviceManufacturer; std::string m_DeviceModel; std::string m_DeviceComment; std::string m_ProbeName; std::string m_ProbeFrequency; std::string m_Zoom; - bool m_IsVideoOnly; + bool m_DeviceIsVideoOnly; + + }; } // namespace mitk #endif \ No newline at end of file