User Tools

Site Tools


biac:fsl:guide

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
biac:fsl:guide [2012/12/12 17:50]
petty [making a template .fsf file]
biac:fsl:guide [2023/02/23 18:43] (current)
Line 100: Line 100:
 ====== III. Writing a batch script for FSL ====== ====== III. Writing a batch script for FSL ======
 If you have a lot of subjects or many runs to do the same analysis to, you may want to run a batch script to avoid tediously running the the rather slow FSL GUI.  Batch scripts should be written on golgi using nedit.  They use the bash scripting language that golgi uses.  before you start it is recommended you read a little on bash scripting [[http://pegasus.rutgers.edu/~elflord/unix/bash-tute.html|here]].  If you have a lot of subjects or many runs to do the same analysis to, you may want to run a batch script to avoid tediously running the the rather slow FSL GUI.  Batch scripts should be written on golgi using nedit.  They use the bash scripting language that golgi uses.  before you start it is recommended you read a little on bash scripting [[http://pegasus.rutgers.edu/~elflord/unix/bash-tute.html|here]]. 
-This script will run FEAT analysis, but requires 1)converted anat and func files and 2) a template. See [[biac:fsl:guide#I.Preparing for FSL|I.Preparing for FSL]] for file conversion. Example template shown below in this section.+This script will run FEAT analysis, but requires 1)converted anat and func files and 2) a template. See [[biac:fsl:guide#I.Preparing for FSL|I.Preparing for FSL]] for file conversion. Example template shown below in this section.  This script would read a template file, and replace the anat/output/data directories, then run feat. This script would be for running the analysis on the machine you are currently logged in to ... it would not be for submitting the the gridengine. For example cluster scripts see: [[biac:cluster:examples|BIAC Cluster Sample Scripts]] 
 Here's a sample **batchFSL** script:  Here's a sample **batchFSL** script: 
 +
 <code bash>#!/bin/bash <code bash>#!/bin/bash
 #for each subject you will have to modify this script for the number of runs and #for each subject you will have to modify this script for the number of runs and
Line 112: Line 114:
 #change this part #change this part
 SUBJ=$1 SUBJ=$1
-FSLDATADIR=~/net/katz/data/Reward.01/Data/FSL/$SUBJ +EXPDIR=`findexp Reward.01
-ANATFILE=${FSLDATADIR}/anatb.nii+FSLDATADIR=${EXPDIR}/Data/FSL/${SUBJ} 
 +ANATFILE=${FSLDATADIR}/anat_brain.nii
    
 ######### #########
  
 #makes the orient file #makes the orient file
-/home/gadde/bin/MkFlirtInitMtx.pl --in $FSLDATADIR/run02.bxh --stdref --o $FSLDATADIR/ORIENT.mat 
-ORIENT=$FSLDATADIR/ORIENT.mat 
 for run in 01 02 03 04; do for run in 01 02 03 04; do
  OUTPUT=${FSLDATADIR}/run${run}_output  OUTPUT=${FSLDATADIR}/run${run}_output
Line 128: Line 129:
   sed -e 's@OUTPUT@'$OUTPUT'@g' \   sed -e 's@OUTPUT@'$OUTPUT'@g' \
    -e 's@ANAT@'$ANATFILE'@g' \    -e 's@ANAT@'$ANATFILE'@g' \
-   -e 's@ORIENT@'$ORIENT'@g' \ 
    -e 's@DATA@'$DATA'@g' <$i> ${FSLDATADIR}/FEAT_${run}.fsf    -e 's@DATA@'$DATA'@g' <$i> ${FSLDATADIR}/FEAT_${run}.fsf
  done  done
Line 135: Line 135:
 done done
 </code> </code>
- 
 ===== making a template .fsf file ===== ===== making a template .fsf file =====
 when making a batch file, you need to have a template file that has the outline for your FEAT analysis. when making a batch file, you need to have a template file that has the outline for your FEAT analysis.
Line 161: Line 160:
   - now, remember those markers you set up in the template.fsf file?  For each one of those, you will need to make a variable that will replace it.  If the variable will change for each run, put it inside the loop.  Otherwise put it outside.   - now, remember those markers you set up in the template.fsf file?  For each one of those, you will need to make a variable that will replace it.  If the variable will change for each run, put it inside the loop.  Otherwise put it outside.
   - The line **echo $OUTPUT** in the example code prints out to the screen the output directory.  This just helps the user know how far along the program is.  You should probably include some sort of marker to let the user know how many analyses have been completed.   - The line **echo $OUTPUT** in the example code prints out to the screen the output directory.  This just helps the user know how far along the program is.  You should probably include some sort of marker to let the user know how many analyses have been completed.
-  - the line starting with **/home/gadde/bin** creates an image orientation file, which you can learn about [[biac:fslguide#fixing_problems_with_image_orientation|here]] 
   - now that you've set up variables for each of the markers in the template.fsf file, you will need to put those variables into the file.  The //sed command// helps with this.  I'm not sure why it is in a loop, but you can ask chris petty if you're curious.  This code is a revised version of something he wrote.  The sed program has many functions, but here we only need it to find the markers in the template.fsf file and replace them with the necessary text.   - now that you've set up variables for each of the markers in the template.fsf file, you will need to put those variables into the file.  The //sed command// helps with this.  I'm not sure why it is in a loop, but you can ask chris petty if you're curious.  This code is a revised version of something he wrote.  The sed program has many functions, but here we only need it to find the markers in the template.fsf file and replace them with the necessary text.
   - so, start out by copying the inner loop.  If you already copied it when you copied the outer loop, then don't copy it again.     - so, start out by copying the inner loop.  If you already copied it when you copied the outer loop, then don't copy it again.  
Line 171: Line 169:
  
  
-====== IV.Incorporating MELODIC analyses ====== 
-See also the [[http://www.fmrib.ox.ac.uk/fsl/feat5/detail.html#prestats|FEAT user guide]]: 
- 
-The MELODIC option runs the ICA (Independent Component Analysis) tool in FSL. This allows identification of structured noise in the fMRI data, which can be selectively removed to improve the FEAT results.  
-  * If you get an error "ERROR:: Environment variable FSLOUTPUTTYPE is not set! Please make sure that the appropriate configuration file is sourced by your shell (e.g. by putting it in .profile)." then you need to use the following commands: 
-<code>export FSLDIR=/usr/local/packages/fsl 
-. /usr/local/packages/fsl/etc/fslconf/fsl.sh</code> 
-You can add these commands to the profile using **nedit ~/.profile**. 
-  * Run Feat pre-stats processing only, by selecting Pre-stats from the top-right menu. Make sure you turn on MELODIC ICA in the Pre-stats section of the FEAT GUI. 
-  * Open the MELODIC report (feat_output_directory.feat/filtered_func_data.ica/report/00index.html) in a web browser and look through the components to identify those that you wish to remove; record the list of component numbers to remove. 
-  * In a terminal, run the MELODIC denoising, using the commands: 
-<code>cd feat_output_directory.feat 
-melodic -i filtered_func_data --mix=../run1.ica/melodic_mix --filter="1,2,3,4,5,6,7,8,9,11,13,14"</code> 
-where you should replace the comma-separated list of component numbers with the list that you previously recorded when viewing the MELODIC report. **This only takes 1-2 minutes.** 
-  * Now reopen the FEAT GUI and set the top-right menu to **Stats + Post-stats**.  
-  * Set the input data to be **feat_output_directory.feat/filtered_func_data+.ica/melodic_ICAfiltered** (The "+" is needed when you run ica as part of the first analyses, as suggested). By default the final FEAT output directory will be inside that second ICA output directory.  
  
 ====== V. Setting up Second-Level Analyses ====== ====== V. Setting up Second-Level Analyses ======
  
-  * Bring up a Golgi window in F-Secure SSH. 
-  * **cd /home/huettel/net/goldman/data/BIAC/Poker.01/data/FSL/31625**, or whatever directory you want to analyze. 
   * Type **fsl**. Click **FEAT**.   * Type **fsl**. Click **FEAT**.
   * Change the top left pull-down menu to **Higher-level analysis**.   * Change the top left pull-down menu to **Higher-level analysis**.
Line 203: Line 183:
 Your new analyses will be saved in a new directory called **across_runs.gfeat**. Your new analyses will be saved in a new directory called **across_runs.gfeat**.
  
-There is a good description of concepts behind higher-level analyses on the [[http://www.fmrib.ox.ac.uk/fsl/feat5/detail.html#higher|feat web manual]]. +There is a good description of concepts behind higher-level analyses on the [[http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FEAT/UserGuide#Setting_Up_Higher-Level_Analysis_in_FEAT|feat higher level analyis]].
- +
- +
-======= VI.Remaining Questions & Problems ======= +
- +
-Intermittent crashes on golgi, often suggesting an "out of memory" error. +
- +
- +
- +
-===== Registration ===== +
- +
-Registration is very poor for many of the spiral images +
-  * Should we correct for maximum image intensity in some way?  +
-  * Do we use ORIENT files? Registration seems dubious. +
- +
-It may be the case that if there is less than 120mm in any direction, then it will pop up the "partial FOV" error. That would be the case if we had relatively few slices or if the size of slizes were misrepresented.  +
- +
-===== Using ORIENT Files ===== +
- +
-The ORIENT file created by Syam Gyadde seems to give better registration results for data acquired with both spiral and EPI sequences. The file is a .mat file located in /home/gadde/bin/MkFlirtInitMtx.pl on Golgi, and it needs to be appropriately inserted once into the template.fsf script and several times into the batchFSL script. +
- +
-== ORIENT in template.fsf == +
- The last section of the template.fsf should read as follows: +
- +
-<code># Now options that don't appear in the GUI +
-# Alternative example_func image (not derived from input 4D dataset) +
-set fmri(alternative_example_func) "" +
- +
-# Delete GLM residuals? +
-set fmri(cleanup_residuals_yn) 1 +
- +
-# Initial structural space registration initialisation transform +
-set fmri(init_initial_highres) "" +
- +
-# Structural space registration initialisation transform +
-set fmri(init_highres) "" +
- +
-# Standard space registration initialisation transform +
-set fmri(init_standard) "ORIENT"</code> +
- +
-== ORIENT in batchFSL == +
-  +
-  * Before the **for** loop in the batch script begins, paste the following line: +
- +
-<code>#to convert from bxhheader to nifti  look in the fileconverter file in this directory +
-/home/gadde/bin/MkFlirtInitMtx.pl --in $FSLDATADIR/run2.bxh --stdref --o $FSLDATADIR/ORIENT.mat +
-ORIENT=$FSLDATADIR/ORIENT.mat</code> +
- +
-  * You will also need to define the variable name **ORIENT** in your sed list: +
-      <code>-e 's@ORIENT@'$ORIENT'@g' \</code> +
- +
- +
-===== MELODIC ICA ===== +
- +
- +
-===== Second-level Analyses ===== +
- +
  
-====== Troubleshooting ====== 
-=== Registration problems: === 
-  * Problem: the data is being registered as a large, stretched-out brain, going way beyond the bounds of a normal brain 
-    * Solution: check the .bxh  header files for your original functional data.  The scanner has recently been putting out functional images with voxel sizes for anatomical images.  change the x and y spacing to 3.75 
-  * Problem: the brain is being flipped so that the frontal lobe is near the cerebellum 
-    * Solution: run a BET brain extraction on the anatomical data.  See step 5 in the [[biac:fsl:guide#preparing_for_fsl|preparing for fsl]] section on how to do this 
-=== FEAT errors === 
-  * Problem: while running a batch script, all of the FEAT windows pop up at once even though the script is supposed to run them sequencially 
-    * Solution: open the script using nedit and find the line that starts with **feat** followed by some input files.  If there is an ampersand(&) at the end of that line, remove it and the process will be run sequencially.  If that doesn't solve the problem, the FEAT windows should be putting out an error 
-  * Problem: when running a batch script, the FEAT Watcher says that the number of volumes is 0 
-    * Solution: your script is pointing to a file that doesn't exist.  Open the FSL GUI and load the .fsf file that your script just created. If Danny wrote the script, it's located under the subject folder, called \\ FEAT_(runnumber).fsf e.g., **FEAT_1.fsf**.  Look at your 4D data files and find the .hdr files that were supposed to be analyzed. 
-  * Problem: when running a batch script, the FEAT Watcher says that the number of volumes is incorrect (not 0, see above) 
-    * Solution: the batch script is most likely using a template file that assumes that all of your runs have the same number of time points.  If one of the runs has a different number of time points, open the GUI, load your .fsf file.  The GUI will update the number of volumes automatically, so now you just hit go.  If the analysis still doesn't work, then ask scott or chris petty. 
-  * Problem: the run stopped, saying the problem was possibly golgi ran out of memory 
-    * Solution: 
biac/fsl/guide.1355334658.txt.gz · Last modified: 2014/08/04 16:03 (external edit)