aimsdata 6.0.0
Neuroimaging data handling
bucketutil_d.h
Go to the documentation of this file.
1#ifndef AIMS_BUCKET_BUCKETUTIL_D_H
2#define AIMS_BUCKET_BUCKETUTIL_D_H
3
7
8namespace aims
9{
10
11 template <typename T, typename U>
12 carto::VolumeRef<U>
14 const BucketMap<T> & bucket, int borderwidth, Point3d* pos )
15 {
16 Point3d bmin( 0, 0, 0 );
17
18 // bounding box of all buckets
19 BoundingBox bb;
20 bb.add( bucket );
21 Point3df dmax = bb.maximum();
22 float vx = bucket.sizeX();
23 float vy = bucket.sizeY();
24 float vz = bucket.sizeZ();
25 Point3d bmax = Point3d( int16_t( round( dmax[0] / vx ) ),
26 int16_t( round( dmax[1] / vy ) ),
27 int16_t( round( dmax[2] / vz ) ) );
28 if( pos )
29 {
30 Point3df dmin = bb.minimum();
31 bmin = Point3d( int16_t( round( dmin[0] / vx ) ),
32 int16_t( round( dmin[1] / vy ) ),
33 int16_t( round( dmin[2] / vz ) ) );
34 *pos = bmin;
35 }
36
37 carto::VolumeRef<U> res = volumeFromBucket<T, U>( bucket, bmin, bmax,
38 borderwidth );
39
40 return res;
41 }
42
43
44 template <typename T, typename U>
47 const BucketMap<T> & bucket, const Point3d & bbmin, const Point3d & bbmax,
48 int borderwidth )
49 {
50 Point3d size = bbmax - bbmin + Point3d( 1, 1, 1 );
51
52 // fill in volume with all buckets
53 carto::VolumeRef<U> vol( size[0], size[1], size[2], 1, borderwidth );
54 std::vector<float> vs;
55 vs.push_back( bucket.sizeX() );
56 vs.push_back( bucket.sizeY() );
57 vs.push_back( bucket.sizeZ() );
58 vs.push_back( bucket.sizeT() );
59 vol->header().setProperty( "voxel_size", vs );
60 vol->fill( 0 );
61 vol->fillBorder( -1 );
63 conv;
64 conv.printToVolume( bucket, vol, -bbmin );
65
66 return vol;
67 }
68
69}
70
71#endif
72
void add(const Point3df &pos)
Point3df minimum() const
Definition boundingbox.h:86
Point3df maximum() const
Definition boundingbox.h:93
An alternate, ordered, representation for buckets (voxels lists).
Definition bucketMap.h:99
float sizeZ() const
returns the Z resolution in mm
Definition bucketMap.h:254
float sizeT() const
returns the T resolution in s
Definition bucketMap.h:264
float sizeY() const
returns the Y resolution in mm
Definition bucketMap.h:244
float sizeX() const
returns the X resolution in mm
Definition bucketMap.h:234
static carto::VolumeRef< U > volumeFromBucket(const BucketMap< T > &bucket, int borderwidth=0, Point3d *pos=0)
Bucket to volume conversion.
void setProperty(const std::string &, const T &)
void fillBorder(const T &value)
const PropertySet & header() const
void fill(const T &value)
The class for EcatSino data write operation.
AimsVector< float, 3 > Point3df
AimsVector< int16_t, 3 > Point3d