18 #include <itkExceptionObject.h>
19 #include <itkImageFileWriter.h>
25 #include <boost/algorithm/string.hpp>
26 #include <itksys/SystemTools.hxx>
27 #include <itkMultiThreader.h>
35 int main(
int argc,
char* argv[])
39 parser.
setTitle(
"Diffusion Indices");
41 parser.
setDescription(
"Computes requested diffusion related measures");
46 parser.
addArgument(
"index",
"idx",
mitkCommandLineParser::String,
"Index:",
"index (fa, gfa, ra, ad, rd, ca, l2, l3, md)",
us::Any(),
false);
49 map<string, us::Any> parsedArgs = parser.
parseArguments(argc, argv);
50 if (parsedArgs.size()==0)
53 string inFileName =
us::any_cast<
string>(parsedArgs[
"input"]);
54 string index =
us::any_cast<
string>(parsedArgs[
"index"]);
55 string outFileName =
us::any_cast<
string>(parsedArgs[
"outFile"]);
57 string ext = itksys::SystemTools::GetFilenameLastExtension(outFileName);
59 outFileName +=
".nrrd";
66 if( boost::algorithm::ends_with(inFileName,
".qbi") && index==
"gfa" )
68 typedef itk::Vector<float, QBALL_ODFSIZE> OdfVectorType;
69 typedef itk::Image<OdfVectorType,3> ItkQballImageType;
77 gfaFilter->SetInput(itk_qbi);
78 gfaFilter->SetComputationMethod(GfaFilterType::GFA_STANDARD);
81 itk::ImageFileWriter< itk::Image<float,3> >
::Pointer fileWriter = itk::ImageFileWriter< itk::Image<float,3> >
::New();
82 fileWriter->SetInput(gfaFilter->GetOutput());
83 fileWriter->SetFileName(outFileName);
86 else if( boost::algorithm::ends_with(inFileName,
".dti") )
88 typedef itk::Image< itk::DiffusionTensor3D<float>, 3 >
ItkTensorImage;
95 measurementsCalculator->SetInput(itk_dti.GetPointer() );
98 measurementsCalculator->SetMeasure(MeasurementsType::FA);
100 measurementsCalculator->SetMeasure(MeasurementsType::RA);
102 measurementsCalculator->SetMeasure(MeasurementsType::AD);
104 measurementsCalculator->SetMeasure(MeasurementsType::RD);
106 measurementsCalculator->SetMeasure(MeasurementsType::CA);
108 measurementsCalculator->SetMeasure(MeasurementsType::L2);
110 measurementsCalculator->SetMeasure(MeasurementsType::L3);
112 measurementsCalculator->SetMeasure(MeasurementsType::MD);
115 MITK_WARN <<
"No valid diffusion index for input image (tensor image) defined";
119 measurementsCalculator->Update();
121 itk::ImageFileWriter< itk::Image<float,3> >
::Pointer fileWriter = itk::ImageFileWriter< itk::Image<float,3> >
::New();
122 fileWriter->SetInput(measurementsCalculator->GetOutput());
123 fileWriter->SetFileName(outFileName);
124 fileWriter->Update();
127 std::cout <<
"Diffusion index " << index <<
" not supported for supplied file type.";
129 catch (itk::ExceptionObject e)
134 catch (std::exception e)
136 std::cout << e.what();
141 std::cout <<
"ERROR!?!";
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)
this class encapsulates qball images
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)
void setCategory(std::string category)
void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix)
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
this class encapsulates tensor images
itk::Image< itk::DiffusionTensor3D< float >, 3 > ItkTensorImage
static DataStorage::SetOfObjects::Pointer Load(const std::string &path, DataStorage &storage)
Load a file into the given DataStorage.
int main(int argc, char *argv[])
void setTitle(std::string title)
void setDescription(std::string description)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.