Flame without 1st level directories

FSL’s fMRI modelling tool, FEAT, is a great tool and is easy to use if you use FSL from start to finish, in the recommended fashion. However, sometimes you might want to get FEAT group results when you don’t have all of the individual 1st level FEAT directories. This tip is for the case when you have just the 4D COPE image and the 4D VARCOPE images (all subjects, of course, already in MNI space), and you just want to do a one-sample t-test.

In the code below, I’m assuming that the following files are around:

  • 4dcope 4D COPE image
  • 4dvarcope 4D VARCOPE image
  • design.mat, design.con and design.con for a 1-sample t-test; use Glm_gui if you need help creating these.
  • mask mask image
  • example_func an example image for ‘underlay’ in the figures
$FSLDIR/bin/flameo --cope=4dcope --vc=4dvarcope --mask=mask --ld=stats --dm=design.mat --cs=design.grp --tc=design.con --runmode=flame1
echo $($FSLDIR/bin/fslnvols 4dcope) - 1 | bc -l  > stats/dof
/bin/rm -f stats/zem* stats/zols* stats/mask*
$FSLDIR/bin/smoothest -d $(cat stats/dof) -m mask -r stats/res4d > stats/smoothness
rm -f stats/res4d*
awk '/VOLUME/ {print $2}' stats/smoothness > thresh_zstat1.vol
awk '/DLH/ {print $2}' stats/smoothness > thresh_zstat1.dlh
$FSLDIR/bin/fslmaths stats/zstat1 -mas mask thresh_zstat1
$FSLDIR/bin/cluster -i thresh_zstat1 -c stats/cope1 -t 2.3 -p 0.05 -d $(cat thresh_zstat1.dlh) --volume=$(cat thresh_zstat1.vol) --othresh=thresh_zstat1 -o cluster_mask_zstat1 --connectivity=26 --mm --olmax=lmax_zstat1_tal.txt > cluster_zstat1_std.txt
$FSLDIR/bin/cluster2html . cluster_zstat1 -std
MinMax=$($FSLDIR/bin/fslstats thresh_zstat1 -l 0.0001 -R)
$FSLDIR/bin/overlay 1 0 example_func -a thresh_zstat1 $MinMax rendered_thresh_zstat1
$FSLDIR/bin/slicer rendered_thresh_zstat1 -S 2 750 rendered_thresh_zstat1.png
/bin/cp $FSLDIR/etc/luts/ramp.gif .ramp.gif

You don’t get the full, pretty output from FEAT, but you do get a pretty PNG overlay, and the HTML table of significant clusters. Generalizing to more complicated group-level models is simply a matter of changing the design.mat and design.con files, and adjusting the degrees-of-freedom calculation on the second line.

This is really just a quick hack. I hope it is of some use.

Quick addition: The code above gives you corrected cluster-wise inference. To get corrected voxel-wise inference, replace the line with the ”$FSLDIR/bin/cluster” command with these four lines:

RESELcount=$(awk '$1~/VOLUME/{v=$2};$1~/RESELS/{r=$2};END{printf("%g",1.0*v/r)}' stats/smoothness)
FWEthresh=$(ptoz 0.05 -g $RESELcount)
$FSLDIR/bin/fslmaths thresh_zstat1 -thr $FWEthresh thresh_zstat1
$FSLDIR/bin/cluster -i thresh_zstat1 -c stats/cope1 -t $FWEthresh --othresh=thresh_zstat1 -o cluster_mask_zstat1 --connectivity=26 --mm --olmax=lmax_zstat1_tal.txt > cluster_zstat1_std.txt

Or, if you want to use an uncorrected threshold, use this snippet instead (replacing 2.3 with your favorite threshold).

UnCorrThresh=2.3
$FSLDIR/bin/cluster -i thresh_zstat1 -c stats/cope1 -t $UnCorrThresh --othresh=thresh_zstat1 -o cluster_mask_zstat1 --connectivity=26 --mm --olmax=lmax_zstat1_tal.txt > cluster_zstat1_std.txt

One thought on “Flame without 1st level directories

  1. Pingback: Flame without 1st level directories – copes only. | NISOx Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s