Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkGroupDiffusionHeadersFilter.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 
19 
20 
22 {
23  // Modify superclass default values, may be overridden by subclasses
24  this->SetNumberOfRequiredInputs( 1 );
25  this->SetNumberOfRequiredOutputs( 4 );
26 }
27 
28 
30 {}
31 
33 {
34 }
35 
37 {
38  InputType input = static_cast<InputType>( this->GetInput( ) );
39  this->SetNthOutput(0, input);
40 
41  InputType dwi;
42  InputType zerodwi;
43  InputType other;
44 
45  bool foundDWI = false;
46 
47  // check each series' first image
48  unsigned int size = input.size();
49  HeaderPointer header;
50  HeaderPointer dwiHeader;
51  for ( unsigned int i = 0 ; i < size ; ++i )
52  {
53  header = input[i];
54 
55  // list of files
56  if( header->bValue > 0)
57  {
58  header->headerGroup = DHG_NonZeroDiffusionWeighted;
59  if(!foundDWI)
60  dwiHeader = header;
61  foundDWI = true;
62  }
63  else
64  {
65  header->headerGroup = DHG_ZeroDiffusionWeighted;
66  }
67  }
68 
69  if(foundDWI)
70  {
71  for ( unsigned int i = 0 ; i < size ; ++i )
72  {
73  header = input[i];
74 
75  // list of files
76  if( !header->isIdentical(dwiHeader))
77  {
78  header->headerGroup = DHG_Other;
79  }
80  }
81  }
82  else
83  {
84  for ( unsigned int i = 0 ; i < size ; ++i )
85  {
86  header = input[i];
87  header->headerGroup = DHG_Other;
88  }
89  }
90 
91  for ( unsigned int i = 0 ; i < size ; ++i )
92  {
93  header = input[i];
94 
95  switch (header->headerGroup)
96  {
97  case DHG_Other:
98  other.push_back(header);
99  break;
101  zerodwi.push_back(header);
102  break;
104  dwi.push_back(header);
105  break;
106  case DHG_NotYetGrouped:
107  break;
108  }
109  }
110 
111  this->SetNthOutput(1, dwi);
112  this->SetNthOutput(2, zerodwi);
113  this->SetNthOutput(3, other);
114 
115 }
116 
118 {
119  // Process object is not const-correct so the const_cast is required here
120  m_Input = input;
121 }
122 
123 
125 {
126  this->SetInput( input );
127 }
128 
129 
131 {
132  return m_Input;
133 }
134 
135 
137 {
138  return this->GetInput();
139 }
140 
143 {
144  return m_Output;
145 }
146 
147 void mitk::GroupDiffusionHeadersFilter::SetNthOutput( const unsigned int& idx, InputType output )
148 {
149  if(idx >= m_Output.size())
150  m_Output.resize(idx+1);
151  m_Output[idx] = output;
152 }
153 
154 void mitk::GroupDiffusionHeadersFilter::operator=( const mitk::GroupDiffusionHeadersFilter::Self& )
155 {}
156 
157 
Superclass of all classes generating some kind of mitk::BaseData.
virtual void SetNthOutput(const unsigned int &idx, InputType output)