Developer documentation
Version 3.0.3-105-gd3941f44
masked.h
Go to the documentation of this file.
1/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * Covered Software is provided under this License on an "as is"
8 * basis, without warranty of any kind, either expressed, implied, or
9 * statutory, including, without limitation, warranties that the
10 * Covered Software is free of defects, merchantable, fit for a
11 * particular purpose or non-infringing.
12 * See the Mozilla Public License v. 2.0 for more details.
13 *
14 * For more details, see http://www.mrtrix.org/.
15 */
16
17#ifndef __interp_masked_h__
18#define __interp_masked_h__
19
20#include "datatype.h"
21#include "algo/loop.h"
22#include "interp/base.h"
23
24namespace MR
25{
26 namespace Interp
27 {
28
30 // @{
31
33
42 template <class InterpType>
43 class Masked : public InterpType { MEMALIGN(Masked<InterpType>)
44 public:
45 using typename InterpType::value_type;
46
47 Masked (const typename InterpType::image_type& parent,
49 InterpType (parent, value_when_out_of_bounds) { }
50
52 /* Unlike other interpolators, this sets the .index() location of
53 * the parent image, and checks to see whether or not there is
54 * any finite & non-zero data present; if there is not, then the
55 * function returns false, as though the location is outside of the
56 * image FoV.
57 *
58 * See file interp/base.h for details. */
59 template <class VectorType>
60 bool voxel (const VectorType& pos)
61 {
62 if (InterpType::set_out_of_bounds (pos))
63 return false;
67 for (auto l_inner = Loop(*this, 3) (*this); l_inner; ++l_inner) {
69 return InterpType::voxel (pos);
70 }
71 InterpType::set_out_of_bounds (true);
72 return true;
73 }
74
76
77 template <class VectorType>
78 FORCE_INLINE bool image (const VectorType& pos) {
79 return voxel (Transform::voxelsize.inverse() * pos.template cast<default_type>());
80 }
81
83
84 template <class VectorType>
85 FORCE_INLINE bool scanner (const VectorType& pos) {
86 return voxel (Transform::scanner2voxel * pos.template cast<default_type>());
87 }
88
89 };
90
91
92
94
95 }
96}
97
98#endif
99
100
This class defines the interface for classes that perform image interpolation.
Definition: base.h:70
Implicit masking for interpolator class.
Definition: masked.h:43
const Eigen::DiagonalMatrix< default_type, 3 > voxelsize
Definition: transform.h:42
const transform_type scanner2voxel
Definition: transform.h:43
constexpr I round(const T x)
Definition: math.h:64
FORCE_INLINE LoopAlongAxes Loop()
Definition: loop.h:419
VectorType::Scalar value(const VectorType &coefs, typename VectorType::Scalar cos_elevation, typename VectorType::Scalar cos_azimuth, typename VectorType::Scalar sin_azimuth, int lmax)
Definition: SH.h:233
MR::default_type value_type
Definition: typedefs.h:33
Definition: base.h:24
size_t index
#define MEMALIGN(...)
Definition: types.h:185
#define FORCE_INLINE
Definition: types.h:156