29 #include <itkImageRegionIterator.h>
33 int main(
int argc,
char *argv[])
37 parser.
setTitle(
"Tumor Invasion Analysis");
59 map<string, us::Any> parsedArgs = parser.
parseArguments(argc, argv);
61 if (parsedArgs.size() == 0)
63 if (parsedArgs.count(
"help") || parsedArgs.count(
"h"))
71 bool useStatsFile =
false;
72 unsigned int forestSize = 250;
73 unsigned int treeDepth = 0;
74 std::string configName =
"";
75 std::string outputFolder =
"";
76 std::string forestFile =
"";
79 std::vector<std::string> trainingIds;
80 std::vector<std::string> testingIds;
81 std::vector<std::string> loadIds;
82 std::string outputFile;
84 std::ofstream experimentFS;
88 if (parsedArgs.count(
"colIds") || parsedArgs.count(
"c"))
90 std::istringstream ss(us::any_cast<string>(parsedArgs[
"colIds"]));
93 while (std::getline(ss, token,
','))
94 trainingIds.push_back(token);
97 if (parsedArgs.count(
"output") || parsedArgs.count(
"o"))
99 outputFolder =
us::any_cast<
string>(parsedArgs[
"output"]);
102 if (parsedArgs.count(
"configName") || parsedArgs.count(
"n"))
104 configName =
us::any_cast<
string>(parsedArgs[
"configName"]);
107 if (parsedArgs.count(
"features") || parsedArgs.count(
"b"))
109 std::istringstream ss(us::any_cast<string>(parsedArgs[
"features"]));
112 while (std::getline(ss, token,
','))
113 features.push_back(token);
116 if (parsedArgs.count(
"treeDepth") || parsedArgs.count(
"d"))
121 if (parsedArgs.count(
"ratio") || parsedArgs.count(
"q"))
126 if (parsedArgs.count(
"forestSize") || parsedArgs.count(
"f"))
128 forestSize =
us::any_cast<
int>(parsedArgs[
"forestSize"]);
131 if (parsedArgs.count(
"stats") || parsedArgs.count(
"s"))
134 experimentFS.open(us::any_cast<string>(parsedArgs[
"stats"]).c_str(), std::ios_base::app);
137 if (parsedArgs.count(
"forest") || parsedArgs.count(
"t"))
142 if (parsedArgs.count(
"testId") || parsedArgs.count(
"t"))
144 std::istringstream ss(us::any_cast<string>(parsedArgs[
"testId"]));
147 while (std::getline(ss, token,
','))
148 testingIds.push_back(token);
151 for (
unsigned int i = 0; i < features.size(); i++)
153 loadIds.push_back(features.at(i));
155 loadIds.push_back(
"GTV");
156 loadIds.push_back(
"BRAINMASK");
157 loadIds.push_back(
"TARGET");
159 if (parsedArgs.count(
"stats") || parsedArgs.count(
"s"))
164 if (parsedArgs.count(
"loadFile") || parsedArgs.count(
"l"))
190 std::cout <<
"Setup Training" << std::endl;
197 std::cout <<
"Start Training" << std::endl;
200 if (forestFile !=
"")
203 std::cout <<
"Start Predict" << std::endl;
206 if (outputFolder !=
"")
208 std::cout <<
"Saving files to " << outputFolder << std::endl;
252 std::ostringstream outStr;
253 stats.
Print(outStr, std::cout,
true);
254 std::cout << std::endl << std::endl << outStr.str() << std::endl;
257 std::cout <<
"dummy" << std::endl;
259 if (outputFolder !=
"")
261 std::cout <<
"Saving files to " << outputFolder << std::endl;
void SamplesWeightingActivated(bool isActive)
SamplesWeightingActivated If activated a weighted mask for the samples is calculated, weighting samples according to their location and ratio.
DataCollection::Pointer LoadCollection(const std::string &xmlFileName)
Build up a mitk::DataCollection from a XML resource.
void ClearDataElementIds()
void SetDataItemNames(std::vector< std::string > itemNames)
void Print(std::ostream &out, std::ostream &sout=std::cout, bool withHeader=false, std::string label="None")
void SaveRandomForest(std::string filename)
SaveRandomForest - Saves a trained random forest.
void SetTestName(std::string name)
void SetVoxel(TDataType value)
void setContributor(std::string contributor)
void SetTestValueToIndexMapper(const ValueToIndexMapper *mapper)
ValueType * any_cast(Any *operand)
void SetGroundTruthValueToIndexMapper(const ValueToIndexMapper *mapper)
std::map< std::string, us::Any > parseArguments(const StringContainerType &arguments, bool *ok=nullptr)
void PrepareResponseSamples(DataCollection *collection)
PrepareResponseSamples.
void SetMaskName(std::string name)
void SetGoldName(std::string name)
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)
void PredictInvasion(DataCollection *collection, std::vector< std::string > modalitiesList)
PredictGrowth - Classify voxels into remaining healthy / turning into tumor.
void SetCollection(DataCollection::Pointer collection)
void SetClassCount(vcl_size_t count)
void setCategory(std::string category)
static bool ExportCollectionToFolder(DataCollection *dataCollection, std::string xmlFile, std::vector< std::string > filter)
ExportCollectionToFolder.
The TumorInvasionAnalysis class - Classifies Tumor progression using RF and predicts on new cases...
void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix)
void LearnProgressionFeatures(DataCollection *collection, std::vector< std::string > modalitiesList, vcl_size_t forestSize=300, vcl_size_t treeDepth=10)
LearnProgressionFeatures.
void SetClassRatio(ScalarType ratio)
SetClassRatio - set ratio of tumor voxels to healthy voxels that is to be used for training...
void AddSubColIds(std::vector< std::string > subColIds)
std::string helpText() const
void setTitle(std::string title)
void setDescription(std::string description)