diff --git a/probtrackxOptions.h b/probtrackxOptions.h index 83ed8abe6b7170246ce48df2d66b37ae65ff543a..fa2f5f75093de7feb99d58938ccdaa990b1e71bd 100644 --- a/probtrackxOptions.h +++ b/probtrackxOptions.h @@ -66,7 +66,7 @@ class probtrackxOptions { Option<int> fibst; Option<bool> modeuler; Option<int> rseed; - + Option<bool> seedcountastext; void parse_command_line(int argc, char** argv,Log& logger); void modecheck(); @@ -206,6 +206,9 @@ class probtrackxOptions { rseed(string("--rseed"), 12345, string("Random seed"), false, requires_argument), + seedcountastext(string("--seedcountastext"), false, + string("Output seed-to-target counts as a text file"), + false, no_argument), options("probtrackx","probtrackx -s <basename> -m <maskname> -x <seedfile> -o <output> --targetmasks=<textfile>\n probtrackx --help\n") { @@ -249,6 +252,7 @@ class probtrackxOptions { options.add(fibst); options.add(modeuler); options.add(rseed); + options.add(seedcountastext); } catch(X_OptionError& e) { options.usage(); diff --git a/streamlines.cc b/streamlines.cc index ed69306a6ad16d34c264332040a935a33abdd99f..a0f71fb2f7eb9c3cb6627be3265060af182be51a 100644 --- a/streamlines.cc +++ b/streamlines.cc @@ -299,6 +299,33 @@ namespace TRACT{ m_seedcounts.push_back(tmpint); //m_particle_numbers.push_back(tmpvec); } + + // where we save the seed counts in text files + if(opts.seedcountastext.value()){ + + int numseeds=0; + if(opts.meshfile.value()==""){ + for(int Wz=m_seeds.minz();Wz<=m_seeds.maxz();Wz++) + for(int Wy=m_seeds.miny();Wy<=m_seeds.maxy();Wy++) + for(int Wx=m_seeds.minx();Wx<=m_seeds.maxx();Wx++) + if(m_seeds.value(Wx,Wy,Wz)!=0) + numseeds++; + } + else{ + ifstream fs(opts.seedfile.value().c_str()); + if(fs){ + char buffer[1024]; + fs.getline(buffer,1024); + fs >>numseeds; + cout<<numseeds<<endl; + } + } + + m_SeedCountMat.ReSize(numseeds,m_targetmasknames.size()); + m_SeedCountMat=0; + m_SeedRow=1; + } + } @@ -426,6 +453,9 @@ namespace TRACT{ if(opts.matrix2out.value()){ next_matrix2_row(); } + if(opts.seedcountastext.value()){ + m_SeedRow++; + } } @@ -499,6 +529,10 @@ namespace TRACT{ m_seedcounts[m](xseedvox,yseedvox,zseedvox)=m_seedcounts[m](xseedvox,yseedvox,zseedvox)+1; m_targflags[m]=1; //m_particle_numbers[m].push_back(particle_number); + + if(opts.seedcountastext.value()) + m_SeedCountMat(m_SeedRow,m+1) += 1; + } } } @@ -515,6 +549,10 @@ namespace TRACT{ m_seedcounts[m](xseedvox,yseedvox,zseedvox)+=(int)d; m_targflags[m]=1; //m_particle_numbers[m].push_back(particle_number); + + if(opts.seedcountastext.value()) + m_SeedCountMat(m_SeedRow,m+1) += d; + } } @@ -678,6 +716,11 @@ namespace TRACT{ save_volume(m_seedcounts[m],logger.appendDir("seeds_to_"+tmpname)); } + + if(opts.seedcountastext.value()){ + write_ascii_matrix(m_SeedCountMat,logger.appendDir("matrix_seeds_to_all_targets")); + } + } // the following is a helper function for save_matrix* diff --git a/streamlines.h b/streamlines.h index 2f9d9126ca3a9df79e5a640127b18b5709261ac7..39748fc8cba34a58d749ca9da17be11bb1d9ac75 100644 --- a/streamlines.h +++ b/streamlines.h @@ -98,6 +98,9 @@ namespace TRACT{ vector<ColumnVector> m_path; vector<volume<int> > m_seedcounts; + Matrix m_SeedCountMat; + int m_SeedRow; + vector<volume<float> > m_targetmasks; vector<string> m_targetmasknames; vector<int> m_targflags;