wiki

Manual First Level Feat

Setting-up First-level Analyses with FEAT

Note that if your runs have any differences in their design (e.g., differences in event timing), then you will need to conduct each first-level (i.e., run) analysis independently. This means that you will need to run FEAT six times if you have six distinct runs. You can automate some of the data input from this section by saving the FSF file after setting up the first run and then modifying it for the designs of the second runs.

Preprocessing

Design

Entering your design is the most complex aspect of FSL (and every other fMRI analysis program). For most of what we do, you should go to the Stats page, and then click Full Model setup. This will pop up yet another GUI, the General Linear Model.

You can change the paths to actual anatomical and functional data and click “GO” if you want to do a test run. A progress window will open up in a browser. For template creation, you will have to go through the design GUI and find all of the places where there will be variations between subjects and between runs. Usually you will need to change most of the file names in the script. These often include the output directory, the 4D data .hdr file, the anatomical image, and the files used for your model set-up when using the 3-column design. The norms for lab scripts could be as follows:

If you need to add anything (such as a T1) you can simply create a new variable name, and be sure to add it to be filled in by the bash script. The word that you choose should be in all caps, so that it doesn’t match any of the other words in the file. Also, be sure to leave the quotes around filenames there, only replace the path. ALWAYS write down your marker words somewhere.

Running First-level Analyses

Writing a batch script for FSL

If you have a lot of subjects or many runs to do the same analysis to, you will want to run a batch script to avoid tediously running the the rather slow FSL GUI. Batch scripts best work in a cluster environment where you can submit jobs and connect easily to your data.

We entered “ANAT” and “DATA” for our niftis for a reason. We will put all of our variables in a master python script, and this script will insert these variables into our bash template script. In the example above, the python would look for everyplace in the template that specified “ANAT” and replace this ANAT with the actual path.

The scripts PREPROCESS_FEAT.py (the python script) would tag team with PREPROCESS_FIGS_TEMPLATE.sh (the bash script), requiring:

See FSL fMRI Analysis for details on running this script with your template design.fsf (design file).

Coding Examples

NOTE that you do NOT need to make this from scratch for your design - we have templates under FSL fMRI Analysis. But you might want an explanation of this code! An example template used to batch FSL subjects for a FEAT run is shown below:

!/bin/bash
# the opening of the script that specifies that it is bash 

# Add a path to your workspace, so it can find fsl, for example
# loads the fsl program
export FSLDIR=/usr/local/packages/fsl
.  ${FSLDIR}/etc/fslconf/fsl.sh
 
# reading variables and setting paths
SUBJ=$1   # first input argument from command line
FSLDATADIR=~/some/path/here/Data/FSL/$SUBJ
ANATFILE=${FSLDATADIR}/anat.nii
 
# A for loop cycling through multiple runs
for run in 01 02 03 04; do
 OUTPUT=${FSLDATADIR}/run${run}_output
 DATA=${FSLDATADIR}/run${run}.hdr
 echo $OUTPUT

# makes the fsf files from the template fsf file
 for i in 'design.fsf'; do
  sed -e 's@OUTPUT@'$OUTPUT'@g' \
   -e 's@ANAT@'$ANATFILE'@g' \
   -e 's@ORIENT@'$ORIENT'@g' \
   -e 's@DATA@'$DATA'@g' <$i> ${FSLDATADIR}/FEAT_${run}.fsf
 done

# run the analysis using the newly created fsf file
 feat ${FSLDATADIR}/FEAT_${run}.fsf
done

The following details are some good tips, again from the Huettel wiki: \

Once you have completed first level analysis, don’t forget: