2 #include <tclap/CmdLine.h> 8 void eventCallback (itk::Object* caller,
const itk::EventObject& event,
void* clientData)
10 itk::ProcessObject * processObject = (itk::ProcessObject*) caller;
11 std::cout<<
"\033[K\rProgression: "<<(int)(processObject->GetProgress() * 100)<<
"%"<<std::flush;
14 int main(
int argc,
char **argv)
16 TCLAP::CmdLine cmd(
"INRIA / IRISA - VisAGeS/Empenn Team",
' ',ANIMA_VERSION);
18 TCLAP::ValueArg<std::string> refLTArg(
"i",
"input",
"Test Image",
true,
"",
"test image",cmd);
19 TCLAP::ValueArg<std::string> dataLTArg(
"I",
"database",
"Database Image List",
true,
"",
"database image list",cmd);
21 TCLAP::ValueArg<std::string> maskArg(
"m",
"maskname",
"Computation mask",
true,
"",
"computation mask",cmd);
22 TCLAP::ValueArg<std::string> resArg(
"o",
"outputname",
"Z-Score output image",
true,
"",
"Z-Score output image",cmd);
23 TCLAP::ValueArg<std::string> resPValArg(
"O",
"outpvalname",
"P-value output image",
true,
"",
"P-Value output image",cmd);
25 TCLAP::ValueArg<std::string> statTestArg(
"t",
"stat-test",
"Statistical test to use ([fisher],chi)",
false,
"fisher",
"statistical test",cmd);
26 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);
27 TCLAP::ValueArg<unsigned int> numEigenArg(
"E",
"numeigenpca",
"Number of eigenvalues to keep (default: 6)",
false,6,
"Number of PCA eigen values",cmd);
29 TCLAP::ValueArg<unsigned int> nbpArg(
"p",
"numberofthreads",
"Number of threads to run on (default: all cores)",
false,itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads(),
"number of threads",cmd);
35 catch (TCLAP::ArgException& e)
37 std::cerr <<
"Error: " << e.error() <<
"for argument " << e.argId() << std::endl;
41 typedef itk::VectorImage<double,3> LogTensorImageType;
44 itk::CStyleCommand::Pointer callback = itk::CStyleCommand::New();
47 MAZScoreImageFilterType::Pointer mainFilter = MAZScoreImageFilterType::New();
48 mainFilter->SetComputationMask(
anima::readImage < itk::Image <unsigned char, 3> > (maskArg.getValue()));
49 mainFilter->SetNumberOfWorkUnits(nbpArg.getValue());
51 mainFilter->SetInput(anima::readImage <LogTensorImageType> (refLTArg.getValue()));
52 mainFilter->SetExplainedRatio(expVarArg.getValue());
53 mainFilter->SetNumEigenValuesPCA(numEigenArg.getValue());
55 if (statTestArg.getValue() ==
"chi")
56 mainFilter->SetStatisticalTestType(MAZScoreImageFilterType::CHI_SQUARE);
58 mainFilter->SetStatisticalTestType(MAZScoreImageFilterType::FISHER);
60 std::ifstream fileIn(dataLTArg.getValue());
61 if (!fileIn.is_open())
63 std::cerr <<
"Could not open data file (" << dataLTArg.getValue() <<
")" << std::endl;
70 fileIn.getline(tmpStr,2048);
72 if (strcmp(tmpStr,
"") == 0)
75 std::cout <<
"Loading tensor image " << tmpStr <<
"..." << std::endl;
76 mainFilter->AddDatabaseInput(anima::readImage <LogTensorImageType> (tmpStr));
80 mainFilter->AddObserver(itk::ProgressEvent(), callback);
86 catch (itk::ExceptionObject &e)
88 std::cerr << e << std::endl;
92 anima::writeImage < itk::Image <double, 3> > (resArg.getValue(),mainFilter->GetOutput(0));
93 anima::writeImage < itk::Image <double, 3> > (resPValArg.getValue(),mainFilter->GetOutput(1));
void eventCallback(itk::Object *caller, const itk::EventObject &event, void *clientData)
itk::SmartPointer< ImageType > readImage(std::string filename)
int main(int argc, char **argv)
Implements patient to group comparison as in http://dx.doi.org/10.1007/978-3-540-85988-8_116.