MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkUSPipelineTest.cpp
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12
13#include "mitkUSVideoDevice.h"
14#include "mitkTestingMacros.h"
15#include "mitkUSImageToUSImageFilter.h"
16#include <mitkImageWriteAccessor.h>
17
18// START TESTFILER
19// This is an specialization of the USImageToUSImageFIlter
20
21 class TestUSFilter : public mitk::USImageToUSImageFilter
22 {
23 protected:
24 TestUSFilter() : mitk::USImageToUSImageFilter(){};
25 virtual ~TestUSFilter(){};
26
27 public:
28 mitkClassMacro(TestUSFilter, mitk::USImageToUSImageFilter);
30 itkCloneMacro(Self)
31
32 virtual void GenerateOutputInformation()
33 {
34 mitk::Image::Pointer inputImage = (mitk::Image*) this->GetInput(0);
35 mitk::Image::Pointer output = (mitk::Image*) this->GetPrimaryOutput();
36 if(inputImage.IsNull()) return;
37 };
38
39
41 {
42 mitk::USImage::Pointer ni = this->GetInput(0);
43 mitk::USImage::Pointer result = mitk::USImage::New();
44
45 try
46 {
47 mitk::Image::Pointer image = ni.GetPointer();
48 mitk::ImageWriteAccessor imgA(image, image->GetVolumeData(0));
49 result->Initialize(image);
50 result->SetImportVolume(imgA.GetData());
51 mitk::USImageMetadata::Pointer meta = ni->GetMetadata();
52 meta->SetDeviceComment("Test");
53 result->SetMetadata(meta);
54 SetNthOutput(0, result);
55 }
56 catch(mitk::Exception& e)
57 {
58 std::stringstream msg;
59 msg << "Cannot open image for reading: " << e.GetDescription();
60 MITK_TEST_FAILED_MSG(<<msg.str());
61 }
62 };
63 };
64
65
66// END TESTFILTER
67
69{
70
71public:
72
73 static void TestPipelineUS(std::string videoFilePath)
74 {
75 // Set up a pipeline
76 mitk::USVideoDevice::Pointer videoDevice = mitk::USVideoDevice::New(videoFilePath, "Manufacturer", "Model");
77 TestUSFilter::Pointer filter = TestUSFilter::New();
78 videoDevice->Update();
79 filter->SetInput(videoDevice->GetOutput());
80 filter->Update();
81 MITK_TEST_CONDITION_REQUIRED(videoDevice.IsNotNull(), "videoDevice should not be null after instantiation");
82
83 //mitk::USImage::Pointer result = dynamic_cast<mitk::USImage *> (filter->GetOutput());
84 mitk::USImage::Pointer result = filter->GetOutput(0);
85 MITK_TEST_CONDITION_REQUIRED(result.IsNotNull(), "resulting images should not be null");
86 std::string model = result->GetMetadata()->GetDeviceModel();
87 MITK_TEST_CONDITION_REQUIRED(model.compare("Model") == 0 , "Resulting images should have their metadata set correctly");
88 }
89
90};
91
95int mitkUSPipelineTest(int argc , char* argv[])
96{
97 MITK_TEST_BEGIN("mitkUSPipelineTest");
98
99 #ifdef WIN32 // Video file compression is currently only supported under windows.
100 // US Pipelines need to be reworked :(
101 //mitkUSPipelineTestClass::TestPipelineUS(argv[1]);
102 #endif
103
104 MITK_TEST_END();
105}
mitkClassMacro(TestUSFilter, mitk::USImageToUSImageFilter)
itkFactorylessNewMacro(Self) itkCloneMacro(Self) virtual void GenerateOutputInformation()
static void TestPipelineUS(std::string videoFilePath)
int mitkUSPipelineTest(int argc, char *argv[])
IGT Exceptions.