From d39dd0d3914696b819f589ad535588c73bd1a7b9 Mon Sep 17 00:00:00 2001
From: Saad Jbabdi <saad@fmrib.ox.ac.uk>
Date: Tue, 2 May 2006 08:32:14 +0000
Subject: [PATCH] added an option --pd to probtrackx for balancing the
 probability w.r.t distance

---
 probtrackxOptions.h | 24 ++++++++++++++----------
 streamlines.cc      | 22 +++++++++++++++++-----
 2 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/probtrackxOptions.h b/probtrackxOptions.h
index 32ad71c..36431e5 100644
--- a/probtrackxOptions.h
+++ b/probtrackxOptions.h
@@ -35,6 +35,7 @@ class probtrackxOptions {
   Option<string> mode;
   Option<string> targetfile;
   Option<bool> simpleout;
+  Option<int> pathdist;
   Option<bool> s2tout;
   FmribOption<bool> matrix1out;
   FmribOption<bool> matrix2out;
@@ -109,6 +110,9 @@ class probtrackxOptions {
   simpleout(string("--opd"), false,
 	    string("output path distribution"),
 	    false, no_argument), 
+  pathdist(string("--pd"), 1,
+	   string("path distribution, 1:probability,2:distance corrected value"),
+	   false, requires_argument), 
   s2tout(string("--os2t"), false,
 	 string("output seeds to targets"),
 	 false, no_argument),
@@ -119,18 +123,17 @@ class probtrackxOptions {
 	  string("output matrix2"),
 	  false, no_argument), 
   maskmatrixout(string("--omaskmatrix"), false,
-	    string("output maskmatrix"),
-	  false, no_argument), 
-
-  outfile(string("-o,--out"), string(""),
-	    string("Output file (only for single seed voxel mode)"),
-	    false, requires_argument),
+		string("output maskmatrix"),
+		false, no_argument), 
+   outfile(string("-o,--out"), string(""),
+	   string("Output file (only for single seed voxel mode)"),
+	   false, requires_argument),
    rubbishfile(string("--rubbish"), string(""),
-	    string("Rubbish file"),
-	    false, requires_argument),
+	       string("Rubbish file"),
+	       false, requires_argument),
    seeds_to_dti(string("--xfm"), string(""),
-	      string("Transform Matrix taking seed space to DTI space default is to use the identity"),false, requires_argument),
-  skipmask(string("--no_integrity"), string(""),
+		string("Transform Matrix taking seed space to DTI space default is to use the identity"),false, requires_argument),
+   skipmask(string("--no_integrity"), string(""),
 	   string("no explanation needed"),
 	   false, requires_argument),
   seedref(string("--seedref"), string(""),
@@ -205,6 +208,7 @@ class probtrackxOptions {
        options.add(logdir); 
        options.add(forcedir); 
        options.add(simpleout);
+       options.add(pathdist);
        options.add(s2tout);
        options.add(matrix1out);
        options.add(matrix2out);
diff --git a/streamlines.cc b/streamlines.cc
index f845479..330b214 100644
--- a/streamlines.cc
+++ b/streamlines.cc
@@ -363,11 +363,23 @@ namespace TRACT{
   
   void Counter::update_pathdist(){
     const vector<ColumnVector>& path=m_stline.get_path_ref();
-    for(unsigned int i=0;i<path.size();i++){
-      int x_s=int(round(float(path[i](1)))),y_s=int(round(float(path[i](2)))),z_s=int(round(float(path[i](3))));
-      if(m_beenhere(x_s,y_s,z_s)==0){
-	m_prob(x_s,y_s,z_s)+=1;
-	m_beenhere(x_s,y_s,z_s)=1;
+    if(opts.pathdist.value()==1){
+      for(unsigned int i=0;i<path.size();i++){
+	int x_s=int(round(float(path[i](1)))),y_s=int(round(float(path[i](2)))),z_s=int(round(float(path[i](3))));
+	if(m_beenhere(x_s,y_s,z_s)==0){
+	  m_prob(x_s,y_s,z_s)+=1;
+	  m_beenhere(x_s,y_s,z_s)=1;
+	}
+      }
+    }
+    else{
+      int d=1;
+      for(unsigned int i=0;i<path.size();i++){
+	int x_s=int(round(float(path[i](1)))),y_s=int(round(float(path[i](2)))),z_s=int(round(float(path[i](3))));
+	if(m_beenhere(x_s,y_s,z_s)==0){
+	  m_prob(x_s,y_s,z_s)+=d;d++;
+	  m_beenhere(x_s,y_s,z_s)=1;
+	}
       }
     }
     
-- 
GitLab