This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
epi_fieldmap_unwarping [2012/01/07 23:33] apersi |
epi_fieldmap_unwarping [2016/09/15 18:04] (current) |
||
---|---|---|---|
Line 7: | Line 7: | ||
The b0 field map acquisition is a Gradient Echo fieldmap sequence that takes 1 min. 4 sec. to run. Though this sequence can probably be found in other places, I recommend using the sequence that is in the protocol named below. | The b0 field map acquisition is a Gradient Echo fieldmap sequence that takes 1 min. 4 sec. to run. Though this sequence can probably be found in other places, I recommend using the sequence that is in the protocol named below. | ||
- Add the b0 field map sequence to your protocol by copying it over from this protocol: \user\research\thompson-schill\**COLORADAPTATIONS_bomap**. The name of the sequence is ' | - Add the b0 field map sequence to your protocol by copying it over from this protocol: \user\research\thompson-schill\**COLORADAPTATIONS_bomap**. The name of the sequence is ' | ||
- | - After adding | + | - After the sequence has been added to your protocol, make sure that these parameters match (meaning the b0 parameters should match the parameters for your epi runs): (number of) slices, slice thickness, field of view (FoV), and shim mode. All of these can be found on the " |
- Head coil does NOT matter. Use whichever you prefer. | - Head coil does NOT matter. Use whichever you prefer. | ||
===Unwarping using FUGUE=== | ===Unwarping using FUGUE=== | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | |||
+ | ===Unwarping at the command line=== | ||
+ | |||
+ | Below is a sample voxbo script that implements b0 unwarping. Please let me know if you have any questions. apersi@sas.upenn.edu | ||
+ | |||
+ | < | ||
+ | # | ||
+ | # SOFTWARE USAGE | ||
+ | # | ||
+ | # FSL -- / | ||
+ | # version 4.1 | ||
+ | # SPM2 -- / | ||
+ | # | ||
+ | # dcm2nii -- / | ||
+ | # | ||
+ | # | ||
+ | # used for the mri_convert command | ||
+ | # | ||
+ | # Bash shell script -- / | ||
+ | # Bash shell script -- / | ||
+ | # Bash shell script -- / | ||
+ | # | ||
+ | # IDL | ||
+ | # used to implement JJ Wang's perfusion and transit time analysis code | ||
+ | # | ||
+ | # | ||
+ | |||
+ | |||
+ | ####### | ||
+ | # Settings | ||
+ | ######## | ||
+ | |||
+ | LOGGING 2 | ||
+ | globals thresh=200 | ||
+ | globals xa=1 | ||
+ | globals ya=1 | ||
+ | globals za=1 | ||
+ | globals xf=3 | ||
+ | globals yf=3 | ||
+ | globals zf=3 | ||
+ | |||
+ | globals refvol=/ | ||
+ | globals paramfile=SPM2_MNI_params.mat | ||
+ | |||
+ | globals " | ||
+ | globals " | ||
+ | globals " | ||
+ | |||
+ | ####### | ||
+ | # Reset any previous attempts to run this script | ||
+ | ####### | ||
+ | |||
+ | runonce shellcommand "if [ -d Anatomy/raw ]; then mv -f */raw/* ./; fi" | ||
+ | runonce shellcommand "if [ -d models ]; then rm -rf models; fi" | ||
+ | runonce shellcommand "if [ -d Anatomy ]; then rm -rf Anatomy; fi" | ||
+ | rUnonce shellcommand "if [ -d $Subject_* ]; then rm -rf $Subject_*; fi" | ||
+ | runonce shellcommand "if [ -d b0map/ | ||
+ | runonce shellcommand "if [ -d b0map/ | ||
+ | runonce shellcommand "if [ -d b0map ]; then rm -rf b0map; fi" | ||
+ | runonce shellcommand "if [ -d DTI ]; then rm -rf DTI; fi" | ||
+ | runonce shellcommand "if [ -d Perfusion_pCASL ]; then rm -rf Perfusion_pCASL; | ||
+ | |||
+ | |||
+ | ####### | ||
+ | # Prepare Anatomy directory | ||
+ | # - Create directories | ||
+ | # - Move DICOM images into the raw directory | ||
+ | # - Create Functional.cub from ScoutEPI | ||
+ | # - Create Anatomical.cub from MPRAGE | ||
+ | # - Move " | ||
+ | ######## | ||
+ | |||
+ | runonce shellcommand "mkdir -p Anatomy" | ||
+ | runonce shellcommand "mkdir -p Anatomy/ | ||
+ | runonce shellcommand "mkdir -p b0map" | ||
+ | runonce shellcommand "mkdir -p b0map/ | ||
+ | runonce shellcommand "mkdir -p b0map/ | ||
+ | runonce shellcommand "mv $b0mag b0map/ | ||
+ | runonce shellcommand "mv $b0phase b0map/ | ||
+ | runonce shellcommand "mv $Loc Anatomy/ | ||
+ | |||
+ | runonce shellcommand " | ||
+ | runonce shellcommand "mv $ScoutEPI Anatomy/ | ||
+ | runonce shellcommand " | ||
+ | runonce shellcommand "mv $MPRAGE Anatomy/ | ||
+ | |||
+ | ####### | ||
+ | # Prepare scout images | ||
+ | # These are images to be used for co-registration and for | ||
+ | # subsequent spatial normalization. They are generated for | ||
+ | # the pCASL and DTI data | ||
+ | ######## | ||
+ | |||
+ | runonce shellcommand " | ||
+ | runonce shellcommand " | ||
+ | |||
+ | ##### | ||
+ | # Align origins of functional, perfusion, DTI, and anatomical data | ||
+ | ##### | ||
+ | |||
+ | runonce shellcommand " | ||
+ | runonce shellcommand " | ||
+ | runonce shellcommand " | ||
+ | runonce shellcommand " | ||
+ | runonce shellcommand " | ||
+ | |||
+ | |||
+ | ##### | ||
+ | ## Get b0 field map, to be used later to unwarp the epi runs | ||
+ | # Convert Phase images to radians. | ||
+ | # Unwrap the phase images | ||
+ | # Get the fieldmap in radians | ||
+ | ##### | ||
+ | |||
+ | ### dicom2niftii | ||
+ | |||
+ | runonce shellcommand "/ | ||
+ | runonce shellcommand "/ | ||
+ | runonce shellcommand " | ||
+ | runonce shellcommand " | ||
+ | runonce shellcommand "mv -f b0map/ | ||
+ | runonce shellcommand "rm -f b0map/ | ||
+ | runonce shellcommand "mv -f b0map/ | ||
+ | runonce shellcommand "mv -f b0map/ | ||
+ | |||
+ | shellcommand "/ | ||
+ | shellcommand "mv -f $raw/ | ||
+ | |||
+ | |||
+ | # Convert Phase images to radians. Move orig phase 1 and 2 to raw dir. | ||
+ | |||
+ | runonce shellcommand " | ||
+ | runonce shellcommand " | ||
+ | runonce shellcommand "mv b0map/ | ||
+ | runonce shellcommand "mv b0map/ | ||
+ | |||
+ | |||
+ | # Unwrap the phase images | ||
+ | |||
+ | runonce shellcommand " | ||
+ | runonce shellcommand " | ||
+ | runonce shellcommand "mv b0map/ | ||
+ | runonce shellcommand "mv b0map/ | ||
+ | |||
+ | # Get the fieldmap in radians | ||
+ | |||
+ | runonce shellcommand " | ||
+ | runonce shellcommand "mv b0map/ | ||
+ | runonce shellcommand "mv b0map/ | ||
+ | |||
+ | # Unwarp ScoutEPI | ||
+ | |||
+ | runonce shellcommand "fugue -i b0map/ | ||
+ | |||
+ | # Coregister the ScoutEPI to the Anatomical image | ||
+ | |||
+ | runonce shellcommand "/ | ||
+ | |||
+ | runonce shellcommand "/ | ||
+ | |||
+ | runonce shellcommand "mv b0map/ | ||
+ | runonce shellcommand "rm -f b0map/ | ||
+ | runonce shellcommand "rm -f b0map/ | ||
+ | |||
+ | |||
+ | runonce shellcommand " | ||
+ | |||
+ | |||
+ | # Unwarp epi runs | ||
+ | |||
+ | shellcommand "fugue -i b0map/ | ||
+ | |||
+ | |||
+ | # run motion correction on epis | ||
+ | |||
+ | shellcommand " | ||
+ | |||
+ | # Clean up b0 directory | ||
+ | |||
+ | shellcommand "mkdir $Subject_$scan" | ||
+ | shellcommand "mkdir $Subject_$scan/ | ||
+ | shellcommand "mv $raw $Subject_$scan/ | ||
+ | shellcommand " | ||
+ | shellcommand " | ||
+ | shellcommand "rm -f b0map/ | ||
+ | shellcommand "mv b0map/ | ||
+ | runonce shellcommand "mv b0map/ | ||
+ | runonce shellcommand "mkdir b0map/ | ||
+ | runonce shellcommand "mv b0map/ | ||
+ | runonce shellcommand "mv b0map/ | ||
+ | |||
+ | |||
+ | ##### | ||
+ | # Process the Anatomical volume | ||
+ | ##### | ||
+ | |||
+ | # Store the original anatomical | ||
+ | |||
+ | runonce shellcommand "cp Anatomy/ | ||
+ | |||
+ | # Convert the Anatomical.cub file to Anatomical.nii | ||
+ | |||
+ | runonce shellcommand " | ||
+ | |||
+ | # Perform noise reduction, skull-stripping and inhomogeneity correction with FSL tools | ||
+ | |||
+ | runonce shellcommand "/ | ||
+ | runonce shellcommand "/ | ||
+ | |||
+ | runonce shellcommand " | ||
+ | runonce shellcommand " | ||
+ | runonce shellcommand " | ||
+ | |||
+ | runonce shellcommand "/ | ||
+ | |||
+ | # Gunzip the files | ||
+ | |||
+ | runonce shellcommand " | ||
+ | |||
+ | # Wrap the skull back around the inhomogeneity corrected brain volume | ||
+ | |||
+ | runonce shellcommand "vbim -i Anatomy/ | ||
+ | runonce shellcommand "vbim -i Anatomy/ | ||
+ | runonce shellcommand "vbim -i Anatomy/ | ||
+ | |||
+ | # Convert the Anatomical.nii file to Anatomical.cub | ||
+ | |||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | runonce shellcommand " | ||
+ | runonce shellcommand "vbhdr -c Anatomy/ | ||
+ | |||
+ | # Clean-up | ||
+ | |||
+ | runonce shellcommand "mv Anatomy/ | ||
+ | |||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | |||
+ | ##### | ||
+ | # Create the " | ||
+ | ##### | ||
+ | |||
+ | runonce shellcommand " | ||
+ | |||
+ | #### | ||
+ | # Co-register each of the scout images (pCASL, DTI) to | ||
+ | # the functional scout volume | ||
+ | # | ||
+ | # The header of the Functional.cub must be copied onto the | ||
+ | # resliced (coregistered) file to preserve origin info | ||
+ | #### | ||
+ | |||
+ | runonce shellcommand " | ||
+ | |||
+ | runonce shellcommand " | ||
+ | runonce shellcommand " | ||
+ | |||
+ | runonce shellcommand "/ | ||
+ | runonce shellcommand "/ | ||
+ | |||
+ | runonce shellcommand " | ||
+ | runonce shellcommand " | ||
+ | |||
+ | runonce shellcommand " | ||
+ | runonce shellcommand " | ||
+ | |||
+ | runonce shellcommand "vbhdr -c Anatomy/ | ||
+ | runonce shellcommand "vbhdr -c Anatomy/ | ||
+ | |||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | |||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | runonce shellcommand "rm Anatomy/ | ||
+ | |||
+ | |||
+ | ##### | ||
+ | # Perform normalization of anatomicals and scouts (Functional, | ||
+ | ##### | ||
+ | |||
+ | runonce spm2_norm_calc $DIR/ | ||
+ | runonce spm2_norm_apply3d $DIR/ | ||
+ | runonce spm2_norm_apply3d $DIR/ | ||
+ | runonce spm2_norm_apply3d $DIR/ | ||
+ | runonce spm2_norm_apply3d $DIR/ | ||
+ | runonce spm2_norm_apply3d $DIR/ | ||
+ | |||
+ | |||
+ | ####### | ||
+ | # Process the pCASL data | ||
+ | # - Prepare Perfusion_pCASL directory | ||
+ | # - convert non-moco pCASL series to TES file | ||
+ | # - Call JJ Wang's IDL code via a bash shell script | ||
+ | # - extract the CBF image from the output (the third image of the tes file) | ||
+ | # - move the processed files into sub-directories | ||
+ | # - convert the CBF volumes to ANALYZE format | ||
+ | # - reslice the CBF images to the functional space using FLIRT | ||
+ | # - use Freesurfer MRI convert to change the replaced file to ANALYZE | ||
+ | # - convert CBF volumes to images, then cubs, and put the processed files away | ||
+ | # - spatially normalize the CBF cub images using SPM | ||
+ | # - remove the un-needed files | ||
+ | ####### | ||
+ | |||
+ | runonce shellcommand "mkdir -p Perfusion_pCASL" | ||
+ | runonce shellcommand "mkdir -p Perfusion_pCASL/ | ||
+ | runonce shellcommand " | ||
+ | runonce shellcommand "mv $RestpCASL Perfusion_pCASL/ | ||
+ | runonce shellcommand "mv $moco_RestpCASL Perfusion_pCASL/ | ||
+ | |||
+ | runonce shellcommand "sh / | ||
+ | |||
+ | runonce shellcommand " | ||
+ | runonce shellcommand "mkdir Perfusion_pCASL/ | ||
+ | runonce shellcommand "mv Perfusion_pCASL/ | ||
+ | runonce shellcommand "mv Perfusion_pCASL/ | ||
+ | |||
+ | runonce shellcommand " | ||
+ | |||
+ | |||
+ | runonce shellcommand "/ | ||
+ | runonce shellcommand64 " | ||
+ | |||
+ | runonce shellcommand " | ||
+ | |||
+ | runonce spm2_norm_apply3d $DIR/ | ||
+ | |||
+ | runonce shellcommand "rm Perfusion_pCASL/ | ||
+ | runonce shellcommand "rm Perfusion_pCASL/ | ||
+ | runonce shellcommand "rm Perfusion_pCASL/ | ||
+ | runonce shellcommand "rm Perfusion_pCASL/ | ||
+ | runonce shellcommand "rm Perfusion_pCASL/ | ||
+ | runonce shellcommand "rm Perfusion_pCASL/ | ||
+ | |||
+ | |||
+ | ####### | ||
+ | # Prepare the DTI data | ||
+ | # At present, this involves simply | ||
+ | # involves moving the data into | ||
+ | # a top-level DTI directory | ||
+ | ####### | ||
+ | |||
+ | runonce shellcommand "mkdir -p DTI" | ||
+ | runonce shellcommand "mkdir -p DTI/ | ||
+ | |||
+ | runonce shellcommand "mv $DTI1 DTI/ | ||
+ | runonce shellcommand "mv $DTI2 DTI/ | ||
+ | |||
+ | |||
+ | ###################### | ||
+ | # process the tes file | ||
+ | ###################### | ||
+ | |||
+ | shellcommand " | ||
+ | # | ||
+ | spm2_norm_apply4d $DIR/ | ||
+ | shellcommand " | ||
+ | threshold $Subject_$scan/ | ||
+ | calcgs $Subject_$scan/ | ||
+ | calcps $Subject_$scan/ | ||
+ | |||
+ | ###################### | ||
+ | # Create a models directory | ||
+ | # Create the average power spectrum and one-over-f file | ||
+ | ##################### | ||
+ | |||
+ | runonce shellcommand "mkdir -p Models" | ||
+ | runonce shellcommand "vbfit 3000 150 $Subject_01/ | ||
+ | |||
+ | </ | ||
+ |