f to p in 3dcalc

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

I am working on a little script to do this for you.

Currently it can be done with ClustExp_StatParse.py, but it was designed to do much more.
And you will have to provide all of the other required inputs for it to output a mask.
It will output a mask, thresholded at a specified p value.

See here:

I will just chop out the portion that outputs a p value thresholded mask and put it into separate script.
In the meantime, check out the Cluster Explorer.

Thanks, Justin