From 11af553f341ed27467ddcb96c5c7ee19351d35ba Mon Sep 17 00:00:00 2001
From: Stephen Smith <steve@fmrib.ox.ac.uk>
Date: Sun, 23 Apr 2006 11:48:04 +0000
Subject: [PATCH] changed order of slice timing correction and motion
 correction. updated fsl:exec calls to integrate with new runfsl/SGE stuff

---
 melodic.tcl | 67 +++++++++++++++++++++++++++++------------------------
 1 file changed, 37 insertions(+), 30 deletions(-)

diff --git a/melodic.tcl b/melodic.tcl
index d210f77..3b380de 100644
--- a/melodic.tcl
+++ b/melodic.tcl
@@ -138,6 +138,26 @@ set fmri(filteringf) [ $w.nb subwidget filtering ]
 
 set fmri(filtering_yn) 1
 
+#{{{ motion correction
+
+frame $w.mc
+set fmri(mcf) $w.mc
+
+global fmri(mc)
+tixOptionMenu $w.mc.menu -label "Motion correction: " -variable fmri(mc)
+$w.mc.menu add command 0 -label "None"
+$w.mc.menu add command 1 -label "MCFLIRT"
+set fmri(mc) 1
+
+pack $w.mc.menu -in $fmri(mcf) -side top -side left
+
+$w.bhelp bind $w.mc -msg "You will normally want to apply motion correction; this attempts to
+remove the effect of subject head motion during the
+experiment. MCFLIRT uses FLIRT (FMRIB's Linear Registration Tool)
+tuned to the problem of FMRI motion correction, applying rigid-body
+transformations."
+
+#}}}
 #{{{ slice timing correction
 
 frame $w.st
@@ -181,26 +201,6 @@ where the first line states which slice was acquired first, the second
 line states which slices was acquired second, etc. The first slice is
 numbered 1 not 0."
 
-#}}}
-#{{{ motion correction
-
-frame $w.mc
-set fmri(mcf) $w.mc
-
-global fmri(mc)
-tixOptionMenu $w.mc.menu -label "Motion correction: " -variable fmri(mc)
-$w.mc.menu add command 0 -label "None"
-$w.mc.menu add command 1 -label "MCFLIRT"
-set fmri(mc) 1
-
-pack $w.mc.menu -in $fmri(mcf) -side top -side left
-
-$w.bhelp bind $w.mc -msg "You will normally want to apply motion correction; this attempts to
-remove the effect of subject head motion during the
-experiment. MCFLIRT uses FLIRT (FMRIB's Linear Registration Tool)
-tuned to the problem of FMRI motion correction, applying rigid-body
-transformations."
-
 #}}}
 #{{{ BET brain extraction
 
@@ -268,7 +268,7 @@ pack $w.temp.label $w.temp.hplabel $w.temp.hp_yn $w.paradigm_hp -in $w.temp -sid
 
 #}}}
 
-pack $fmri(stf) $fmri(mcf) $w.bet $w.smooth $w.temp -in $fmri(filteringf) -anchor w -pady 1 -padx 5
+pack $fmri(mcf) $fmri(stf) $w.bet $w.smooth $w.temp -in $fmri(filteringf) -anchor w -pady 1 -padx 5
 
 #}}}
     #{{{ Melodic
@@ -477,6 +477,14 @@ if { $fmri(ndelete) > 0 } {
 set target_vol_number [ expr $total_volumes / 2 ]
 fsl:exec "${FSLDIR}/bin/avwroi $INPUT example_func $target_vol_number 1"
 
+#}}}
+#{{{ motion correction
+
+if { $fmri(mc) != 0 } {
+    fsl:exec "${FSLDIR}/bin/mcflirt -in $INPUT -out prefiltered_func_data_mcf -refvol $target_vol_number" -t 15
+    set INPUT prefiltered_func_data_mcf
+}
+
 #}}}
 #{{{ slice timing correction
 
@@ -500,14 +508,6 @@ if { $fmri(st) > 0 } {
     set INPUT prefiltered_func_data_st
 }
 
-#}}}
-#{{{ motion correction
-
-if { $fmri(mc) != 0 } {
-    fsl:exec "${FSLDIR}/bin/mcflirt -in $INPUT -out prefiltered_func_data_mcf -refvol $target_vol_number" -r
-    set INPUT prefiltered_func_data_mcf
-}
-
 #}}}
 #{{{ BET
 
@@ -556,10 +556,17 @@ fsl:exec "rm -rf prefiltered_func_data*"
 
 set thecommand "${FSLDIR}/bin/melodic -i $INPUT -o $OUTPUT -v --nobet --bgthreshold=$fmri(thresh) --tr=$fmri(tr)"
 
+set job_duration 20
 if { $fmri(dim_yn) == 1 } {
     set thecommand "$thecommand -d 0"
+    if { $total_volumes > 400 } {
+	set job_duration 180
+    }
 } else {
     set thecommand "$thecommand -d $fmri(dim)"
+    if { $fmri(dim) > 100 } {
+	set job_duration 180
+    }
 }
 
 if { $fmri(thresh_yn) == 0 } {
@@ -581,7 +588,7 @@ if { $fmri(ostats) == 1 } {
 }
 
 puts $thecommand
-fsl:exec $thecommand 
+fsl:exec "$thecommand" -t $job_duration
 
 #}}}
 
-- 
GitLab