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'

'스크랩 > fMRIB(fsl)' 카테고리의 다른 글

fMRIB(FSL) 로 추적한 TRACT의 FA MEAN 구하기  (0) 2018.05.31

+ Recent posts