22 #include <itkDiffusionTensor3DReconstructionImageFilter.h>
23 #include <itkDiffusionTensor3D.h>
24 #include <itkImageFileWriter.h>
25 #include <itkNrrdImageIO.h>
27 #include <itksys/SystemTools.hxx>
35 int main(
int argc,
char* argv[])
44 parser.
setTitle(
"Tensor Reconstruction");
48 map<string, us::Any> parsedArgs = parser.
parseArguments(argc, argv);
49 if (parsedArgs.size()==0)
52 std::string inFileName =
us::any_cast<
string>(parsedArgs[
"input"]);
53 std::string outfilename =
us::any_cast<
string>(parsedArgs[
"outFile"]);
54 outfilename = itksys::SystemTools::GetFilenamePath(outfilename)+
"/"+itksys::SystemTools::GetFilenameWithoutExtension(outfilename);
55 outfilename +=
".dti";
58 if (parsedArgs.count(
"b0Threshold"))
59 threshold = us::any_cast<int>(parsedArgs[
"b0Threshold"]);
68 typedef itk::DiffusionTensor3DReconstructionImageFilter< short, short, float > TensorReconstructionImageFilterType;
72 filter->SetThreshold(threshold);
77 io->SetFileType( itk::ImageIOBase::Binary );
78 io->UseCompressionOn();
80 itk::ImageFileWriter< itk::Image< itk::DiffusionTensor3D< float >, 3 > >
::Pointer writer = itk::ImageFileWriter< itk::Image< itk::DiffusionTensor3D< float >, 3 > >
::New();
81 writer->SetInput(filter->GetOutput());
82 writer->SetFileName(outfilename);
83 writer->SetImageIO(io);
84 writer->UseCompressionOn();
87 catch ( itk::ExceptionObject &err)
89 std::cout <<
"Exception: " << err;
91 catch ( std::exception err)
93 std::cout <<
"Exception: " << err.what();
97 std::cout <<
"Exception!";
itk::SmartPointer< Self > Pointer
void setContributor(std::string contributor)
DataCollection - Class to facilitate loading/accessing structured data.
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)
void setCategory(std::string category)
int main(int argc, char *argv[])
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.
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.