37#ifndef AIMS_UTILITY_FLIP_H
38#define AIMS_UTILITY_FLIP_H
41#include <cartodata/volume/volume.h>
42#include <cartobase/containers/nditerator.h>
93 const std::string & orient );
112template <
class T>
inline
120 thing->getSize() ) );
125 std::vector<float> trans_shift;
149 for( ; rit->isValid(); rit->next(), ++i )
151 std::string rid = rit->currentValue()->getString();
164 std::cerr <<
"wrong referential ID\n";
175 std::vector<float>( thing->getSize().size(), 0.f ) );
177 std::vector<int> dims = thing->getSize();
179 = thing->referential().toOrientation(
186 std::vector<float> vs = thing->getVoxelSize();
187 std::vector<float> fvs =
flip.transformVector( vs );
189 for( i=0, n=fvs.size(); i<n; ++i )
190 fvs[i] = std::abs( fvs[i] );
191 for( i=0, n=std::min(
size_t(
flip.order() ), vs.size() ); i<n; ++i )
193 vsf.
matrix()( i, i ) = 1. / vs[i];
194 tvsf.
matrix()( i, i ) = fvs[i];
197 std::unique_ptr<soma::AffineTransformationBase> iflip =
flip.inverse();
199 std::vector<float> ts2 = iflip->transform( trans_shift );
211 res->flipToOrientation( orient, orient );
213 res->flipToOrientation( orient );
215 res->referential().setOrientation(
"LPI" );
220 if( !trans_shift.empty() )
225 size_t i, n = std::min(
size_t( shift.
order() ), trans_shift.size() );
227 shift.
matrix()( i, shift.
order() ) = trans_shift[i];
229 std::vector< std::vector<float> > new_trans;
230 new_trans.reserve( trans->size() );
232 for( ; tit->isValid(); tit->next() )
236 new_trans.push_back( t.
toVector() );
249template <
class T>
inline
253 return this->
flip( thing,
"RPI" );
256template <
class T>
inline
259 return this->
flip( thing,
"LAI" );
263template <
class T>
inline
266 return this->
flip( thing,
"LPS" );
270template <
class T>
inline
273 return this->
flip( thing,
"RPS" );
276template <
class T>
inline
279 return this->
flip( thing,
"RAI" );
283template <
class T>
inline
286 return this->
flip( thing,
"LAS" );
290template <
class T>
inline
293 return this->
flip( thing,
"PLI" );
297template <
class T>
inline
301 return this->
flip( thing,
"IPL" );
305template <
class T>
inline
309 return this->
flip( thing,
"LIP" );
313template <
class T>
inline
317 return this->
flip( thing,
"RAS" );
void setUpdateTransforms(bool x)
carto::VolumeRef< T > doZZ(const carto::rc_ptr< carto::Volume< T > > &thing)
function which returns the ZZ flipped data
carto::VolumeRef< T > doYY(const carto::rc_ptr< carto::Volume< T > > &thing)
function which returns the YY flipped data
carto::VolumeRef< T > doXX(const carto::rc_ptr< carto::Volume< T > > &thing)
function which returns the XX flipped data
carto::VolumeRef< T > doXZ(const carto::rc_ptr< carto::Volume< T > > &thing)
function which returns the XZ flipped data
void setCenterReferential(const std::string &x)
carto::VolumeRef< T > doXXYYZZ(const carto::rc_ptr< carto::Volume< T > > &thing)
function which returns the XXYYZZ flipped data
void setFlipMemory(bool x)
carto::VolumeRef< T > doXY(const carto::rc_ptr< carto::Volume< T > > &thing)
function which returns the XY flipped data
bool updateTransforms() const
bool useSharedView() const
carto::VolumeRef< T > doXXZZ(const carto::rc_ptr< carto::Volume< T > > &thing)
function which returns the XXZZ flipped data
carto::VolumeRef< T > flip(const carto::rc_ptr< carto::Volume< T > > &thing, const std::string &orient)
returns the flipped data in the given orientation
carto::VolumeRef< T > doYZ(const carto::rc_ptr< carto::Volume< T > > &thing)
function which returns the YZ flipped data
std::string centerRefertential() const
carto::VolumeRef< T > doYYZZ(const carto::rc_ptr< carto::Volume< T > > &thing)
function which returns the YYZZ flipped data
carto::VolumeRef< T > doXXYY(const carto::rc_ptr< carto::Volume< T > > &thing)
function which returns the XXYY flipped data
void setUseSharedView(bool x)
void setProperty(const std::string &, const T &)
virtual bool removeProperty(const std::string &key)
virtual bool hasProperty(const std::string &) const
bool getProperty(const std::string &, T &) const
virtual void copyHeaderFrom(const PropertySet &other)
const PropertySet & header() const