3 #include <tclap/CmdLine.h> 5 #include <itkVectorImage.h> 6 #include <itkImageFileReader.h> 7 #include <itkImageFileWriter.h> 11 int main(
int argc,
char *argv[] )
13 TCLAP::CmdLine cmd(
"Simulator for stimulated spin echo T2 sequences\nINRIA / IRISA - VisAGeS/Empenn Team",
' ',ANIMA_VERSION);
15 TCLAP::ValueArg<std::string> t1MapArg(
"",
"t1",
"Input T1 map",
true,
"",
"T1 map",cmd);
16 TCLAP::ValueArg<std::string> t2MapArg(
"",
"t2",
"Input T2 map",
true,
"",
"T2 map",cmd);
17 TCLAP::ValueArg<std::string> m0ImageArg(
"",
"m0",
"Input M0 image",
true,
"",
"M0 image",cmd);
18 TCLAP::ValueArg<std::string> b1ImageArg(
"",
"b1",
"Input B1 image",
false,
"",
"B1 image",cmd);
19 TCLAP::ValueArg<std::string> resArg(
"o",
"output",
"Output simulated image",
true,
"",
"output simulated image",cmd);
21 TCLAP::ValueArg<unsigned int> neArg(
"n",
"ne",
"Number of echoes, default: 7",
false, 7,
"number of echoes",cmd);
22 TCLAP::ValueArg<double> teArg(
"e",
"te",
"TE echo spacing (ms), default: 10ms",
false, 10,
"TE value",cmd);
23 TCLAP::ValueArg<double> xfaArg(
"x",
"excite-fa",
"Excitation flip angle (degrees), default: 90 degrees",
false, 90,
"excitation flip angle value",cmd);
24 TCLAP::ValueArg<double> faArg(
"f",
"fa",
"Flip angle (degrees), default: 180 degrees",
false, 180,
"flip angle value",cmd);
26 TCLAP::ValueArg<unsigned int> nbpArg(
"T",
"numberofthreads",
"Number of threads to run on (default : all cores)",
false,itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads(),
"number of threads",cmd);
32 catch (TCLAP::ArgException& e)
34 std::cerr <<
"Error: " << e.error() <<
"for argument " << e.argId() << std::endl;
39 std::string input1FileName = t1MapArg.getValue();
40 std::string input2FileName = t2MapArg.getValue();
41 std::string input3FileName = m0ImageArg.getValue();
42 std::string outputFileName = resArg.getValue();
45 typedef itk::Image<double, 3> ImageType;
46 typedef itk::VectorImage<double, 3> OutputImageType;
50 typedef itk::ImageFileReader<ImageType> ReaderType;
51 ReaderType::Pointer reader1 = ReaderType::New();
52 reader1->SetFileName(input1FileName);
56 ReaderType::Pointer reader2 = ReaderType::New();
57 reader2->SetFileName(input2FileName);
61 ReaderType::Pointer reader3 = ReaderType::New();
62 reader3->SetFileName(input3FileName);
65 FilterType::Pointer filter = FilterType::New();
66 filter->SetInput(0,reader1->GetOutput());
67 filter->SetInput(1,reader2->GetOutput());
68 filter->SetInput(2,reader3->GetOutput());
69 filter->SetNumberOfWorkUnits(nbpArg.getValue());
72 if (b1ImageArg.getValue() !=
"")
74 ReaderType::Pointer readerB1 = ReaderType::New();
75 readerB1->SetFileName(b1ImageArg.getValue().c_str());
78 filter->SetInput(3,readerB1->GetOutput());
81 filter->SetEchoSpacing(teArg.getValue());
82 filter->SetFlipAngle(faArg.getValue() * M_PI / 180.0);
83 filter->SetNumberOfEchoes(neArg.getValue());
84 filter->SetExcitationFlipAngle(xfaArg.getValue() * M_PI / 180.0);
89 typedef itk::ImageFileWriter <FilterType::Image4DType> WriterType;
90 WriterType::Pointer writer = WriterType::New();
91 writer->SetFileName(outputFileName);
92 writer->SetInput(filter->GetOutputAs4DImage());
int main(int argc, char *argv[])