2 #include <itkTimeProbe.h> 3 #include <tclap/CmdLine.h> 8 int main(
int argc,
char **argv)
10 TCLAP::CmdLine cmd(
"INRIA / IRISA - VisAGeS/Empenn Team",
' ',ANIMA_VERSION);
12 TCLAP::ValueArg<std::string> inArg(
"i",
"input",
"List of diffusion weighted images or 4D volume",
true,
"",
"input diffusion images",cmd);
13 TCLAP::ValueArg<std::string> resArg(
"o",
"outputfile",
"Result ODF image",
true,
"",
"result ODF image",cmd);
15 TCLAP::ValueArg<std::string> gradArg(
"g",
"gradientlist",
"List of gradients (text file)",
true,
"",
"list of gradients",cmd);
16 TCLAP::ValueArg<std::string> bvalArg(
"b",
"bval",
"input b-values (for checking single shell)",
true,
"",
"Input b-values",cmd);
17 TCLAP::ValueArg<std::string> refB0Arg(
"r",
"ref-b0",
"Externally estimated B0 (otherwise mean of B0s is used)",
false,
"",
"External B0 image",cmd);
18 TCLAP::SwitchArg bvalueScaleArg(
"B",
"b-no-scale",
"Do not scale b-values according to gradient norm",cmd);
19 TCLAP::ValueArg <int> selectedBvalArg(
"v",
"select-bval",
"B-value shell used to estimate ODFs (default: first one in data volume above 10)",
false,-1,
"b-value shell selection",cmd);
21 TCLAP::ValueArg<double> lambdaArg(
"l",
"lambda",
"Lambda regularization parameter (see Descoteaux MRM 2007)",
false,0.006,
"lambda for regularization",cmd);
22 TCLAP::ValueArg<unsigned int> orderArg(
"k",
"order",
"Order of spherical harmonics basis",
false,4,
"Order of SH basis",cmd);
24 TCLAP::ValueArg<double> sharpFactorArg(
"s",
"sharpenratio",
"Ratio for sharpening ODFs (see Descoteaux TMI 2009, default : 0.255)",
false,0.255,
"sharpening ratio",cmd);
25 TCLAP::SwitchArg sharpenArg(
"S",
"sharpenodf",
"Sharpen ODF ? (default: no)",cmd,
false);
27 TCLAP::ValueArg<std::string> normSphereArg(
"n",
"normalizefile",
"Sphere tesselation for normalization",
false,
"",
"Normalization sphere file",cmd);
28 TCLAP::SwitchArg normalizeArg(
"N",
"normalize",
"Normalize ODF ? (default: no)",cmd,
false);
30 TCLAP::SwitchArg radialArg(
"R",
"radialestimation",
"Use radial estimation (see Aganj et al) ? (default: no)",cmd,
false);
31 TCLAP::ValueArg<double> aganjRegFactorArg(
"d",
"adr",
"Delta threshold for signal regularization, only use if R option activated (see Aganj et al, default : 0.001)",
false,0.001,
"delta signal regularization",cmd);
33 TCLAP::ValueArg<unsigned int> nbpArg(
"p",
"numberofthreads",
"Number of threads to run on (default: all cores)",
false,itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads(),
"number of threads",cmd);
39 catch (TCLAP::ArgException& e)
41 std::cerr <<
"Error: " << e.error() <<
"for argument " << e.argId() << std::endl;
46 typedef MainFilterType::TInputImage InputImageType;
48 MainFilterType::Pointer mainFilter = MainFilterType::New();
49 mainFilter->SetLambda(lambdaArg.getValue());
50 if (orderArg.getValue() % 2 == 0)
51 mainFilter->SetLOrder(orderArg.getValue());
53 mainFilter->SetLOrder(orderArg.getValue() - 1);
55 mainFilter->SetSharpen(sharpenArg.isSet());
56 if (sharpenArg.isSet())
57 mainFilter->SetSharpnessRatio(sharpFactorArg.getValue());
59 mainFilter->SetUseAganjEstimation(radialArg.isSet());
60 mainFilter->SetDeltaAganjRegularization(aganjRegFactorArg.getValue());
62 mainFilter->SetNormalize(normalizeArg.isSet());
63 if (normalizeArg.isSet())
64 mainFilter->SetFileNameSphereTesselation(normSphereArg.getValue());
66 anima::setMultipleImageFilterInputsFromFileName<InputImageType,MainFilterType>(inArg.getValue(), mainFilter);
68 if (refB0Arg.getValue() !=
"")
69 mainFilter->SetReferenceB0Image(anima::readImage <InputImageType> (refB0Arg.getValue()));
72 GFReaderType gfReader;
74 gfReader.SetBValueBaseString(bvalArg.getValue());
75 gfReader.SetGradientIndependentNormalization(bvalueScaleArg.isSet());
76 gfReader.SetB0ValueThreshold(10);
80 GFReaderType::GradientVectorType directions = gfReader.GetGradients();
81 GFReaderType::BValueVectorType mb = gfReader.GetBValues();
83 for(
unsigned int i = 0;i < directions.size();++i)
84 mainFilter->AddGradientDirection(i,directions[i]);
86 mainFilter->SetBValuesList(mb);
87 mainFilter->SetBValueShellSelected(selectedBvalArg.getValue());
89 itk::TimeProbe tmpTime;
92 mainFilter->SetNumberOfWorkUnits(nbpArg.getValue());
97 std::cout <<
"Execution Time: " << tmpTime.GetTotal() << std::endl;
99 anima::writeImage <MainFilterType::TOutputImage> (resArg.getValue(),mainFilter->GetOutput());
int main(int argc, char **argv)
void SetGradientFileName(std::string fName)