ANIMA  4.0
animaLowMemPatientToGroupODFComparison.cxx
Go to the documentation of this file.
1 #include <iostream>
2 #include <tclap/CmdLine.h>
3 
5 #include <animaODFFunctions.h>
6 
7 int main(int argc, char **argv)
8 {
9  TCLAP::CmdLine cmd("INRIA / IRISA - VisAGeS/Empenn Team", ' ',ANIMA_VERSION);
10 
11  TCLAP::ValueArg<std::string> refODFArg("i","inputodf","ODF Test Image",true,"","ODF test image",cmd);
12  TCLAP::ValueArg<std::string> dataODFArg("I","databaseodf","ODF Database Image List",true,"","ODF database image list",cmd);
13 
14  TCLAP::ValueArg<std::string> maskArg("m","maskname","Computation mask",true,"","computation mask",cmd);
15  TCLAP::ValueArg<std::string> resArg("o","outputname","Z-Score output image",true,"","Z-Score output image",cmd);
16  TCLAP::ValueArg<std::string> resPValArg("O","outpvalname","P-value output image",true,"","P-Value output image",cmd);
17 
18  TCLAP::ValueArg<std::string> statTestArg("t","stat-test","Statistical test to use ([fisher],chi)",false,"fisher","statistical test",cmd);
19  TCLAP::ValueArg<double> expVarArg("e","expvar","PCA threshold: threshold on eigenvalues to compute the new basis (default: 0.9)",false,0.9,"PCA threshold",cmd);
20  TCLAP::ValueArg<unsigned int> numEigenArg("E","numeigenpca","Number of eigenvalues to keep (default: 6)",false,6,"Number of PCA eigen values",cmd);
21 
22  TCLAP::ValueArg<unsigned int> nbpArg("p","numberofthreads","Number of threads to run on (default: all cores)",false,itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads(),"number of threads",cmd);
23  TCLAP::ValueArg<unsigned int> nbThetaArg("T","theta","Number of theta values (theta varies between 0 and pi/2",false,0,"number of theta values",cmd);
24  TCLAP::ValueArg<unsigned int> nbPhiArg("P","phi","Number of phi values (theta varies between 0 and 2 pi",false,0,"number of phi values",cmd);
25 
26  TCLAP::ValueArg<std::string> samplesFileNameArg("d","sampledirectionsfile","Samples directions in a text file",false,"","Samples directions file",cmd);
27 
28  TCLAP::ValueArg<unsigned int> splitsArg("s","split","Split image for low memory (default: 2)",false,2,"Number of splits",cmd);
29  TCLAP::ValueArg<int> specSplitArg("S","splittoprocess","Specific split to process (use to run on cluster (default: -1 = all)",false,-1,"Split to process",cmd);
30  TCLAP::SwitchArg genOutputDescroArg("G","generateouputdescription","Generate ouptut description data",cmd,false);
31 
32  try
33  {
34  cmd.parse(argc,argv);
35  }
36  catch (TCLAP::ArgException& e)
37  {
38  std::cerr << "Error: " << e.error() << "for argument " << e.argId() << std::endl;
39  return(1);
40  }
41 
42  std::string dataODFName, maskName;
43  dataODFName = dataODFArg.getValue();
44  maskName = maskArg.getValue();
45 
46  typedef anima::LowMemoryPatientToGroupODFComparisonBridge MultiAtlasZScoreBridgeType;
47 
48  MultiAtlasZScoreBridgeType *mainFilter = new MultiAtlasZScoreBridgeType;
49  mainFilter->SetComputationMask(maskName);
50  mainFilter->SetNumberOfWorkUnits(nbpArg.getValue());
51 
52  mainFilter->SetNumEigenValuesPCA(numEigenArg.getValue());
53  mainFilter->SetExplainedRatio(expVarArg.getValue());
54 
55  mainFilter->SetDataODFFileNames(dataODFName);
56  mainFilter->SetTestODFFileName(refODFArg.getValue());
57 
58  std::vector < std::vector <double> > sampleDirections = anima::InitializeSampleDirections(nbThetaArg.getValue(),nbPhiArg.getValue(),
59  samplesFileNameArg.getValue());
60 
61  mainFilter->SetSampleDirections(sampleDirections);
62 
63  if (statTestArg.getValue() == "chi")
64  mainFilter->SetStatisticalTestType(MultiAtlasZScoreBridgeType::MainFilterType::CHI_SQUARE);
65  else
66  mainFilter->SetStatisticalTestType(MultiAtlasZScoreBridgeType::MainFilterType::FISHER);
67 
68  mainFilter->SetOutputName(resArg.getValue());
69  mainFilter->SetOutputPValName(resPValArg.getValue());
70 
71  mainFilter->SetNbSplits(splitsArg.getValue());
72 
73  try
74  {
75  mainFilter->Update(specSplitArg.getValue(),genOutputDescroArg.getValue());
76  }
77  catch(itk::ExceptionObject &e)
78  {
79  std::cerr << e << std::endl;
80  return 1;
81  }
82 
83  delete mainFilter;
84 
85  return 0;
86 }
87 
int main(int argc, char **argv)
std::vector< std::vector< double > > InitializeSampleDirections(unsigned int nbTheta, unsigned int nbPhi, std::string sampleDirFileName)