20 #include <metaCommand.h>
23 #include <itkImageFileWriter.h>
27 #include <itksys/SystemTools.hxx>
34 #define _USE_MATH_DEFINES
45 int main(
int argc,
char* argv[])
49 parser.
setTitle(
"Machine Learning Based Streamline Tractography");
50 parser.
setCategory(
"Fiber Tracking and Processing Methods");
51 parser.
setDescription(
"Perform machine learning based streamline tractography");
68 map<string, us::Any> parsedArgs = parser.
parseArguments(argc, argv);
69 if (parsedArgs.size()==0)
72 string imageFile =
us::any_cast<
string>(parsedArgs[
"image"]);
73 string forestFile =
us::any_cast<
string>(parsedArgs[
"forest"]);
74 string outFile =
us::any_cast<
string>(parsedArgs[
"out"]);
77 if (parsedArgs.count(
"mask"))
78 maskFile = us::any_cast<string>(parsedArgs[
"mask"]);
81 if (parsedArgs.count(
"seed"))
82 seedFile = us::any_cast<string>(parsedArgs[
"seed"]);
85 if (parsedArgs.count(
"stop"))
86 stopFile = us::any_cast<string>(parsedArgs[
"stop"]);
89 if (parsedArgs.count(
"stepsize"))
90 stepsize = us::any_cast<float>(parsedArgs[
"stepsize"]);
92 float samplingdist = 0.25;
93 if (parsedArgs.count(
"samplingdist"))
94 samplingdist = us::any_cast<float>(parsedArgs[
"samplingdist"]);
97 if (parsedArgs.count(
"samples"))
98 samples = us::any_cast<int>(parsedArgs[
"samples"]);
101 if (parsedArgs.count(
"seeds"))
102 seeds = us::any_cast<int>(parsedArgs[
"seeds"]);
104 typedef itk::Image<unsigned char, 3> ItkUcharImgType;
106 MITK_INFO <<
"loading diffusion-weighted image";
110 if (!maskFile.empty())
119 if (!seedFile.empty())
128 if (!stopFile.empty())
143 tracker->SetMaskImage(mask);
144 tracker->SetSeedImage(seed);
145 tracker->SetStoppingRegions(stop);
146 tracker->SetSeedsPerVoxel(seeds);
147 tracker->SetStepSize(stepsize);
148 tracker->SetForestHandler(tfh);
149 tracker->SetSamplingDistance(samplingdist);
150 tracker->SetNumberOfSamples(samples);
152 tracker->SetAposterioriCurvCheck(
false);
153 tracker->SetRemoveWmEndFibers(
false);
155 vtkSmartPointer< vtkPolyData > poly = tracker->GetFiberPolyData();
static void Save(const mitk::BaseData *data, const std::string &path)
Save a mitk::BaseData instance.
itk::SmartPointer< Self > Pointer
void setContributor(std::string contributor)
ValueType * any_cast(Any *operand)
Performes deterministic streamline tracking on the input tensor image.
std::map< std::string, us::Any > parseArguments(const StringContainerType &arguments, bool *ok=nullptr)
void LoadForest(std::string forestFile)
Manages random forests for fiber tractography. The preparation of the features from the inputa data a...
static ImageType::Pointer GetItkVectorImage(Image *image)
void addArgument(const std::string &longarg, const std::string &shortarg, Type type, const std::string &argLabel, const std::string &argHelp=std::string(), const us::Any &defaultValue=us::Any(), bool optional=true, bool ignoreRest=false, bool deprecated=false)
int main(int argc, char *argv[])
Perform machine learning based streamline tractography.
Image class for storing images.
itk::Image< itk::Vector< float, numOdfSamples >, 3 > SampledShImageType
void setCategory(std::string category)
void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix)
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
void AddRawData(Image::Pointer img)
void setTitle(std::string title)
void setDescription(std::string description)
static mitk::Image::Pointer LoadImage(const std::string &path)
LoadImage Convenience method to load an arbitrary mitkImage.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.