ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkDiffusionTensor3DReconstructionImageFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkDiffusionTensor3DReconstructionImageFilter_h
19#define itkDiffusionTensor3DReconstructionImageFilter_h
20
22#include "itkSpatialObject.h"
24#include "vnl/vnl_matrix.h"
25#include "vnl/vnl_vector_fixed.h"
26#include "vnl/vnl_matrix_fixed.h"
27#include "itkMathSVD.h"
28#if !defined(ITK_LEGACY_REMOVE) && !defined(ITK_FUTURE_LEGACY_REMOVE)
29# include "vnl/algo/vnl_svd.h" // transitional transitive include; dropped on ITK legacy removal
30#endif
31#include "itkVectorContainer.h"
32#include "itkVectorImage.h"
33#include "ITKDiffusionTensorImageExport.h"
34
35namespace itk
36{
55// Define how to print enumeration
56extern ITKDiffusionTensorImage_EXPORT std::ostream &
58
132
133template <typename TReferenceImagePixelType,
134 typename TGradientImagePixelType = TReferenceImagePixelType,
135 typename TTensorPixelType = double,
136 typename TMaskImageType = Image<unsigned char, 3>>
138 : public ImageToImageFilter<Image<TReferenceImagePixelType, 3>, Image<DiffusionTensor3D<TTensorPixelType>, 3>>
139{
140public:
146
148 itkNewMacro(Self);
149
151 itkOverrideGetNameOfClassMacro(DiffusionTensor3DReconstructionImageFilter);
152
153 using ReferencePixelType = TReferenceImagePixelType;
154
155 using GradientPixelType = TGradientImagePixelType;
156
158
162
164
166
168
171
177
180
182 using MaskImageType = TMaskImageType;
183
185 using TensorBasisMatrixType = vnl_matrix_fixed<double, 6, 6>;
186
187 using CoefficientMatrixType = vnl_matrix<double>;
188
190 using GradientDirectionType = vnl_vector_fixed<double, 3>;
191
194
197 void
199 const GradientImageType *
200 GetGradientImage(unsigned int index) const;
202
209 void
211
213 void
215 {
218 {
219 itkExceptionStringMacro(
220 "Cannot call both methods:AddGradientImage and SetGradientImage. Please call only one of them.");
221 }
222
223 this->ProcessObject::SetNthInput(0, referenceImage);
224
227 }
228
230 virtual ReferenceImageType *
232 {
233 return (static_cast<ReferenceImageType *>(this->ProcessObject::GetInput(0)));
234 }
235
237 [[nodiscard]] virtual GradientDirectionType
238 GetGradientDirection(unsigned int idx) const
239 {
241 {
242 itkExceptionMacro("Gradient direction " << idx << " does not exist");
243 }
244 return m_GradientDirectionContainer->ElementAt(idx);
245 }
246
248 void
250
252 void
254
255
260 itkSetMacro(Threshold, ReferencePixelType);
261 itkGetConstMacro(Threshold, ReferencePixelType);
263
271 itkSetMacro(BValue, TTensorPixelType);
272#ifdef GetBValue
273# undef GetBValue
274#endif
275 itkGetConstReferenceMacro(BValue, TTensorPixelType);
277
278 itkConceptMacro(ReferenceEqualityComparableCheck, (Concept::EqualityComparable<ReferencePixelType>));
279 itkConceptMacro(TensorEqualityComparableCheck, (Concept::EqualityComparable<TensorPixelType>));
280 itkConceptMacro(GradientConvertibleToDoubleCheck, (Concept::Convertible<GradientPixelType, double>));
281 itkConceptMacro(DoubleConvertibleToTensorCheck, (Concept::Convertible<double, TensorPixelType>));
282 itkConceptMacro(GradientReferenceAdditiveOperatorsCheck,
284 itkConceptMacro(GradientReferenceAdditiveAndAssignOperatorsCheck,
286
287 itkConceptMacro(ReferenceOStreamWritableCheck, (Concept::OStreamWritable<ReferencePixelType>));
288 itkConceptMacro(TensorOStreamWritableCheck, (Concept::OStreamWritable<TensorPixelType>));
289
290protected:
293 void
294 PrintSelf(std::ostream & os, Indent indent) const override;
295
296 void
298
299 void
301
302 void
303 DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
304
305 void
306 VerifyPreconditions() const override;
307
310#if !defined(ITK_LEGACY_REMOVE)
311 // We need to expose the enum values at the class level
312 // for backwards compatibility
313 static constexpr GradientImageTypeEnumeration GradientIsInASingleImage =
314 GradientImageTypeEnumeration::GradientIsInASingleImage;
315 static constexpr GradientImageTypeEnumeration GradientIsInManyImages =
316 GradientImageTypeEnumeration::GradientIsInManyImages;
317 static constexpr GradientImageTypeEnumeration Else = GradientImageTypeEnumeration::Else;
318#endif
319
320private:
321 /* Tensor basis coeffs */
323
324 /* Pseudo-inverse of m_TensorBasis (dual tensor basis), precomputed in BeforeThreadedGenerateData. */
325 vnl_matrix<double> m_TensorBasisInverse{};
326
328
331
334
337
340
342 TTensorPixelType m_BValue{};
343
346
349};
350} // namespace itk
351
352#ifndef ITK_MANUAL_INSTANTIATION
353# include "itkDiffusionTensor3DReconstructionImageFilter.hxx"
354#endif
355
356#endif
Contains all enum classes used by DiffusionTensor3DReconstructionImageFilter class.
void SetGradientImage(GradientDirectionContainerType *, const GradientImagesType *gradientImage)
typename OutputImageType::RegionType OutputImageRegionType
void AddGradientImage(const GradientDirectionType &, const GradientImageType *gradientImage)
void VerifyPreconditions() const override
Verifies that the process object has been configured correctly, that all required inputs are set,...
void PrintSelf(std::ostream &os, Indent indent) const override
void SetMaskSpatialObject(MaskSpatialObjectType *maskSpatialObject)
virtual GradientDirectionType GetGradientDirection(unsigned int idx) const
ImageToImageFilter< Image< TReferenceImagePixelType, 3 >, Image< DiffusionTensor3D< TTensorPixelType >, 3 > > Superclass
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
~DiffusionTensor3DReconstructionImageFilter() override=default
void SetMaskImage(MaskImageType *maskImage)
DiffusionTensor3DReconstructionImageFilterEnums::GradientImageFormat GradientImageTypeEnumeration
const GradientImageType * GetGradientImage(unsigned int index) const
VectorContainer< unsigned int, GradientDirectionType > GradientDirectionContainerType
Represent a diffusion tensor as used in DTI images.
Templated n-dimensional image class.
Definition itkImage.h:89
Control indentation during Print() invocation.
Definition itkIndent.h:51
virtual void SetNthInput(DataObjectPointerArraySizeType idx, DataObject *input)
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
Implements transparent reference counting.
Implementation of the composite pattern.
Templated n-dimensional vector image class.
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
detail::VectorContainer< std::conditional_t< std::is_void_v< T2 >, SizeValueType, T1 >, std::conditional_t< std::is_void_v< T2 >, T1, T2 > > VectorContainer
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, AnatomicalOrientation::CoordinateEnum value)