| 278 | } |
| 279 | |
| 280 | void doDumping() |
| 281 | { |
| 282 | if (mask.IsNotNull() && mask->GetTimeSteps() > 1) |
| 283 | { |
| 284 | std::cout << |
| 285 | "Pixel Dumper: Selected mask has multiple timesteps. Only use first timestep to mask the pixel dumping." << std::endl; |
| 286 | |
| 287 | mitk::ImageTimeSelector::Pointer maskTimeSelector = mitk::ImageTimeSelector::New(); |
| 288 | maskTimeSelector->SetInput(mask); |
| 289 | maskTimeSelector->SetTimeNr(0); |
| 290 | maskTimeSelector->UpdateLargestPossibleRegion(); |
| 291 | mask = maskTimeSelector->GetOutput(); |
| 292 | } |
| 293 | |
| 294 | try |
| 295 | { |
| 296 | if (mask.IsNotNull()) |
| 297 | { // if mask exist, we use the mask because it could be a sub region. |
| 298 | AccessFixedDimensionByItk(mask, ExtractRelevantInformation, 3); |
| 299 | } |
| 300 | else |
| 301 | { |
| 302 | AccessFixedDimensionByItk(images.front(), ExtractRelevantInformation, 3); |
| 303 | } |
| 304 | } |
| 305 | catch (const std::exception& e) |
| 306 | { |
| 307 | std::cerr << "Error extracting image geometry. Error text: " << e.what(); |
| 308 | throw; |
| 309 | } |
| 310 | |
| 311 | |
| 312 | for (unsigned int index = 0; index < images.size(); ++index) |
| 313 | { |
| 314 | try |
| 315 | { |
| 316 | InternalImageMapType conversionMap = ConvertImageTimeSteps(images[index]); |
| 317 | |
| 318 | if (conversionMap.size() == 1) |
| 319 | { |
| 320 | internalImages.insert(std::make_pair(captions[index], conversionMap.begin()->second)); |
| 321 | } |
| 322 | else if (conversionMap.size() > 1) |
| 323 | { |
| 324 | for (auto& pos : conversionMap) |
| 325 | { |
| 326 | std::stringstream namestream; |
| 327 | namestream << captions[index] << " " << pos.first; |
| 328 | internalImages.insert(std::make_pair(namestream.str(), pos.second)); |
| 329 | } |
| 330 | } |
| 331 | } |
| 332 | catch (const std::exception& e) |
| 333 | { |
| 334 | std::stringstream errorStr; |
| 335 | errorStr << "Inconsistent image \"" << captions[index] << "\" will be excluded from the collection. Error: " << e.what(); |
| 336 | std::cerr << errorStr.str() << std::endl; |
| 337 | } |