Dear FSL-users,
I am looking for a method that allows to combine shell scripting with searching for the maximum z-value in an image and gives that particular voxel the value 1 whereas all other voxels should get value 0 (so that I can add a sphere to that image centered at that particular voxel).
I have used the cluster command, but this method marks all (local) maxima, not only the unique global one. For this reason I tried to subsequently use the "fslmaths -thr" command that reads the global maximum value found by "fslstats -r". However, this method seems not to be bug free. Once in a while the thresholding does not work correctly and the maximum voxel gets value 0 rather than 1.
Please find below the code I have used. Is there an easier and bugfree method to use?
Thanks in advance.
Henk van Steenbergen
Leiden University, The Netherlands
=========================================================
# FIND LOCAL MAXIMA
cluster --zstat=zstat_std_masked --zthresh=0 --olmaxim=zstat_std_masked_maxes
# MULTPILY VOXEL MARKED AS LOCAL MAXIMA (=1) WITH ORIGINAL Z VALUE
fslmaths zstat_std -mul zstat_std_masked_maxes zstat_std_masked_maxes_z
# FIND GLOBAL MAX
fslmaths zstat_std_masked_maxes_z -thr `fslstats zstat_std_masked_maxes_z -r | awk '{print $2}'` -bin zstat_std_masked_maxpnt
# SPHERE AROUND GLOBAL MAX
fslmaths zstat_std_masked_maxpnt -kernel sphere 6 -fmean -bin INDIVROI_zstat
|