Created
March 22, 2013 15:35
-
-
Save anonymous/5222225 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################################## | |
##Running fsl from the command line | |
##some commands that I find useful | |
## | |
############################################################################################## | |
############################################################################################## | |
############################################################################################## | |
##Using the fslmaths and fslstats toolboxes | |
############################################################################################## | |
############################################################################################## | |
##To get the documentation for a the toolbox type | |
############################################################################################## | |
fslmaths | |
############################################################################################## | |
##divde two images in FSL | |
############################################################################################## | |
fslmaths 'image_1.nii.gz' -div 'image_2.nii.gz' 'output_image.nii.gz' | |
##you can also do things like subtract (-sub), add (-add), multiply (-mul) | |
############################################################################################## | |
##apply a mask to an image | |
############################################################################################## | |
fslmaths 'image_1.nii.gz' -mas 'mask.nii.gz' 'output_image.nii.gz' | |
############################################################################################## | |
##threshold an image to create a binary mask | |
############################################################################################## | |
##calculate the lower 15 percentile of an image, store as variable | |
thresh_it =`fslstats 'image_1.nii.gz' -P 15` | |
##threshold your image at this threshold to create a binary mask | |
fslmaths 'image_1.nii.gz' -thr $threshold_it -bin ../CSF_MASK/$subjscan | |
############################################################################################## | |
##calculate statistics on an image (mean, no indluding voxels with zeros) and store as variable | |
############################################################################################## | |
mean_nozeros=`fslstats 'image_1.nii.gz' -M` ##mean, not including voxels with zeros | |
mean_zeros=`fslstats 'image_1.nii.gz' -m` ##mean, including voxels with zeros | |
sd_nozeros=`fslstats 'image_1.nii.gz' -S` ##standard deviation, not including voxels with zeros | |
sd_zeros=`fslstats 'image_1.nii.gz' -s` ##standard deviation, including voxels with zeros | |
############################################################################################## | |
##do some calculations with these variables | |
############################################################################################## | |
fslmaths 'image_1.nii.gz' -sub $mean_nozeros -div $sd_nozeros | |
############################################################################################## | |
##create a gauss kernel of 10 mm and perform mean filtering | |
############################################################################################## | |
fslmaths 'image_1.nii.gz' -s 10 'output_image.nii.gz' | |
############################################################################################## | |
##erode a mask or image by zeroing non-zero voxels when zero voxels found in kernel | |
############################################################################################## | |
fslmaths 'mask.nii.gz' -kernel box 5x5x5 -ero 'output_image.nii.gz' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment