1 #include <tclap/CmdLine.h> 3 #include <itkVectorImage.h> 10 int main(
int argc,
char **argv)
12 TCLAP::CmdLine cmd(
"INRIA / IRISA - VisAGeS/Empenn Team",
' ',ANIMA_VERSION);
14 TCLAP::ValueArg<std::string> inFileArg(
"i",
"input",
"list of MCM images (one per line)",
true,
"",
"MCM images",cmd);
15 TCLAP::ValueArg<std::string> maskArg(
"m",
"maskfiles",
"Input masks list in text file (mask images should contain only zeros or ones)",
false,
"",
"input masks list",cmd);
16 TCLAP::ValueArg<std::string> resArg(
"o",
"output",
"Average MCM volume",
true,
"",
"result MCM volume",cmd);
17 TCLAP::ValueArg<int> outputFascicleArg(
"n",
"nb-of-output-fascicle",
"number of output fascicles",
true, 0,
"number of output fascicles",cmd);
18 TCLAP::ValueArg<unsigned int> nbpArg(
"p",
"numberofthreads",
"Number of threads to run on (default: all cores)",
false,itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads(),
"number of threads",cmd);
24 catch (TCLAP::ArgException& e)
26 std::cerr <<
"Error: " << e.error() <<
"for argument " << e.argId() << std::endl;
34 typedef itk::VectorImage<double, 3> ImageType;
38 std::ifstream inputFile(inFileArg.getValue().c_str());
40 if (!inputFile.is_open())
42 std::cerr <<
"Please provide usable file with input MCMs" << std::endl;
46 unsigned int nbOfImages = 0;
49 while (!inputFile.eof())
52 inputFile.getline(tmpStr,2048);
54 if (strcmp(tmpStr,
"") == 0)
57 std::cout <<
"Loading image " << nbOfImages <<
" : " << tmpStr << std::endl;
59 MCMReaderType mcmReader;
60 mcmReader.SetFileName(tmpStr);
63 mainFilter->SetInput(nbOfImages,mcmReader.GetModelVectorImage());
65 if ((firstInputModel.IsNull()&&
66 (mcmReader.GetModelVectorImage()->GetDescriptionModel()->GetNumberOfCompartments() > mcmReader.GetModelVectorImage()->GetDescriptionModel()->GetNumberOfIsotropicCompartments())))
67 firstInputModel = mcmReader.GetModelVectorImage()->GetDescriptionModel();
72 std::ifstream masksIn;
73 if (maskArg.getValue() !=
"")
74 masksIn.open(maskArg.getValue());
77 if (masksIn.is_open())
80 while (!masksIn.eof())
82 masksIn.getline(tmpStr,2048);
84 if (strcmp(tmpStr,
"") == 0)
87 mainFilter->
AddMaskImage(anima::readImage <MaskImageType> (tmpStr));
97 for (
unsigned int i = 0;i < firstInputModel->GetNumberOfIsotropicCompartments();++i)
99 switch (firstInputModel->GetCompartment(i)->GetCompartmentType())
118 std::cerr <<
"Unhandled isotropic compartment" << std::endl;
123 mcmCreator.
SetCompartmentType(firstInputModel->GetCompartment(firstInputModel->GetNumberOfIsotropicCompartments())->GetCompartmentType());
129 mainFilter->SetNumberOfWorkUnits(nbpArg.getValue());
130 mainFilter->Update();
132 MCMWriterType mcmWriter;
133 mcmWriter.SetInputImage(mainFilter->GetOutput());
135 mcmWriter.SetFileName(resArg.getValue());
MCMPointer GetNewMultiCompartmentModel()
itk::SmartPointer< Self > Pointer
void SetNumberOfCompartments(unsigned int num)
void AddMaskImage(MaskImageType *maskImage)
void SetReferenceOutputModel(MCModelPointer &model)
void SetModelWithStationaryWaterComponent(bool arg)
itk::SmartPointer< Self > Pointer
itk::Image< unsigned char, 3 > MaskImageType
void SetModelWithStaniszComponent(bool arg)
void SetModelWithRestrictedWaterComponent(bool arg)
void SetCompartmentType(CompartmentType arg)
int main(int argc, char **argv)
Really this class is some simplified factory that creates the MCM that it knows.
void SetModelWithFreeWaterComponent(bool arg)