22 #include <itkDiffusionTensor3D.h>
31 int main(
int argc,
char* argv[])
42 parser.
addArgument(
"tendf",
"f",
mitkCommandLineParser::Float,
"Weight f",
"Weighting factor between first eigenvector (f=1 equals FACT tracking) and input vector dependent direction (f=0).", 1.0,
true);
50 parser.
setCategory(
"Fiber Tracking and Processing Methods");
51 parser.
setTitle(
"Streamline Tracking");
52 parser.
setDescription(
"Deterministic tensor-based streamline tractography or TEND tractography (multi tensor possible)");
55 map<string, us::Any> parsedArgs = parser.
parseArguments(argc, argv);
56 if (parsedArgs.size()==0)
61 string outFileName =
us::any_cast<
string>(parsedArgs[
"outFile"]);
70 bool interpolate =
false;
72 if (parsedArgs.count(
"minCurv"))
73 minCurv = us::any_cast<float>(parsedArgs[
"minCurv"]);
74 if (parsedArgs.count(
"minFA"))
75 minFA = us::any_cast<float>(parsedArgs[
"minFA"]);
76 if (parsedArgs.count(
"stepSize"))
77 stepSize = us::any_cast<float>(parsedArgs[
"stepSize"]);
78 if (parsedArgs.count(
"tendf"))
79 tendf = us::any_cast<float>(parsedArgs[
"tendf"]);
80 if (parsedArgs.count(
"tendg"))
81 tendg = us::any_cast<float>(parsedArgs[
"tendg"]);
82 if (parsedArgs.count(
"minLength"))
83 minLength = us::any_cast<float>(parsedArgs[
"minLength"]);
84 if (parsedArgs.count(
"numSeeds"))
85 numSeeds = us::any_cast<int>(parsedArgs[
"numSeeds"]);
88 if (parsedArgs.count(
"interpolate"))
89 interpolate = us::any_cast<bool>(parsedArgs[
"interpolate"]);
100 std::cout <<
"Loading tensor images ...";
101 typedef itk::Image< itk::DiffusionTensor3D<float>, 3 >
ItkTensorImage;
102 dtiFileName = inputImages.at(0);
103 for (
unsigned int i=0; i<inputImages.size(); i++)
111 filter->SetInput(i, itk_dti);
113 catch(...){ std::cout <<
"could not load: " << inputImages.at(i); }
116 std::cout <<
"Loading seed image ...";
117 typedef itk::Image< unsigned char, 3 > ItkUCharImageType;
119 if (parsedArgs.count(
"seed"))
122 std::cout <<
"Loading mask image ...";
124 if (parsedArgs.count(
"mask"))
128 filter->SetSeedsPerVoxel(numSeeds);
129 filter->SetFaThreshold(minFA);
130 filter->SetMinCurvatureRadius(minCurv);
131 filter->SetStepSize(stepSize);
134 filter->SetInterpolate(interpolate);
135 filter->SetMinTractLength(minLength);
137 if (mitkSeedImage.IsNotNull())
141 filter->SetSeedImage(mask);
144 if (mitkMaskImage.IsNotNull())
148 filter->SetMaskImage(mask);
153 vtkSmartPointer<vtkPolyData> fiberBundle = filter->GetFiberPolyData();
154 if ( fiberBundle->GetNumberOfLines()==0 )
156 std::cout <<
"No fibers reconstructed. Check parametrization.";
160 fib->SetReferenceGeometry(mitkImage->GetGeometry());
165 catch (itk::ExceptionObject e)
170 catch (std::exception e)
172 std::cout << e.what();
177 std::cout <<
"ERROR!?!";
itk::SmartPointer< Self > Pointer
Performes deterministic streamline tracking on the input tensor image.
int main(int argc, char *argv[])
Deterministic tensor-based streamline tractography or TEND tractography (multi tensor possible) ...
void setContributor(std::string contributor)
ValueType * any_cast(Any *operand)
std::map< std::string, us::Any > parseArguments(const StringContainerType &arguments, bool *ok=nullptr)
T::Pointer GetData(const std::string &name)
static bool SaveBaseData(mitk::BaseData *data, const std::string &path)
SaveBaseData Convenience method to save arbitrary baseData.
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)
Image class for storing images.
void setCategory(std::string category)
static mitk::DataNode::Pointer LoadDataNode(const std::string &path)
LoadDataNode Method to load an arbitrary DataNode.
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.
this class encapsulates tensor images
std::vector< std::string > StringContainerType
itk::Image< itk::DiffusionTensor3D< float >, 3 > ItkTensorImage
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.