3dLocalstat percentile output

Cheers AFNI users!

I am trying to produce a map of voxels ranked by percentile of local intensity using 3dLocalstat. While the distribution of ‘hot spots’ in the output stats map look correct, the output voxel values are not in terms of percentile (e.g. voxel corresponding to 50th percentile is not 0.5). Am I forgetting to set an additional modifying flag? Any help is appreciated!

3dLocalstat -nbhd ‘SPHERE(3)’ -stat perc:1:0:0.1 -mask ma.dilate2_3.nii -prefix t2_perc3.nii sub-${subject}_T2w.nii.gz

This particular use of 3dLocalstat may not be what you expect. The stat parameter here essentially computes a voxel value based on the bin step. Consider this example:

3dLocalstat -prefix testperc.nii.gz -nbhd ‘SPHERE(-5)’ -stat ‘perc:1:100:25’ func_slim+tlrc.‘[1]’

The stat format for the percentile uses “perc:start:stop:step” as its parameters all expressed in percent (not decimal fractions). This command computes the values at the 1%, 26%, 51% and 76%ile in a 5mm radius local neighborhood around each voxel. The output has 4 subbrick volumes. Switch among these with the Overlay panel control.

The median would be computed with either of these commands, and either would have only a single output subbrick volume (the start and stop are equal):

3dLocalstat -prefix testperc2.nii.gz -nbhd ‘SPHERE(-5)’ -stat ‘perc:1:100:25’ func_slim+tlrc.‘[1]’
3dLocalstat -prefix test_median.nii.gz -nbhd ‘SPHERE(-5)’ -stat ‘median’ func_slim+tlrc.‘[1]’

Thanks so much for clarifying the function’s behavior. I think I have a workaround based on your advice. Appreciate your help!