I imagine there is an easier way to make a mask for a p-value threshold given an f-stat subbrick.
Our strategy is to extract the statpar of the brick and use that with fift_t2p. I think we could also use e.g. stat2cdf(0.05,4,$ab,0) or cdf -p2t fift .005 14 882 | sed ‘s/t = //’.
Either way it seems like we are tripping over ourselves to extract and feed back data 3dcalc might already know – the stat parameters of the subbrik it is working on.
3dinfo $file'[5]'
# ...
# -- At sub-brick #0 'SEScomp:Time F' datum type is short: 0 to 32767 [internal]
# [* 0.00015631] 0 to 5.12182 [scaled]
# statcode = fift; statpar = 14 882
# ...
ab=$(3dinfo -verb $file"[5]"|
perl -lne 'print join(",", split(/\W+/,$1)) if m/statpar = (.*)/')
# 14,882
# calc mask: lower pval (converted from f) than threshold
3dcalc \
-prefix mask.nii.gz \
-f $file"[5]" \
-expr "step( 0.05 - fift_t2p(f,$ab) )" \
-overwrite \
-datum short