35 #ifndef AIMS_ROI_ROISTAT_H
36 #define AIMS_ROI_ROISTAT_H
85 std::set< Vertex*> currentRoiStatVert;
87 std::vector< int > roi_st, roi_dt;
90 roi.setProperty(
"last_image_stated", image);
91 setProperty(
"last_image_stated", image);
94 std::vector< int > bbmaxTO;
95 std::vector< float > vsTO;
96 roi.getProperty(
"boundingbox_max", bbmaxTO);
97 roi.getProperty(
"voxel_size", vsTO );
100 std::vector< int > i_st, i_dt;
108 ASSERT(image->getSizeT() == 1);
117 ASSERT(image->getSizeT() == 1);
131 for (
int t = 0; t < image->getSizeT(); ++t)
136 getProperty(
"start_time", roi_st );
137 roi_st.push_back( i_st[ t ] );
138 setProperty(
"start_time",roi_st);
139 getProperty(
"duration_time", roi_dt );
140 roi_dt.push_back( i_dt[ t ] );
141 setProperty(
"duration_time",roi_dt);
144 std::vector<int> dim = tmpin->
getSize();
145 for( z=0; z<dim[2]; ++z )
146 for( y=0; y<dim[1]; ++y )
147 for( x=0; x<dim[0]; ++x )
148 tmpin(x, y, z) = image->
at(x, y, z, t);
152 bbmaxTO[0]+1, bbmaxTO[1]+1, bbmaxTO[2]+1,
153 Point3df( vsTO[0],vsTO[1],vsTO[2] ) );
157 metaRoi != metaRoiList.end();
160 std::map<int,carto::rc_ptr<BucketMap<Void> > > corresBuckets;
161 std::map<int,carto::rc_ptr<BucketMap<Void> > >
::iterator
162 ib, eb = corresBuckets.end();
163 Tree* tmpTree =
dynamic_cast< Tree *
>( *metaRoi );
164 std::string surname;(*tmpTree).getProperty(
"surname", surname);
167 const std::list<BaseTree*> & metaRoiChild = (*metaRoi)->
children();
169 metaRoiContent != metaRoiChild.end();
172 tmpTree =
dynamic_cast< Tree *
>( *metaRoiContent );
173 std::string tmp;(*tmpTree).getProperty(
"nomenName", tmp);
177 for( std::set< Vertex* >::const_iterator j = roisv.begin();
178 j != roisv.end(); ++j )
180 int l; (*j)->getProperty(
"roi_label", l);
181 if( (*j)->getProperty(
"aims_roi", bck ) )
182 corresBuckets[ l ] = bck;
184 std::cout <<
"Bucket not found. Label = " << l << std::endl ;
188 if (corresBuckets.size() == 0)
continue;
194 ASSERT (currentRoiStatVert.size() < 2 );
196 if (currentRoiStatVert.size() == 0)
199 v->setProperty(
"surname", surname);
201 else v = *( currentRoiStatVert.begin() );
209 for( ib=corresBuckets.begin(); ib!=eb; ++ib )
216 for( ibk=bck->begin()->second.begin(),
217 ebk=bck->begin()->second.end(); ibk!=ebk; ++ibk )
219 float pixel = tmpout( ibk->first );
230 std=(float)sqrt( (
double)(std-
square(mean)*pn2) / (
float)(pn2-1) );
232 v->setProperty(
"voxel_number", pn2 );
233 std::vector< float > tac, sac, mac, Mac;
234 v->getProperty(
"mean_ac", tac);
235 tac.push_back( mean );
236 v->setProperty(
"mean_ac", tac);
237 v->getProperty(
"std_ac", sac);
238 sac.push_back( std );
239 v->setProperty(
"std_ac", sac);
240 v->getProperty(
"min_ac", mac);
241 mac.push_back(
min );
242 v->setProperty(
"min_ac", mac);
243 v->getProperty(
"max_ac", Mac);
244 Mac.push_back(
max );
245 v->setProperty(
"max_ac", Mac);
249 setProperty(
"voxel_volume",vsTO[0]*vsTO[1]*vsTO[2]);
const std::list< BaseTree * > & children() const
std::list< BaseTree * >::const_iterator const_iterator
Vertex * addVertex(const std::string &s="")
std::set< Vertex * > getVerticesWith(const std::string &s) const
std::set< Vertex * > VertByNameAndDescendantName(std::string &name)
void setRef(const carto::rc_ptr< carto::Volume< T > > &ref)
Set the input data to be resampled by the doit() methods.
void doit(const aims::AffineTransformation3d &transform, carto::Volume< T > &output_data) const
Resample the input volume set with setRef() into an existing volume.
void populate(carto::rc_ptr< carto::Volume< T > > &image, AimsRoi &roi, const AffineTransformation3d &motion)
void applyGtm(RoiGtm &rgtm)
RoiStats(Resampler< float > *interpolator, RoiSelector *roiSel)
Resampler< float > * _interpolator
void streamout(char *out=NULL)
std::vector< float > tacByStructName(std::string s)
virtual bool hasProperty(const std::string &) const
bool getProperty(const std::string &, T &) const
void setVoxelSize(float vx, float vy=1., float vz=1., float vt=1.)
virtual void copyHeaderFrom(const PropertySet &other)
std::vector< int > getSize() const
const T & at(long x, long y=0, long z=0, long t=0) const
float min(float x, float y)
float max(float x, float y)