2 #include <tclap/CmdLine.h> 10 void eventCallback (itk::Object* caller,
const itk::EventObject& event,
void* clientData)
12 itk::ProcessObject * processObject = (itk::ProcessObject*) caller;
13 std::cout<<
"\033[K\rProgression: "<<(int)(processObject->GetProgress() * 100)<<
"%"<<std::flush;
16 int main(
int argc,
char **argv)
18 TCLAP::CmdLine cmd(
"INRIA / IRISA - VisAGeS/Empenn Team",
' ',ANIMA_VERSION);
20 TCLAP::ValueArg<std::string> refODFArg(
"i",
"inputodf",
"ODF Test Image",
true,
"",
"ODF test image",cmd);
22 TCLAP::ValueArg<std::string> dataODFArg(
"I",
"databaseodf",
"ODF Database Image List",
true,
"",
"ODF database image list",cmd);
24 TCLAP::ValueArg<std::string> maskArg(
"m",
"maskname",
"Computation mask",
true,
"",
"computation mask",cmd);
25 TCLAP::ValueArg<std::string> resArg(
"o",
"outputname",
"Z-Score output image",
true,
"",
"Z-Score output image",cmd);
26 TCLAP::ValueArg<std::string> resPValArg(
"O",
"outpvalname",
"P-value output image",
true,
"",
"P-Value output image",cmd);
28 TCLAP::ValueArg<std::string> statTestArg(
"t",
"stat-test",
"Statistical test to use ([fisher],chi)",
false,
"fisher",
"statistical test",cmd);
29 TCLAP::ValueArg<double> expVarArg(
"e",
"expvar",
"PCA threshold: threshold on eigenvalues to compute the new basis (default: 0.5)",
false,0.5,
"PCA threshold",cmd);
30 TCLAP::ValueArg<unsigned int> numEigenArg(
"E",
"numeigenpca",
"Number of eigenvalues to keep (default: 6)",
false,6,
"Number of PCA eigen values",cmd);
32 TCLAP::ValueArg<unsigned int> nbpArg(
"p",
"numberofthreads",
"Number of threads to run on (default: all cores)",
false,itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads(),
"number of threads",cmd);
34 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);
35 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);
37 TCLAP::ValueArg<std::string> samplesFileNameArg(
"d",
"sampledirectionsfile",
"Samples directions in a text file",
false,
"",
"Samples directions file",cmd);
43 catch (TCLAP::ArgException& e)
45 std::cerr <<
"Error: " << e.error() <<
"for argument " << e.argId() << std::endl;
49 typedef itk::VectorImage<double,3> ODFImageType;
52 itk::CStyleCommand::Pointer callback = itk::CStyleCommand::New();
55 MAOZScoreImageFilterType::Pointer mainFilter = MAOZScoreImageFilterType::New();
56 mainFilter->SetComputationMask(
anima::readImage < itk::Image <unsigned char,3> > (maskArg.getValue()));
57 mainFilter->SetNumberOfWorkUnits(nbpArg.getValue());
59 mainFilter->SetInput(anima::readImage <ODFImageType> (refODFArg.getValue()));
60 mainFilter->SetExplainedRatio(expVarArg.getValue());
61 mainFilter->SetNumEigenValuesPCA(numEigenArg.getValue());
64 samplesFileNameArg.getValue());
66 mainFilter->SetSampleDirections(sampleDirections);
68 if (statTestArg.getValue() ==
"chi")
69 mainFilter->SetStatisticalTestType(MAOZScoreImageFilterType::CHI_SQUARE);
71 mainFilter->SetStatisticalTestType(MAOZScoreImageFilterType::FISHER);
73 std::ifstream fileIn(dataODFArg.getValue());
74 if (!fileIn.is_open())
76 std::cerr <<
"Could not open ODF data file (" << dataODFArg.getValue() <<
")" << std::endl;
83 fileIn.getline(tmpStr,2048);
85 if (strcmp(tmpStr,
"") == 0)
88 std::cout <<
"Loading ODF image " << tmpStr <<
"..." << std::endl;
89 mainFilter->AddDatabaseInput(anima::readImage <ODFImageType> (tmpStr));
93 mainFilter->AddObserver(itk::ProgressEvent(), callback);
99 catch(itk::ExceptionObject &e)
101 std::cerr << e << std::endl;
105 anima::writeImage < itk::Image <double, 3> > (resArg.getValue(),mainFilter->GetOutput(0));
106 anima::writeImage < itk::Image <double, 3> > (resPValArg.getValue(),mainFilter->GetOutput(1));
int main(int argc, char **argv)
void eventCallback(itk::Object *caller, const itk::EventObject &event, void *clientData)
std::vector< std::vector< double > > InitializeSampleDirections(unsigned int nbTheta, unsigned int nbPhi, std::string sampleDirFileName)
itk::SmartPointer< ImageType > readImage(std::string filename)