17 #include <metaCommand.h>
21 #include <boost/lexical_cast.hpp>
30 #define _USE_MATH_DEFINES
38 int main(
int argc,
char* argv[])
43 parser.
setCategory(
"Fiber Tracking and Processing Methods");
45 parser.
setDescription(
"Extract fibers from a tractogram using planar figure ROIs");
55 map<string, us::Any> parsedArgs = parser.
parseArguments(argc, argv);
56 if (parsedArgs.size()==0)
59 string inFib =
us::any_cast<
string>(parsedArgs[
"input"]);
61 string pf1_path =
us::any_cast<
string>(parsedArgs[
"planfirgure1"]);
65 if (parsedArgs.count(
"operation"))
67 operation =
us::any_cast<
string>(parsedArgs[
"operation"]);
68 if (parsedArgs.count(
"planfirgure2") && (operation==
"AND" || operation==
"OR"))
69 pf2_path =
us::any_cast<
string>(parsedArgs[
"planfirgure2"]);
74 typedef itk::Image<unsigned char, 3> ItkUcharImgType;
83 if (input1.IsNotNull())
87 pfcNode->SetData(pfc);
89 set1->push_back(pfcNode);
90 storage->Add(pfcNode);
93 if (!pf2_path.empty())
98 if (operation.empty())
100 result = inputTractogram->ExtractFiberSubset(input1, NULL);
102 else if (operation==
"NOT")
105 storage->Add(input1, set1);
106 result = inputTractogram->ExtractFiberSubset(pfcNode, storage);
108 else if (operation==
"AND" && input2.IsNotNull())
111 storage->Add(input1, set1);
112 storage->Add(input2, set1);
113 result = inputTractogram->ExtractFiberSubset(pfcNode, storage);
115 else if (operation==
"OR" && input2.IsNotNull())
118 storage->Add(input1, set1);
119 storage->Add(input2, set1);
120 result = inputTractogram->ExtractFiberSubset(pfcNode, storage);
124 std::cout <<
"Could not process input:";
125 std::cout << pf1_path;
126 std::cout << pf2_path;
127 std::cout << operation;
134 mitk::CastToItkImage<ItkUcharImgType>(mitkMaskImage, itkMaskImage);
136 if (operation==
"NOT")
137 result = inputTractogram->ExtractFiberSubset(itkMaskImage,
true,
true);
139 result = inputTractogram->ExtractFiberSubset(itkMaskImage,
true,
false);
142 if (result.IsNotNull())
145 std::cout <<
"No valid fiber bundle extracted.";
147 catch (itk::ExceptionObject e)
152 catch (std::exception e)
154 std::cout << e.what();
159 std::cout <<
"ERROR!?!";
itk::SmartPointer< Self > Pointer
void setContributor(std::string contributor)
ValueType * any_cast(Any *operand)
std::map< std::string, us::Any > parseArguments(const StringContainerType &arguments, bool *ok=nullptr)
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.
Base Class for Fiber Bundles;.
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 setTitle(std::string title)
void setDescription(std::string description)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.