From 221a80d4932fb65a7feaf2ada2ed0e008eb52af2 Mon Sep 17 00:00:00 2001 From: Saad Jbabdi <saad@fmrib.ox.ac.uk> Date: Wed, 13 Aug 2008 15:38:31 +0000 Subject: [PATCH] changes to waytotal: outputs one line per seed now --- ptx_nmasks.cc | 8 +++++++- ptx_twomasks.cc | 19 +++++++++++++------ streamlines.cc | 15 ++++++++++++--- streamlines.h | 1 + 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/ptx_nmasks.cc b/ptx_nmasks.cc index dc42edb..67a98a2 100644 --- a/ptx_nmasks.cc +++ b/ptx_nmasks.cc @@ -44,7 +44,10 @@ void nmasks() Seedmanager seedmanager(counter); + vector<int> keeptotal(seeds.size()); for(unsigned int i=0;i<seeds.size();i++){ + + // add all other seeds as waypoint masks tmpvol=0; for(unsigned int j=0;j<seeds.size();j++) if(j!=i) @@ -53,18 +56,21 @@ void nmasks() stline.pop_waymasks(); stline.add_waymask(tmpvol); + // start tracking cout << "Tracking from mask " << i+1 << endl; + keeptotal[i] = 0; for(int z=0;z<seeds[i].zsize();z++){ for(int y=0;y<seeds[i].ysize();y++){ for(int x=0;x<seeds[i].xsize();x++){ if(seeds[i](x,y,z)!=0){ - seedmanager.run(x,y,z,false,-1); + keeptotal[i] += seedmanager.run(x,y,z,false,-1); } } } } } + counter.save_total(keeptotal); counter.save(); cout<<"finished"<<endl; diff --git a/ptx_twomasks.cc b/ptx_twomasks.cc index e30c4eb..d3b05a9 100644 --- a/ptx_twomasks.cc +++ b/ptx_twomasks.cc @@ -35,12 +35,16 @@ void twomasks() counter.initialise(); Seedmanager seedmanager(counter); - stline.add_waymask(seeds2); + vector<int> keeptotal(2); + + stline.add_waymask(seeds2); + keeptotal[0] = 0; + cout << "tracking from first seed" << endl; for(int z=0;z<seeds.zsize();z++){ for(int y=0;y<seeds.ysize();y++){ for(int x=0;x<seeds.xsize();x++){ if(seeds(x,y,z)>0){ - seedmanager.run(x,y,z,false,-1); + keeptotal[0] += seedmanager.run(x,y,z,false,-1); } } } @@ -48,18 +52,21 @@ void twomasks() stline.pop_waymasks(); stline.add_waymask(seeds); - cout<<"added"<<endl; + keeptotal[1] = 0; + cout << "tracking from second seed" << endl; for(int z=0;z<seeds2.zsize();z++){ for(int y=0;y<seeds2.ysize();y++){ for(int x=0;x<seeds2.xsize();x++){ - if(seeds2(x,y,z)>0){ - seedmanager.run(x,y,z,false,seeds2(x,y,z)-1); + if(seeds2(x,y,z)>0){ + keeptotal[1] += seedmanager.run(x,y,z,false,-1); + //keeptotal[1] += seedmanager.run(x,y,z,false,seeds2(x,y,z)-1); } } } } - + + counter.save_total(keeptotal); counter.save(); cout<<"finished"<<endl; } diff --git a/streamlines.cc b/streamlines.cc index 044dc90..373dbe5 100644 --- a/streamlines.cc +++ b/streamlines.cc @@ -156,9 +156,9 @@ namespace TRACT{ float pref_x=0,pref_y=0,pref_z=0; if(opts.prefdirfile.value()!=""){ - pref_x = m_prefdir(xyz_seeds(1),xyz_seeds(2),xyz_seeds(3),0); - pref_y = m_prefdir(xyz_seeds(1),xyz_seeds(2),xyz_seeds(3),1); - pref_z = m_prefdir(xyz_seeds(1),xyz_seeds(2),xyz_seeds(3),2); + pref_x = m_prefdir((int)xyz_seeds(1),(int)xyz_seeds(2),(int)xyz_seeds(3),0); + pref_y = m_prefdir((int)xyz_seeds(1),(int)xyz_seeds(2),(int)xyz_seeds(3),1); + pref_z = m_prefdir((int)xyz_seeds(1),(int)xyz_seeds(2),(int)xyz_seeds(3),2); } //update every passed_flag for( unsigned int wm=0;wm<m_waymasks.size();wm++ ){ @@ -578,6 +578,15 @@ namespace TRACT{ keeptotvec(1)=keeptotal; write_ascii_matrix(keeptotvec,logger.appendDir("waytotal")); + } + void Counter::save_total(const vector<int>& keeptotal){ + + // save total number of particles that made it through the streamlining + ColumnVector keeptotvec(keeptotal.size()); + for (int i=1;i<=(int)keeptotal.size();i++) + keeptotvec(i)=keeptotal[i-1]; + write_ascii_matrix(keeptotvec,logger.appendDir("waytotal")); + } void Counter::save(){ diff --git a/streamlines.h b/streamlines.h index 5ffe94f..ab771a4 100644 --- a/streamlines.h +++ b/streamlines.h @@ -175,6 +175,7 @@ namespace TRACT{ void update_maskmatrix(){} //not written yet void save_total(const int& keeptotal); + void save_total(const vector<int>& keeptotal); void save(); void save_pathdist(); void save_pathdist(string add); -- GitLab