3 #include <itkTimeProbe.h> 5 #include <tclap/CmdLine.h> 10 #include <itkCommand.h> 15 void eventCallback (itk::Object* caller,
const itk::EventObject& event,
void* clientData)
17 itk::ProcessObject * processObject = (itk::ProcessObject*) caller;
18 std::cout<<
"\033[K\rProgression: "<<(int)(processObject->GetProgress() * 100)<<
"%"<<std::flush;
21 int main(
int argc,
char* argv[])
23 TCLAP::CmdLine cmd(
"INRIA / IRISA - VisAGeS/Empenn Team",
' ',ANIMA_VERSION);
26 TCLAP::ValueArg<std::string> odfArg(
"i",
"odf",
"Input diffusion tensor image",
true,
"",
"dti image",cmd);
27 TCLAP::ValueArg<std::string> seedMaskArg(
"s",
"seed-mask",
"Seed mask",
true,
"",
"seed",cmd);
28 TCLAP::ValueArg<std::string> fibersArg(
"o",
"fibers",
"Output fibers",
true,
"",
"fibers",cmd);
29 TCLAP::ValueArg<std::string> b0Arg(
"b",
"b0",
"B0 image",
true,
"",
"b0 image",cmd);
30 TCLAP::ValueArg<std::string> noiseArg(
"N",
"noise",
"Noise image",
true,
"",
"noise image",cmd);
32 TCLAP::ValueArg<int> colinearityModeArg(
"",
"col-init-mode",
33 "Colinearity mode for initialization - 0: center, 1: outward, 2: top, 3: bottom, 4: left, 5: right, 6: front, 7: back (default: 0)",
34 false,0,
"colinearity mode for initialization",cmd);
35 TCLAP::ValueArg<int> initialDirectionModeArg(
"",
"init-mode",
36 "Mode for initialization - 0: take most colinear direction, 1: take highest weighted direction (default: 1)",
37 false,1,
"mode for initialization",cmd);
40 TCLAP::ValueArg<std::string> cutMaskArg(
"c",
"cut-mask",
"Mask for cutting fibers (default: none)",
false,
"",
"cut mask",cmd);
41 TCLAP::ValueArg<std::string> forbiddenMaskArg(
"f",
"forbidden-mask",
"Mask for removing fibers (default: none)",
false,
"",
"remove mask",cmd);
42 TCLAP::ValueArg<std::string> filterMaskArg(
"",
"filter-mask",
"Mask for filtering fibers (default: none)",
false,
"",
"filter mask",cmd);
44 TCLAP::ValueArg<double> gfaThrArg(
"",
"gfa-thr",
"GFA threshold (default: 0.2)",
false,0.2,
"GFA threshold",cmd);
45 TCLAP::ValueArg<double> stepLengthArg(
"",
"step-length",
"Length of each step (default: 1)",
false,1.0,
"step length",cmd);
46 TCLAP::ValueArg<int> nbFibersArg(
"",
"nb-fibers",
"Number of starting particle filters (n*n*n) per voxel (default: 1)",
false,1,
"number of seeds per voxel",cmd);
48 TCLAP::ValueArg<double> minLengthArg(
"",
"min-length",
"Minimum length for a fiber to be considered for computation (default: 10mm)",
false,10.0,
"minimum length",cmd);
49 TCLAP::ValueArg<double> maxLengthArg(
"",
"max-length",
"Maximum length of a tract (default: 150mm)",
false,150.0,
"maximum length",cmd);
51 TCLAP::ValueArg<unsigned int> nbParticlesArg(
"n",
"nb-particles",
"Number of particles per filter (default: 1000)",
false,1000,
"number of particles",cmd);
52 TCLAP::ValueArg<unsigned int> clusterMinSizeArg(
"",
"cluster-min-size",
"Minimal number of particles per cluster before split (default: 10)",
false,10,
"minimal cluster size",cmd);
54 TCLAP::ValueArg<double> resampThrArg(
"r",
"resamp-thr",
"Resampling relative threshold (default: 0.8)",
false,0.8,
"resampling threshold",cmd);
56 TCLAP::ValueArg<double> minDiffProbaArg(
"",
"mdp",
"Minimal diffusion probability for an ODF direction to be kept (default: 0.02",
false,0.01,
"Minimal diffusion probability for an ODF direction",cmd);
57 TCLAP::ValueArg<double> trashThrArg(
"",
"trash-thr",
"Relative threshold to keep fibers in trash (default: 0.1)",
false,0.1,
"trash threshold",cmd);
58 TCLAP::ValueArg<double> kappaPriorArg(
"k",
"kappa-prior",
"Kappa of prior distribution (default: 15)",
false,15.0,
"prior kappa",cmd);
59 TCLAP::ValueArg<double> curvScaleArg(
"",
"cs",
"Scale for ODF curvature to get vMF kappa (default: 6)",
false,6.0,
"scale for ODF curvature",cmd);
61 TCLAP::ValueArg<double> distThrArg(
"",
"dist-thr",
"Hausdorff distance threshold for mergine clusters (default: 0.5)",
false,0.5,
"merging threshold",cmd);
62 TCLAP::ValueArg<double> kappaThrArg(
"",
"kappa-thr",
"Kappa threshold for splitting clusters (default: 30)",
false,30.0,
"splitting threshold",cmd);
64 TCLAP::ValueArg<unsigned int> clusterDistArg(
"",
"cluster-dist",
"Distance between clusters: choices are 0 (AHD), 1 (HD, default) or 2 (MHD)",
false,1,
"cluster distance",cmd);
66 TCLAP::SwitchArg averageClustersArg(
"M",
"average-clusters",
"Output only cluster mean",cmd,
false);
67 TCLAP::SwitchArg addLocalDataArg(
"L",
"local-data",
"Add local data information to output tracks",cmd);
69 TCLAP::ValueArg<unsigned int> nbThreadsArg(
"T",
"nb-threads",
"Number of threads to run on (default: all available)",
false,itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads(),
"number of threads",cmd);
75 catch (TCLAP::ArgException& e)
77 std::cerr <<
"Error: " << e.error() <<
"for argument " << e.argId() << std::endl;
82 typedef MainFilterType::InputModelImageType InputModelImageType;
83 typedef MainFilterType::MaskImageType MaskImageType;
84 typedef MainFilterType::Vector3DType Vector3DType;
86 MainFilterType::Pointer odfTracker = MainFilterType::New();
88 odfTracker->SetNumberOfWorkUnits(nbThreadsArg.getValue());
89 odfTracker->SetInputModelImage(anima::readImage <InputModelImageType> (odfArg.getValue()));
91 odfTracker->SetInitialColinearityDirection((MainFilterType::ColinearityDirectionType)colinearityModeArg.getValue());
92 odfTracker->SetInitialDirectionMode((MainFilterType::InitialDirectionModeType)initialDirectionModeArg.getValue());
95 odfTracker->SetSeedMask(anima::readImage <MaskImageType> (seedMaskArg.getValue()));
98 if (cutMaskArg.getValue() !=
"")
99 odfTracker->SetCutMask(anima::readImage <MaskImageType> (cutMaskArg.getValue()));
102 if (forbiddenMaskArg.getValue() !=
"")
103 odfTracker->SetForbiddenMask(anima::readImage <MaskImageType> (forbiddenMaskArg.getValue()));
106 if (filterMaskArg.getValue() !=
"")
107 odfTracker->SetFilterMask(anima::readImage <MaskImageType> (filterMaskArg.getValue()));
109 typedef MainFilterType::ScalarImageType ScalarImageType;
110 odfTracker->SetB0Image(anima::readImage <ScalarImageType> (b0Arg.getValue()));
111 odfTracker->SetNoiseImage(anima::readImage <ScalarImageType> (noiseArg.getValue()));
113 odfTracker->SetNumberOfFibersPerPixel(nbFibersArg.getValue());
114 odfTracker->SetStepProgression(stepLengthArg.getValue());
115 odfTracker->SetGFAThreshold(gfaThrArg.getValue());
116 odfTracker->SetMinLengthFiber(minLengthArg.getValue());
117 odfTracker->SetMaxLengthFiber(maxLengthArg.getValue());
119 odfTracker->SetNumberOfParticles(nbParticlesArg.getValue());
120 odfTracker->SetMinimalNumberOfParticlesPerClass(clusterMinSizeArg.getValue());
121 odfTracker->SetResamplingThreshold(resampThrArg.getValue());
122 odfTracker->SetFiberTrashThreshold(trashThrArg.getValue());
124 odfTracker->SetMinimalDiffusionProbability(minDiffProbaArg.getValue());
125 odfTracker->SetKappaOfPriorDistribution(kappaPriorArg.getValue());
127 odfTracker->SetPositionDistanceFuseThreshold(distThrArg.getValue());
128 odfTracker->SetKappaSplitThreshold(kappaThrArg.getValue());
129 odfTracker->SetClusterDistance(clusterDistArg.getValue());
130 odfTracker->SetCurvatureScale(curvScaleArg.getValue());
132 bool computeLocalColors = (fibersArg.getValue().find(
".fds") != std::string::npos) && (addLocalDataArg.isSet());
133 odfTracker->SetComputeLocalColors(computeLocalColors);
134 odfTracker->SetMAPMergeFibers(averageClustersArg.getValue());
136 itk::CStyleCommand::Pointer callback = itk::CStyleCommand::New();
138 odfTracker->AddObserver(itk::ProgressEvent(), callback);
140 itk::TimeProbe tmpTime;
143 odfTracker->Update();
144 odfTracker->RemoveAllObservers();
147 std::cout <<
"Tracking time: " << tmpTime.GetTotal() <<
"s" << std::endl;
void SetInputData(vtkPolyData *data)
int main(int argc, char *argv[])
void eventCallback(itk::Object *caller, const itk::EventObject &event, void *clientData)
void SetFileName(std::string &name)