22 #include "DWIPreprocessCLP.h" 28 main (
int argc,
char const* argv[])
34 typedef float FloatType;
37 DWIReaderType::Pointer reader = DWIReaderType::New();
38 reader->SetConfigurationFile(_InputFile);
39 if (_MaskFileArg.isSet())
41 typedef DWIReaderType::MaskImageType MaskImageType;
42 MaskImageType::Pointer maskImage;
43 itk::ReadImage<MaskImageType>(_MaskFile, maskImage);
44 reader->SetMaskImage(maskImage);
47 reader->SetShowWarnings(_WarnArg.isSet());
48 if (_DebugArg.isSet())
50 if (_NoNormalizeDWIArg.isSet())
51 reader->SetNormalizeDWI(
false);
52 if (_IsVectorImageArg.isSet())
53 reader->SetIsInput4DImage(
false);
54 if (_BThresholdArg.isSet())
55 reader->GetSamplingSchemeQSpace()->SetBThresholdSingleShell(_BThreshold);
58 DWIReaderType::DWIImageType::Pointer dwiImage;
59 DWIReaderType::B0ImageType::Pointer b0Image;
60 dwiImage = reader->GetOutput();
61 b0Image = reader->GetB0Image();
63 if (_B0ImageFileArg.isSet())
67 DWIWriterType::Pointer writer = DWIWriterType::New();
68 writer->SetInput(dwiImage);
69 if (_OutputEachShellArg.isSet())
70 writer->SetOutputEachShell(
true);
71 writer->SetSamplingSchemeQSpace(reader->GetSamplingSchemeQSpace());
72 writer->SetConfigurationFile(_OutputFile);
74 std::string _OutputFile_ext, _OutputFile_noext;
76 if (_BFileArg.isSet())
77 writer->SetBFile(_BFile);
79 writer->SetBFile(_OutputFile_noext +
"_b." + _OutputFile_ext);
80 if (_GradFileArg.isSet())
81 writer->SetOrientationFile(_GradFile);
83 writer->SetOrientationFile(_OutputFile_noext +
"_grad." + _OutputFile_ext);
84 if (_DWIFileArg.isSet())
85 writer->SetDWIFile(_DWIFile);
87 writer->SetDWIFile(_OutputFile_noext +
"_dwi.nii.gz");
helper functions specifically used in dmritool
bool SaveImage(const SmartPointer< ImageType > &image, const std::string &filename, const std::string &printInfo="Writing Image:")
write gradient file, b values and DWI files (with optional index file)
Load gradient file, b values and DWI files (with optional index file)
int main(int argc, char const *argv[])
Read DWI images, gradients, b values, and output the formal normalized formalt in a configuration fil...
void GetFileExtension(const std::string &fileNameAbsolute, std::string &ext, std::string &fileNoExt)