| 70 | } |
| 71 | |
| 72 | void mitk::ModelSignalImageGenerator::Generate() |
| 73 | { |
| 74 | SortParameterImages(); |
| 75 | |
| 76 | if(this->m_Mask.IsNotNull()) |
| 77 | { |
| 78 | AccessFixedDimensionByItk(m_Mask, mitk::ModelSignalImageGenerator::DoPrepareMask, 3); |
| 79 | } |
| 80 | else |
| 81 | { |
| 82 | this->m_InternalMask = nullptr; |
| 83 | } |
| 84 | |
| 85 | /** @todo #1 This did not work! The Access-Routine would be a much nicer solution, but for some reasons, the handling did not work. |
| 86 | * Thats why the code for Generation the Data was pasted below |
| 87 | */ |
| 88 | // mitk::Image::Pointer firstParameterImage = this->m_InputParameterImages[0]; |
| 89 | // AccessFixedDimensionByItk(firstParameterImage, mitk::ModelSignalImageGenerator::DoGenerateData, 3); |
| 90 | |
| 91 | |
| 92 | typedef itk::Image<double, 3> InputFrameImageType; |
| 93 | typedef itk::Image<double, 3> OutputImageType; |
| 94 | |
| 95 | typedef itk::MultiOutputNaryFunctorImageFilter<InputFrameImageType, OutputImageType, SimpleFunctorPolicy, InternalMaskType> FilterType; |
| 96 | FilterType::Pointer filter = FilterType::New(); |
| 97 | |
| 98 | for(unsigned int i=0; i<this->m_ParameterInputMap.size(); ++i) |
| 99 | { |
| 100 | InputFrameImageType::Pointer frameImage = InputFrameImageType::New(); |
| 101 | Image::Pointer parameterImage = m_InputParameterImages.at(i); |
| 102 | |
| 103 | mitk::CastToItkImage(parameterImage, frameImage); |
| 104 | filter->SetInput(i,frameImage); |
| 105 | } |
| 106 | |
| 107 | ModelDataGenerationFunctor::Pointer generationFunctor = ModelDataGenerationFunctor::New(); |
| 108 | generationFunctor->SetModelParameterizer(m_Parameterizer); |
| 109 | |
| 110 | SimpleFunctorPolicy functor; |
| 111 | functor.SetFunctor(generationFunctor); |
| 112 | filter->SetFunctor(functor); |
| 113 | if (this->m_InternalMask.IsNotNull()) |
| 114 | { |
| 115 | filter->SetMask(this->m_InternalMask); |
| 116 | } |
| 117 | filter->Update(); |
| 118 | |
| 119 | if (filter->GetNumberOfOutputs() != generationFunctor->GetGrid().GetSize()) |
| 120 | { |
| 121 | itkExceptionMacro("Error. Number of computed output Images does not match Grid size!"); |
| 122 | } |
| 123 | |
| 124 | /** @todo #1 Better solution than all this code! |
| 125 | * This was copied from TestingHelper/TestArtifactGenerator. Just instantiating a mitk::Image and setting its Volumes |
| 126 | * in the for-loop did not work somehow. |
| 127 | * This was a work around |
| 128 | */ |
| 129 | |