diff --git a/fdt.tcl b/fdt.tcl index 43b31184124a27380fd02b1b684a0ac40f9590bc..b1fce27adfe12eb366f471f4592b33b7babd7451 100644 --- a/fdt.tcl +++ b/fdt.tcl @@ -80,6 +80,11 @@ proc fdt:dialog { w tclstartupfile } { checkbutton $w.registration.struct.yn -variable registration(struct_yn) -command "registration_packframe $w" label $w.registration.struct.lb -text "Main structural image" TitleFrame $w.registration.struct.tf -text "Main structural image" + frame $w.registration.nonlin + checkbutton $w.registration.nonlin.yn -variable registration(nonlin_yn) -text "Non-betted structural" -command "registration_packframe $w" + FileEntry $w.registration.nonlin.file -textvariable registration(nonlin_image) -filetypes IMAGE + + optionMenu2 $w.registration.struct.tf.search registration(struct_search) 0 "No search" 90 "Normal search" 180 "Full search" optionMenu2 $w.registration.struct.tf.dof registration(struct_dof) 6 "6 DOF" 7 "7 DOF" 9 "9 DOF" 12 "12 DOF" optionMenu2 $w.registration.struct.tf.costfn registration(struct_costfn) corratio "Correlation ratio" mutualinfo "Mutual information" @@ -106,14 +111,18 @@ proc fdt:dialog { w tclstartupfile } { set registration(standard_search) 90 set registration(standard_image) [ file join ${FSLDIR} data standard MNI152_T1_2mm_brain ] - pack $w.registration.directory $w.registration.struct $w.registration.standard -side top -padx 3 -pady 3 -anchor w + pack $w.registration.directory $w.registration.struct $w.registration.nonlin $w.registration.standard -side top -padx 3 -pady 3 -anchor w + + proc registration_packframe { w } { global registration - pack forget $w.registration.struct.yn $w.registration.struct.tf $w.registration.struct.yn $w.registration.struct.lb + pack forget $w.registration.struct.yn $w.registration.struct.tf $w.registration.struct.yn $w.registration.struct.lb $w.registration.nonlin.yn $w.registration.nonlin.file pack forget $w.registration.standard.yn $w.registration.standard.tf $w.registration.standard.yn $w.registration.standard.lb - if {$registration(struct_yn)} { pack $w.registration.struct.yn $w.registration.struct.tf -side left -anchor w } else { pack $w.registration.struct.yn $w.registration.struct.lb -side left -anchor w} - if {$registration(standard_yn)} { pack $w.registration.standard.yn $w.registration.standard.tf -side left -anchor w } else { pack $w.registration.standard.yn $w.registration.standard.lb -side left -anchor w} + if { $registration(struct_yn) } { pack $w.registration.struct.yn $w.registration.struct.tf -side left -anchor w } else { pack $w.registration.struct.yn $w.registration.struct.lb -side left -anchor w} + if { $registration(struct_yn) } { pack $w.registration.nonlin.yn -side left } + if { $registration(struct_yn) && $registration(nonlin_yn) } { pack $w.registration.nonlin.file -side left } + if { $registration(standard_yn) } { pack $w.registration.standard.yn $w.registration.standard.tf -side left -anchor w } else { pack $w.registration.standard.yn $w.registration.standard.lb -side left -anchor w} } registration_packframe $w @@ -474,16 +483,17 @@ proc fdt:probtrack_mode { w } { pack forget $w.data.seed.voxel $w.data.seed.ssf $w.data.seed.ssf.xfm $w.data.seed.ssf.reference $w.data.seed.bcf $w.data.seed.target $w.data.targets.cf $w.data.seed.ssf.invxfm $w.data.seed.ssf.nonlinear $w.data.dir configure -label "Output directory:" -title "Name the output directory" -filetypes * - if { $probtrack(useNonlinear) } { pack $w.data.seed.ssf.invxfm -side bottom -anchor w -pady 2 } + pack $w.data.seed.ssf -in $w.data.seed.f -side bottom -anchor w -pady 2 + if { $probtrack(useNonlinear) && $probtrack(usereference_yn) } { pack $w.data.seed.ssf.invxfm -side bottom -anchor w -pady 2 } switch -- $probtrack(mode) { simple { - pack $w.data.seed.ssf $w.data.seed.voxel -in $w.data.seed.f -side bottom -anchor w -pady 2 + pack $w.data.seed.voxel -in $w.data.seed.f -side bottom -anchor w -pady 2 if { $probtrack(usereference_yn) } { pack $w.data.seed.ssf.reference -side bottom -anchor w -pady 2 } $w.data.seed.ssf.reference configure -label "Seed reference image:" -title "Choose reference image" $w.data.dir configure -label "Output file:" -title "Name the output file" -filetypes IMAGE } seedmask { - pack $w.data.seed.ssf -in $w.data.seed.f -side bottom -anchor w -pady 2 + pack forget $w.data.seed.ssf.ssd if { [ file exists ${FSLDIR}/bin/reord_OM ] } { pack $w.data.seed.bcf -in $w.data.seed.f -side bottom -anchor w -pady 2 @@ -494,12 +504,12 @@ proc fdt:probtrack_mode { w } { } network { - pack $w.data.seed.target $w.data.seed.ssf -in $w.data.seed.f -side bottom -anchor w -pady 2 + pack $w.data.seed.target -in $w.data.seed.f -side bottom -anchor w -pady 2 } } if { $probtrack(waypoint_yn) } { pack $w.data.targets.wf.tf } if { $probtrack(classify_yn) } { pack $w.data.targets.cf.tf } - if { $probtrack(usereference_yn) } { $w.data.seed.ssf.nonlinear pack $w.data.seed.ssf.xfm -side bottom -anchor w -pady 2 } + if { $probtrack(usereference_yn) } { pack $w.data.seed.ssf.nonlinear $w.data.seed.ssf.xfm -side top -anchor w -pady 2 } $w.probtrack compute_size } @@ -600,7 +610,8 @@ proc fdt:apply { w dialog } { set errorStr "" if { $eddy(input) == "" } { set errorStr "You need to specify the input image! " } if { $eddy(output) == "" } { set errorStr "$errorStr You need to specify an output image!" } - if { $eddy(reorientbVecs) && $errorStr != "" } { set errorStr "$errorStr You need to specify a bvecs image!" } + if { $eddy(reorientbVecs) } { set errorStr "$errorStr You need to specify a bvecs image!" } + if { $errorStr != "" } { MxPause $errorStr return } @@ -688,6 +699,7 @@ proc fdt:apply { w dialog } { if { $probtrack(mode) == "simple" && $probtrack(usereference_yn) && $probtrack(reference) == "" } { set errorStr "$errorStr You must specify a reference image" } if { $probtrack(mode) == "seedmask" && $probtrack(reference) == "" } { set errorStr "$errorStr You must specify a mask image" } if { $probtrack(exclude_yn) && $probtrack(exclude) == "" } { set errorStr "$errorStr You must specify the exclusion mask!" } + if { $probtrack(useNonlinear) && $probtrack(usereference_yn) && $probtrack(invxfm) == "" } { set errorStr "$errorStr You must specify the inverse transform!" } if { $probtrack(terminate_yn) && $probtrack(stop) == ""} { set errorStr "$errorStr You must specify the termination mask!" } if { $probtrack(output) == "" } { set errorStr "$errorStr You must specify the output basename!" } set flags "" @@ -732,6 +744,11 @@ proc fdt:apply { w dialog } { set flags "$flags --xfm=$probtrack(xfm)" puts $log "set probtrack(usereference_yn) $probtrack(usereference_yn)" puts $log "set probtrack(xfm) $probtrack(xfm)" + if { $probtrack(useNonlinear) } { + set flags "$flags --invxfm=$probtrack(invxfm)" + puts $log "set $probtrack(useNonlinear) $probtrack(useNonlinear)" + puts $log "set probtrack(invxfm) $probtrack(invxfm)" + } } if { $probtrack(exclude_yn) == 1 } { @@ -865,7 +882,8 @@ proc fdt:apply { w dialog } { set errorStr "" if { $registration(directory) == "" } { set errorStr "You must specify the bedpostX directory!" } if { $registration(struct_yn) && $registration(struct_image) == "" } { set errorStr "$errorStr You must specify the structural image!" } - if { $registration(standard_yn) && $registration(standard_image) == "" } { set errorStr "$errorStr You must specify the standard image!" } + if { $registration(struct_yn) && $registration(nonlin_yn) && $registration(nonlin_image) == "" } { set errorStr "$errorStr You must specify the non-betted structural image!" } + if { $registration(standard_yn) && == "" } { set errorStr "$errorStr You must specify the standard image!" } if { $errorStr != "" } { MxPause $errorStr return @@ -882,9 +900,13 @@ proc fdt:apply { w dialog } { set diff2str [ file join $registration(directory) xfms diff2str.mat ] set str2diff [ file join $registration(directory) xfms str2diff.mat ] set str2stand [ file join $registration(directory) xfms str2standard.mat ] + set str2stand_warp [ file join $registration(directory) xfms str2standard_warp ] set stand2str [ file join $registration(directory) xfms standard2str.mat ] + set stand2str_warp [ file join $registration(directory) xfms standard2str_warp ] set diff2stand [ file join $registration(directory) xfms diff2standard.mat ] + set diff2stand_warp [ file join $registration(directory) xfms diff2standard_warp ] set stand2diff [ file join $registration(directory) xfms standard2diff.mat ] + set stand2diff_warp [ file join $registration(directory) xfms standard2diff_warp ] set diff [ file join $registration(directory) nodif_brain ] if { $registration(struct_yn) } { set searchrx "-searchrx -$registration(struct_search) $registration(struct_search)" @@ -902,6 +924,12 @@ proc fdt:apply { w dialog } { fdt_monitor $w "${FSLDIR}/bin/convert_xfm -omat $stand2str -inverse $str2stand" fdt_monitor $w "${FSLDIR}/bin/convert_xfm -omat $diff2stand -concat $str2stand $diff2str" fdt_monitor $w "${FSLDIR}/bin/convert_xfm -omat $stand2diff -inverse $diff2stand" + if { $registration(nonlin_yn) } { + fdt_monitor $w "${FSLDIR}/bin/fnirt --in=$registration(nonlin_image) --aff=$str2strand --cout=$str2stand_warp --config=T1_2_MNI152_2mm" + fdt_monitor $w "${FSLDIR}/bin/invwarp -w $str2stand_warp -o standard2str_warp -r ${diff}_mask" + fdt_monitor $w "${FSLDIR}/bin/convertwarp -o $diff2stand_warp -r ${FSLDIR}/data/standard/MNI152_T1_2mm -m $diff2str -w $str2stand_warp" + fdt_monitor $w "${FSLDIR}/bin/convertwarp -o $stand2diff_warp -r ${diff}_mask -w $stand2str_warp --postmat=$str2diff" + } } } elseif { $registration(standard_yn) } { set searchrx "-searchrx -$registration(standard_search) $registration(standard_search)"