35 #ifndef AIMS_RESAMPLING_RESAMPLER_D_H 36 #define AIMS_RESAMPLING_RESAMPLER_D_H 62 : _ref( 0 ), _defval( T() )
71 const T& outBackground,
78 outResolution[0] = vs[0];
79 outResolution[1] = vs[1];
80 outResolution[2] = vs[2];
82 std::vector<int> sz = outVolume.
getSize();
93 * outSizeY * outSizeZ * outSizeT);
95 for ( t = 0; t < outSizeT; t++ )
97 updateParameters( inVolume, t, verbose );
99 for ( z = 0; z < outSizeZ; z++ )
102 for ( y = 0; y < outSizeY; y++ )
104 o = &outVolume.
at( 0, y, z, t );
106 for ( x = 0; x < outSizeX; x++ )
108 const Point3df outLoc ( x * outResolution[0],
109 y * outResolution[1],
110 z * outResolution[2] );
112 doResample( inVolume, inverse_transform_to_vox, outBackground,
127 template <
typename T>
139 mm_to_voxel_transform.
scale(
Point3df( 1, 1, 1 ), in_voxel_size );
142 transform_chain.
push_back(external_ref(inverse_transform_to_mm));
143 transform_chain.
push_back(external_ref(mm_to_voxel_transform));
145 resample_inv_to_vox(input_data, transform_chain, background,
146 output_volume, verbose);
149 template <
typename T>
162 mm_to_voxel_transform.
scale(
Point3df( 1, 1, 1 ), in_voxel_size );
165 transform_chain.
push_back(external_ref(inverse_transform_to_mm));
166 transform_chain.
push_back(external_ref(mm_to_voxel_transform));
168 resample_inv_to_vox(input_data, transform_chain, background,
169 output_location, output_value, timestep);
173 template <
typename T >
177 const T& outBackground,
187 normTransform3d = transform3d * normTransform3d;
188 normTransform3d = normTransform3d.
inverse();
190 resample_inv_to_vox(inVolume, normTransform3d, outBackground, outVolume,
196 template <
typename T >
200 const T& outBackground,
202 T& outValue,
int t )
const 210 normTransform3d = transform3d * normTransform3d;
211 normTransform3d = normTransform3d.
inverse();
215 doResample( inVolume, normTransform3d, outBackground, outLocation,
221 template <
typename T>
226 throw std::runtime_error(
"Resampler used without a ref volume to resample" 232 template <
typename T>
235 int dimX,
int dimY,
int dimZ,
239 throw std::runtime_error(
"Resampler used without a ref volume to resample" 242 std::vector<float> vs( 4, 1. );
243 vs[0] = resolution[0];
244 vs[1] = resolution[1];
245 vs[2] = resolution[2];
247 thing->header().setProperty(
"voxel_size", vs );
250 thing->copyHeaderFrom( _ref->header() );
251 thing->header().setProperty(
"voxel_size", vs );
268 std::vector<std::vector<float> > trout;
269 trout.reserve( trs->size() );
270 for( ; tit->isValid(); tit->next() )
274 trout.push_back( m.toVector() );
281 std::vector<std::vector<float> > trout;
282 std::vector<std::string> refsout;
287 std::string refid = iref->getString();
288 refsout.push_back( refid );
293 if( refsout.empty() )
294 refsout.push_back(
"Coordinates aligned to another file or to " 295 "anatomical truth" );
306 template <
typename T>
const T & at(long x, long y=0, long z=0, long t=0) const
virtual void print(const bool force=false)
virtual bool removeProperty(const std::string &key)
std::vector< int > getSize() const
void setProperty(const std::string &, const T &)
std::vector< float > getVoxelSize() const
Resampling of data from a volume, applying a transformation.
std::vector< float > getVoxelSize() const
bool getProperty(const std::string &, T &) const
reference_wrapper< T > ref(T &ref)