Skip to main content
Home

Search form

  • Home
  • Calendar
  • People
    • Key Personnel
    • Members
    • Collaborators
  • Grants
  • Papers
  • Blogs
  • Wiki
  • Log In
Home / Some Useful FSL Commands

Some Useful FSL Commands

https://gist.github.com/anonymous/5222225

 

##############################################################################################
##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'
Tags: 
fsl commands

Navigation

  • Statistical methods
    • General
    • Causal Inference
    • Population ICA
    • PVD
    • Testing
    • Prediction / Machine Learning
    • Computation
    • Visualization
    • Structural PCA
  • Scientific areas of interest
    • Brain imaging - Variability
    • Brain Imaging - Prediction
    • Brain Imaging - Clinical
    • Wearable Computing
    • Biosignals
  • Software & Tutorials
  • Social media
  • Logos

Tags in Tags

brain imaging Cluster DICOM functional data intra class correlation neuroimaging NIFTI Parallel Computing R replication SMART wiki
More
© 2012 smart-stats.org