17 #ifndef __mitkDiffusionImageNrrdWriterService__cpp
18 #define __mitkDiffusionImageNrrdWriterService__cpp
21 #include "itkMetaDataDictionary.h"
22 #include "itkMetaDataObject.h"
23 #include "itkNrrdImageIO.h"
24 #include "itkImageFileWriter.h"
25 #include "itksys/SystemTools.hxx"
57 MITK_ERROR <<
"Sorry, input to DiffusionImageNrrdWriterService is NULL!";
60 if ( this->GetOutputLocation().empty() )
62 MITK_ERROR <<
"Sorry, filename has not been set!";
73 if (measurementFrame(0,0) || measurementFrame(0,1) || measurementFrame(0,2) ||
74 measurementFrame(1,0) || measurementFrame(1,1) || measurementFrame(1,2) ||
75 measurementFrame(2,0) || measurementFrame(2,1) || measurementFrame(2,2))
77 sprintf( valbuffer,
" (%lf,%lf,%lf) (%lf,%lf,%lf) (%lf,%lf,%lf)", measurementFrame(0,0), measurementFrame(0,1), measurementFrame(0,2), measurementFrame(1,0), measurementFrame(1,1), measurementFrame(1,2), measurementFrame(2,0), measurementFrame(2,1), measurementFrame(2,2));
78 itk::EncapsulateMetaData<std::string>(itkImg->GetMetaDataDictionary(),std::string(
"measurement frame"),std::string(valbuffer));
81 sprintf( valbuffer,
"DWMRI");
82 itk::EncapsulateMetaData<std::string>(itkImg->GetMetaDataDictionary(),std::string(
"modality"),std::string(valbuffer));
87 itk::EncapsulateMetaData<std::string>(itkImg->GetMetaDataDictionary(),std::string(
"DWMRI_b-value"),std::string(valbuffer));
92 sprintf( keybuffer,
"DWMRI_gradient_%04d", i );
101 itk::EncapsulateMetaData<std::string>(itkImg->GetMetaDataDictionary(),std::string(keybuffer),std::string(valbuffer));
104 typedef itk::VectorImage<short,3>
ImageType;
106 std::string ext = this->GetMimeType()->GetExtension(this->GetOutputLocation());
107 ext = itksys::SystemTools::LowerCase(ext);
113 this->SetOutputLocation(this->GetOutputLocation() + ext);
116 if (ext ==
".hdwi" || ext ==
".nrrd" || ext ==
".dwi")
122 io->SetFileType( itk::ImageIOBase::Binary );
123 io->UseCompressionOn();
125 typedef itk::ImageFileWriter<ImageType> WriterType;
127 nrrdWriter->UseInputMetaDataDictionaryOn();
128 nrrdWriter->SetInput( itkImg );
129 nrrdWriter->SetImageIO(io);
130 nrrdWriter->SetFileName(this->GetOutputLocation());
131 nrrdWriter->UseCompressionOn();
132 nrrdWriter->SetImageIO(io);
135 nrrdWriter->Update();
137 catch (itk::ExceptionObject e)
139 std::cout << e << std::endl;
164 #endif //__mitkDiffusionImageNrrdWriterService__cpp
bool IsDiffusionWeightedImage() const
const MeasurementFrameType & GetMeasurementFrame() const
itk::SmartPointer< Self > Pointer
DataCollection - Class to facilitate loading/accessing structured data.
The CustomMimeType class represents a custom mime-type which may be registered as a service object...
map::core::discrete::Elements< 3 >::InternalImageType ImageType
Convenience class to temporarily change the current locale.
DiffusionImageNrrdWriterService()
virtual ConfidenceLevel GetConfidenceLevel() const override
The confidence level of the reader or writer implementation.
virtual void Write() override
Write the base data to the specified location or output stream.
Image class for storing images.
static const char * GetStaticNameOfClass()
float GetReferenceBValue() const
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
us::ServiceRegistration< IFileWriter > RegisterService(us::ModuleContext *context=us::GetModuleContext())
GradientDirectionsContainerType::Pointer GetGradientContainer() const
ConfidenceLevel
A confidence level describing the confidence of the reader or writer in handling the given data...
virtual ~DiffusionImageNrrdWriterService()
virtual mitk::DiffusionImageNrrdWriterService * Clone() const override
Base class for writing mitk::BaseData objects to files or streams.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.