1 #include <tclap/CmdLine.h> 4 #include <itkImageFileReader.h> 5 #include <itkImageFileWriter.h> 9 int main(
int argc,
char *argv[] )
11 TCLAP::CmdLine cmd(
"SimuBlochIR-SE: Simulator for Inversion Recovery - Spin Echo\nINRIA / IRISA - VisAGeS/Empenn Team",
' ',ANIMA_VERSION);
13 TCLAP::ValueArg<std::string> t1MapArg(
"",
"t1",
"Input T1 map",
true,
"",
"T1 map",cmd);
14 TCLAP::ValueArg<std::string> t2MapArg(
"",
"t2",
"Input T2 map",
true,
"",
"T2 map",cmd);
15 TCLAP::ValueArg<std::string> m0ImageArg(
"",
"m0",
"Input M0 image",
true,
"",
"M0 image",cmd);
16 TCLAP::ValueArg<std::string> resArg(
"o",
"output",
"Output simulated image for Inversion Recovery - Spin Echo",
true,
"",
"output simulated image",cmd);
18 TCLAP::ValueArg<double> trArg(
"r",
"tr",
"TR value (ms), default: 2400ms",
false,2400,
"TR value",cmd);
19 TCLAP::ValueArg<double> teArg(
"e",
"te",
"TE value (ms), default: 20ms",
false,20,
"TE value",cmd);
20 TCLAP::ValueArg<double> tiArg(
"i",
"ti",
"TI value (ms), default: 1200ms",
false,1200,
"TR value",cmd);
26 catch (TCLAP::ArgException& e)
28 std::cerr <<
"Error: " << e.error() <<
"for argument " << e.argId() << std::endl;
33 std::string input1FileName = t1MapArg.getValue();
34 std::string input2FileName = t2MapArg.getValue();
35 std::string input3FileName = m0ImageArg.getValue();
36 std::string outputFileName = resArg.getValue();
37 double TR = trArg.getValue();
38 double TE = teArg.getValue();
39 double TI = tiArg.getValue();
42 if ((TR < 0) || (TE < 0) || (TI < 0))
44 std::cerr <<
"Error: " << std::endl;
45 std::cerr <<
"TR(ms) < 0 or TE(ms) < 0 or TI(ms) < 0" << std::endl;
46 std::cerr <<
"Please set TR(ms) >= 0 and TE(ms) >= 0 and TI(ms) >= 0." << std::endl;
53 std::cerr <<
"Error: " << std::endl;
54 std::cerr <<
"TE + TI >= TR" << std::endl;
55 std::cerr <<
"Please set TE, TI and TR values which satisfy TE + TI < TR." << std::endl;
61 typedef itk::Image<double, 3> ImageType;
65 typedef itk::ImageFileReader<ImageType> ReaderType;
66 ReaderType::Pointer reader1 = ReaderType::New();
67 reader1->SetFileName(input1FileName);
71 typedef itk::ImageFileReader<ImageType> ReaderType;
72 ReaderType::Pointer reader2 = ReaderType::New();
73 reader2->SetFileName(input2FileName);
77 typedef itk::ImageFileReader<ImageType> ReaderType;
78 ReaderType::Pointer reader3 = ReaderType::New();
79 reader3->SetFileName(input3FileName);
83 ReaderType::SizeType size1 = reader1->GetOutput()->GetLargestPossibleRegion().GetSize();
84 ReaderType::SizeType size2 = reader2->GetOutput()->GetLargestPossibleRegion().GetSize();
85 ReaderType::SizeType size3 = reader3->GetOutput()->GetLargestPossibleRegion().GetSize();
88 if ( ((
sizeof(size1)/
sizeof(size1[0])) != (
sizeof(size2)/
sizeof(size2[0])))
89 || ((
sizeof(size1)/
sizeof(size1[0])) != (
sizeof(size3)/
sizeof(size3[0]))) )
91 std::cerr <<
"Error: " << std::endl;
92 std::cerr <<
"The dimensions of the input images are not the same." << std::endl;
93 std::cerr <<
"Please input the images with the same dimension." << std::endl;
98 if (((size1[0] != size2[0]) || (size1[0] != size3[0]))
99 || ((size1[1] != size2[1]) || (size1[1] != size3[1]))
100 || ((size1[2] != size2[2]) || (size1[2] != size3[2])) )
102 std::cerr <<
"Error: " << std::endl;
103 std::cerr <<
"The sizes of the input images are not the same." << std::endl;
104 std::cerr <<
"Please input the images with the same size." << std::endl;
109 FilterType::Pointer filter = FilterType::New();
110 filter->SetInput(0,reader1->GetOutput());
111 filter->SetInput(1,reader2->GetOutput());
112 filter->SetInput(2,reader3->GetOutput());
119 typedef itk::ImageFileWriter< ImageType > WriterType;
120 WriterType::Pointer writer = WriterType::New();
121 writer->SetFileName(outputFileName);
122 writer->SetInput(filter->GetOutput());
int main(int argc, char *argv[])