27 #include <itksys/SystemTools.hxx> 33 struct InputParameters
35 std::string inputPath;
36 std::string outputPath;
46 parser.
setTitle(
"Mitk Spectral Unmixing App");
48 parser.
setContributor(
"Computer Assisted Medical Interventions, DKFZ");
56 "Input folder (directory)",
63 "Input save folder (directory)",
70 "Number of Input files",
77 InputParameters input;
80 std::map<std::string, us::Any> parsedArgs = parser.
parseArguments(argc, argv);
84 for (
int i = 0; i < argc; ++i)
89 if (parsedArgs.count(
"inputPath"))
91 input.inputPath =
us::any_cast<std::string>(parsedArgs[
"inputPath"]);
99 if (parsedArgs.count(
"outputPath"))
101 input.outputPath =
us::any_cast<std::string>(parsedArgs[
"outputPath"]);
108 if (parsedArgs.count(
"numberOfInputs"))
110 input.numberOfInputs =
us::any_cast<
int>(parsedArgs[
"numberOfInputs"]);
115 mitkThrow() <<
"Error: No number of Inputs";
117 MITK_INFO <<
"Parsing arguments...[Done]";
126 if (algorithm ==
"QR")
130 ->SetAlgorithm(mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::HOUSEHOLDERQR);
133 else if (algorithm ==
"SVD")
137 ->SetAlgorithm(mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::JACOBISVD);
140 else if (algorithm ==
"LU")
144 ->SetAlgorithm(mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::FULLPIVLU);
147 else if (algorithm ==
"NNLS")
151 ->SetAlgorithm(mitk::pa::SpectralUnmixingFilterVigra::VigraAlgortihmType::LARS);
154 else if (algorithm ==
"WLS")
158 ->SetAlgorithm(mitk::pa::SpectralUnmixingFilterVigra::VigraAlgortihmType::WEIGHTED);
168 return spectralUnmixingFilter;
173 std::vector<int> weigthVec = { 30, 32, 33, 35, 37, 38, 40, 41, 43, 44, 45, 46, 47, 47,
174 47, 47, 47, 46, 46, 45, 44, 44, 43, 42, 42, 41 };
176 for (
int i = 0; i < weights; ++i)
179 ->AddWeight(weigthVec[i]);
185 int main(
int argc,
char *argv[])
189 std::string inputDir = input.inputPath;
190 std::string outputDir = input.outputPath;
191 unsigned int N = input.numberOfInputs;
232 std::vector<std::string> algorithms = {
"QR",
"LU",
"SVD",
"NNLS",
"WLS" };
233 int repetition = 6000;
235 for (
unsigned alg = 0; alg < 5; ++alg)
237 ofstream myerrorfile;
238 myerrorfile.open(
"E:/NHDATA/time/time_evaluation_" + std::to_string(repetition)+
"_" + algorithms[alg] +
"_new02.txt");
241 for(
int i = 2; i < 27; ++i)
243 myerrorfile << std::to_string(i) +
"\t";
246 file =
"E:/NHDATA/time/input/time_0" + std::to_string(i) +
".nrrd";
248 file =
"E:/NHDATA/time/input/time_" + std::to_string(i) +
".nrrd";
250 auto m_inputImage = mitk::IOUtil::Load<mitk::Image>(file);
254 for (
int j = 0; j < repetition; ++j)
256 std::chrono::steady_clock::time_point _start;
257 _start = std::chrono::steady_clock::now();
260 m_SpectralUnmixingFilter->SetInput(m_inputImage);
261 m_SpectralUnmixingFilter->AddOutputs(2);
262 m_SpectralUnmixingFilter->Verbose(
false);
263 m_SpectralUnmixingFilter->RelativeError(
false);
264 m_SpectralUnmixingFilter->AddChromophore(mitk::pa::PropertyCalculator::ChromophoreType::OXYGENATED);
265 m_SpectralUnmixingFilter->AddChromophore(mitk::pa::PropertyCalculator::ChromophoreType::DEOXYGENATED);
267 for (
int wl = 0; wl < i; ++wl)
269 m_SpectralUnmixingFilter->AddWavelength(700 + wl * 10);
278 m_SpectralUnmixingFilter->Update();
280 auto output1 = m_SpectralUnmixingFilter->GetOutput(0);
281 auto output2 = m_SpectralUnmixingFilter->GetOutput(1);
283 m_SpectralUnmixingFilter =
nullptr;
285 std::chrono::steady_clock::time_point _end(std::chrono::steady_clock::now());
286 myerrorfile << std::chrono::duration_cast<std::chrono::duration<double>>(_end - _start).count() <<
"\t";
This filter is subclass of the spectral unmixing filter base. All algorithms in this class are based ...
void setContributor(std::string contributor)
ValueType * any_cast(Any *operand)
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, mitkCommandLineParser::Channel channel=mitkCommandLineParser::Channel::None)
std::map< std::string, us::Any > parseArguments(const StringContainerType &arguments, bool *ok=nullptr)
mitk::pa::SpectralUnmixingFilterBase::Pointer GetFilterInstance(std::string algorithm)
This filter is subclass of the spectral unmixing filter base. All algorithms in this class are based ...
InputParameters parseInput(int argc, char *argv[])
int main(int argc, char *argv[])
void setCategory(std::string category)
void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix)
void setTitle(std::string title)
void setDescription(std::string description)
void add_weight(int weights, mitk::pa::SpectralUnmixingFilterBase::Pointer m_SpectralUnmixingFilter)
void beginGroup(const std::string &description)