35#ifndef AIMS_RESAMPLING_RESAMPLER_D_H
36#define AIMS_RESAMPLING_RESAMPLER_D_H
40#include <cartobase/config/verbose.h>
41#include <aims/transformation/transformation_chain.h>
42#include <aims/utility/progress.h>
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();
96 * outSizeY * outSizeZ * outSizeT, 0, 100,
"%", 3,
99 for ( t = 0; t < outSizeT; t++ )
103 for ( z = 0; z < outSizeZ; z++ )
106 for ( y = 0; y < outSizeY; y++ )
108 o = &outVolume.
at( 0, y, z, t );
110 for ( x = 0; x < outSizeX; x++ )
112 const Point3df outLoc ( x * outResolution[0],
113 y * outResolution[1],
114 z * outResolution[2] );
116 doResample( inVolume, inverse_transform_to_vox, outBackground,
122 if(verbose || _verbose_stream) {
145 aims::TransformationChain3d transform_chain;
146 transform_chain.push_back(external_ref(inverse_transform_to_mm));
147 transform_chain.push_back(external_ref(mm_to_voxel_transform));
150 output_volume, verbose);
166 mm_to_voxel_transform.
scale(
Point3df( 1, 1, 1 ), in_voxel_size );
168 aims::TransformationChain3d transform_chain;
169 transform_chain.push_back(external_ref(inverse_transform_to_mm));
170 transform_chain.push_back(external_ref(mm_to_voxel_transform));
173 output_location, output_value, timestep);
177template <
typename T >
181 const T& outBackground,
191 normTransform3d = transform3d * normTransform3d;
192 normTransform3d = *normTransform3d.
inverse();
200template <
typename T >
204 const T& outBackground,
206 T& outValue,
int t )
const
214 normTransform3d = transform3d * normTransform3d;
215 normTransform3d = *normTransform3d.
inverse();
219 doResample( inVolume, normTransform3d, outBackground, outLocation,
230 throw std::runtime_error(
"Resampler used without a ref volume to resample"
239 int dimX,
int dimY,
int dimZ,
243 throw std::runtime_error(
"Resampler used without a ref volume to resample"
246 std::vector<float> vs( 4, 1. );
247 vs[0] = resolution[0];
248 vs[1] = resolution[1];
249 vs[2] = resolution[2];
250 vs[3] =
_ref->getVoxelSize()[3];
271 std::unique_ptr<aims::AffineTransformation3d> motioninv
273 std::vector<std::vector<float> > trout;
274 trout.reserve( trs->size() );
275 for( ; tit->isValid(); tit->next() )
279 trout.push_back( m.toVector() );
286 std::vector<std::vector<float> > trout;
287 std::vector<std::string> refsout;
288 const carto::PropertySet & iph = _ref->header();
291 carto::Object iref = iph.
getProperty(
"referential" );
292 std::string refid = iref->getString();
293 refsout.push_back( refid );
298 if( refsout.empty() )
299 refsout.push_back(
"Coordinates aligned to another file or to "
300 "anatomical truth" );
302 trout.push_back( motion.
inverse()->toVector() );
virtual void updateParameters(const carto::Volume< float > &, int, bool) const
void resample_inv(const carto::Volume< T > &input_data, const soma::Transformation3d &inverse_transform_to_mm, const T &background, const Point3df &output_location, T &output_value, int timestep) const
Resample a volume at a single location.
virtual void doResample(const carto::Volume< float > &input_data, const soma::Transformation3d &inverse_transform, const float &background, const Point3df &output_location, float &output_value, int timestep) const=0
void setRef(const carto::rc_ptr< carto::Volume< T > > &ref)
Set the input data to be resampled by the doit() methods.
virtual void resample(const carto::Volume< T > &input_data, const aims::AffineTransformation3d &transform, const T &background, carto::Volume< T > &output_data, bool verbose=false) const
Resample a volume into an existing output volume.
void doit(const aims::AffineTransformation3d &transform, carto::Volume< T > &output_data) const
Resample the input volume set with setRef() into an existing volume.
carto::rc_ptr< carto::Volume< T > > _ref
void resample_inv_to_vox(const carto::Volume< T > &input_data, const soma::Transformation3d &inverse_transform_to_vox, const T &background, const Point3df &output_location, T &output_value, int timestep) const
Resample a volume at a single location.
std::ostream * _verbose_stream
const carto::rc_ptr< carto::Volume< T > > & ref() const
Input data to be resampled by the doit() methods.
void setProperty(const std::string &, const T &)
virtual bool removeProperty(const std::string &key)
bool getProperty(const std::string &, T &) const
std::vector< float > getVoxelSize() const
std::vector< int > getSize() const
virtual void copyHeaderFrom(const PropertySet &other)
const PropertySet & header() const
const T & at(long x, long y=0, long z=0, long t=0) const
ProgressInfo< double, double > Progression
AimsVector< float, 3 > Point3df