Initial Processing

From Pheno Wiki
Jump to: navigation, search

Back to LA5C

Data were initially processing using the setup_subjects script (created by Russ Poldrack).


About Setup Subjects

Data are transferred in DICOM format to a server after a scan is completed. setup_subject.sh is a script for the automatic transfer and conversion of data from BMC or CCN to func. setup_subject.sh transfers the raw DICOM files to func and converts these files into usable format, for use with FSL or other tools. This script runs on the Sun Grid Engine.

Usage

USAGE: setup_subject -b <base_dir> -g <group> -s <subject> -options

To check the progress of the script, look at the log files in the notes/ directory using the command more notefile.

Required Arguments

Required arguments:

-b base_dir: the project directory in which the subject's dir will be created (this MUST be an absolute path, i.e., starting with /)
-g group: the name of the group under which the scan was performed (this MUST be in lowercase, and must also match the account name under which the data are stored on DNS0)
-s subject: the subject code that was entered when scanning

Optional Arguments

Optional arguments:
[general flags]:

-t: run in test mode - don't execute commands

[processing operations]:

-c: run MCFLIRT motion correction on 4D image
-m: run MELODIC ICA on motion-corrected 4D image
-x: run BET on the motion-corrected 4D data
-w: Preprocess MP-RAGE (align, BET, and bias correction)
-D: Run raw data diagnostics
-z: name of file specifying definitions for MCFLIRT_ARGS and MELODIC_ARGS
-h: unwarp allegra MP-RAGE using MGH code (for Allegra 3T only)

[debabeler options]:

-d: skip debabeling
-j: location of debabeler .jar file

[data input options]:

-u username specify a username for dns0 account (defaults to group name)
-y: read data from dicom backup (for data collected prior to 9/17/05)

[file output options]:

-k: don't automatically delete DICOM data after conversion
-3: Keep 3D data after 4D conversion
-f: don't fix raw directory names (leave extra numbers)
-e: skip downloading of data from dns0 (assumes existing data)
-a: tag to denote BOLD directories (defaults to BOLD)
-q skip entry of DICOM info into database
-I specify a dicom server directory

[grid options]:

-G submit compute tasks to the Grid (default)
-L run Locally (do not submit compute tasks to the Grid)

Example Command Lines

Here are example command lines to run the script:

e.g. setup_subject_nifti -b /space/raid3/data/cannon/hbm_prodromal_vcap -g cannon -s 80023_00 -x -w -D -k
This command line would convert the data, keep the DICOM data (-k), skull-strip the data (-x), process the MP-RAGE (-w), and run diagnostics (-D).
e.g. setup_subject_nifti_swe -b /space/raid9/data/cannon/swe_twin_fmri -g cannonlab -s 2006600001 -c -x -D
This command line would convert the data, delete the converted DICOM data by default, motion-correct the data (-c), skull-strip the data (-x), and run diagnostics (-D).

You should always run setup subjects on the grid, so that it goes faster and doesn't hog the individual processors. For more detail on the grid, go here: Sun_Grid_Engine

Detail

Directories

Creates directory structure in the specified -b folder, including the subject directory and the subdirectories analysis/, behav/, dicom/, notes/, raw/:

/space/raid9/data/cannon/swe_twin_fmri/${subjectid}
/space/raid9/data/cannon/swe_twin_fmri/${subjectid}/dicom
/space/raid9/data/cannon/swe_twin_fmri/${subjectid}/raw
/space/raid9/data/cannon/swe_twin_fmri/${subjectid}/behav
/space/raid9/data/cannon/swe_twin_fmri/${subjectid}/analysis
/space/raid9/data/cannon/swe_twin_fmri/${subjectid}/notes
/space/raid9/data/cannon/swe_twin_fmri/${subjectid}/raw/EPI_aflab_run1
/space/raid9/data/cannon/swe_twin_fmri/${subjectid}/raw/EPI_aflab_run2
/space/raid9/data/cannon/swe_twin_fmri/${subjectid}/raw/EPI_stscap
/space/raid9/data/cannon/swe_twin_fmri/${subjectid}/raw/struct

Preprocessing

This script completes the following preprocessing steps:

  • Transfers raw data from BMC (cp -r) into the dicom/ directory. Need a BMC account, and to give your username -u.
  • Creates log file in subjectdir/notes/setup_log.date
  • Converts from DICOM to NIFTI (dcm2nii). Afterward, the script either deletes it or not, depending on the -k option.
  • Motion correction (mcflirt): registers each volume across time to the middle volume and makes motion parameter files and plots for each task to put into later analyses.
  • Brain extraction (bet and betfunc2)
  • Optional - run melodic
  • Create diagnostic .pdfs for each run of each task
  • Basic DTI analysis (calls proc_dti script, creates FA, MD, etc.)

Command Lines

To manually run the command lines in the script:

1. First copy the raw data recursively to the appropriate subject directory, using the command cp:

e.g. cp -r 2006600001 2006600001/dicom

2. Convert all DICOM files to NIFTI format, using the command dcm2nii:

dcm2nii ${DICOMDIRECTORY}
e.g. dcm2nii 001/

Copy the output of this file into the functional directories located in $SUBDIR/raw/.

3. Run motion correction and registration on all raw functional files, using the command mcflirt:

mcflirt -in ${SUBCODE}_${BOLDTAG}*${IMG_SUFFIX} -plots -report -mats
e.g. mcflirt -in 2006600001_EPI_stscap.nii.gz

4. Skull-strip all raw functional files and all motion-corrected, registered functional files, using the command betfunc2:

betfunc2 $FOUR_D_FILENAME_SHORT $BET_4D_FILENAME
e.g. betfunc2 2006600001_EPI_stscap.nii.gz 2006600001_EPI_stscap_brain.nii.gz
e.g. betfunc2 2006600001_EPI_stscap_mcf.nii.gz 2006600001_EPI_stscap_mcf_brain.nii.gz

5. Skull-strip the structural files, e.g. T2 or SPGR, using the command bet:

bet $SUBDIR/raw/struct/${SUBCODE}_t2.$IMG_SUFFIX $SUBDIR/raw/struct/${SUBCODE}_t2_brain.$IMG_SUFFIX
e.g. bet /space/raid9/data/cannon/swe_twin_fmri/2006600001/raw/struct/2006600001_t2.nii.gz /space/raid9/data/cannon/swe_twin_fmri/2006600001/raw/struct/2006600001_t2_brain.nii.gz