30 #include "itkDiffusionTensor3DReconstructionImageFilter.h"
33 #include <itkImageFileWriter.h>
34 #include <itkNrrdImageIO.h>
35 #include <itkDiffusionTensor3D.h>
47 typedef itk::DiffusionTensor3D< TTensorPixelType > TensorPixelType;
48 typedef itk::Image< TensorPixelType, 3 > TensorImageType;
56 measurementsCalculator->SetInput(itkvol.GetPointer() );
60 measurementsCalculator->SetMeasure(MeasurementsType::FA);
61 measurementsCalculator->Update();
62 map->InitializeByItk( measurementsCalculator->GetOutput() );
63 map->SetVolume( measurementsCalculator->GetOutput()->GetBufferPointer() );
67 measurementsCalculator->SetMeasure(MeasurementsType::MD);
68 measurementsCalculator->Update();
69 map->InitializeByItk( measurementsCalculator->GetOutput() );
70 map->SetVolume( measurementsCalculator->GetOutput()->GetBufferPointer() );
74 measurementsCalculator->SetMeasure(MeasurementsType::AD);
75 measurementsCalculator->Update();
76 map->InitializeByItk( measurementsCalculator->GetOutput() );
77 map->SetVolume( measurementsCalculator->GetOutput()->GetBufferPointer() );
82 measurementsCalculator->SetMeasure(MeasurementsType::CA);
83 measurementsCalculator->Update();
84 map->InitializeByItk( measurementsCalculator->GetOutput() );
85 map->SetVolume( measurementsCalculator->GetOutput()->GetBufferPointer() );
89 measurementsCalculator->SetMeasure(MeasurementsType::RA);
90 measurementsCalculator->Update();
91 map->InitializeByItk( measurementsCalculator->GetOutput() );
92 map->SetVolume( measurementsCalculator->GetOutput()->GetBufferPointer() );
96 measurementsCalculator->SetMeasure(MeasurementsType::RD);
97 measurementsCalculator->Update();
98 map->InitializeByItk( measurementsCalculator->GetOutput() );
99 map->SetVolume( measurementsCalculator->GetOutput()->GetBufferPointer() );
105 int main(
int argc,
char* argv[])
113 parser.
setTitle(
"Tensor Derived Maps Extraction");
118 map<string, us::Any> parsedArgs = parser.
parseArguments(argc, argv);
119 if (parsedArgs.size()==0)
126 std::string inputFile =
us::any_cast<
string>(parsedArgs[
"input"]);
127 std::string baseFileName =
us::any_cast<
string>(parsedArgs[
"out"]);
129 std::string dtiFileName =
"_dti.dti";
135 MITK_ERROR <<
"Invalid Input Image. Must be DWI. Aborting.";
139 typedef itk::DiffusionTensor3DReconstructionImageFilter< DiffusionPixelType, DiffusionPixelType, TTensorPixelType > TensorReconstructionImageFilterType;
145 gradientContainerCopy->push_back(it.Value());
151 tensorReconstructionFilter->SetGradientImage( gradientContainerCopy, itkVectorImagePointer );
153 tensorReconstructionFilter->SetThreshold(50);
154 tensorReconstructionFilter->Update();
156 typedef itk::Image<itk::DiffusionTensor3D<TTensorPixelType>, 3> TensorImageType;
158 tensorImage->SetDirection( itkVectorImagePointer->GetDirection() );
161 tensorImageMitk->InitializeByItk(tensorImage.GetPointer());
162 tensorImageMitk->SetVolume( tensorImage->GetBufferPointer() );
167 io->SetFileType( itk::ImageIOBase::Binary );
168 io->UseCompressionOn();
170 itk::ImageFileWriter< itk::Image< itk::DiffusionTensor3D< double >, 3 > >
::Pointer writer = itk::ImageFileWriter< itk::Image< itk::DiffusionTensor3D< double >, 3 > >
::New();
171 writer->SetInput(tensorReconstructionFilter->GetOutput());
172 writer->SetFileName(baseFileName + dtiFileName);
173 writer->SetImageIO(io);
174 writer->UseCompressionOn();
bool IsDiffusionWeightedImage() const
static void Save(const mitk::BaseData *data, const std::string &path)
Save a mitk::BaseData instance.
itk::SmartPointer< Self > Pointer
void setContributor(std::string contributor)
ValueType * any_cast(Any *operand)
std::map< std::string, us::Any > parseArguments(const StringContainerType &arguments, bool *ok=nullptr)
void addArgument(const std::string &longarg, const std::string &shortarg, Type type, const std::string &argLabel, const std::string &argHelp=std::string(), const us::Any &defaultValue=us::Any(), bool optional=true, bool ignoreRest=false, bool deprecated=false)
static const std::string filename
Image class for storing images.
void setCategory(std::string category)
void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix)
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.
std::string helpText() const
GradientDirectionsContainerType::Pointer GetGradientContainer() const
void setTitle(std::string title)
void setDescription(std::string description)
static mitk::Image::Pointer LoadImage(const std::string &path)
LoadImage Convenience method to load an arbitrary mitkImage.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.