There are a couple ways to accomplish this, but it requires a short script. Here's an example using 3dTstat to calculate a mean for groups of sub-bricks and then 3dTcat to put the separate volumes back together. You might consider changing that to a median across sub-bricks if you like. Just change the one line in the script.
Also you can use 3dTsmooth to smooth across time, and that will compress better for screen display. Another alternative is to use 3dTsmooth and then 3dcalc using a dataset with a counted sub-brick list as input. These links do some similar extractions and time selections that might be of interest.
[
afni.nimh.nih.gov]
[
afni.nimh.nih.gov]
#!/bin/tcsh
# extract_time.csh
if ("$1" == '' || "$1" == "-help" || "$1" == "-h") then
echo "Usage: A script to reduce a 3D+time dataset by computing "
echo " a mean sub-brick every n-interval sub-bricks from an AFNI dataset"
echo ""
echo " `basename $0` nth-interval <dsetname>"
echo ""
echo "The output dataset is saved as dsetprefix_extract+orig"
echo ""
goto END
endif
set interval = $1
set dset = `@GetAfniPrefix $2`
set outdset = ${dset}_extract
set nvals = `3dnvals ${2}`
@ nvals--
set TR = `3dAttribute "TAXIS_FLOATS" ${2} |awk '{print $2}'`
set TR = `ccalc "${TR} * ${interval}"`
# statistical operation - 'mean', 'median' or other option for 3dTstat
set stattype = 'mean'
# remove any existing output and temporary files
rm -f temp_${dset}_${stattype}*
rm -f $outdset+orig.*
echo "Extracting sub-brick volumes from $2"
echo "taking mean every ${interval}th sub-brick"
foreach subbrick (`count 0 $nvals $interval`)
@ endval = $subbrick + $interval - 1
if ($endval > $nvals) then
@ endval = $nvals
endif
3dTstat -"${stattype}" -prefix temp_${dset}_${stattype}_${subbrick} \
${2}".[${subbrick}..${endval}]"
end
# put all the separate time points into a single dataset
3dTcat -prefix ${outdset} temp_${dset}_${stattype}*.HEAD
# update the TR with the expanded TR
3drefit -TR ${TR} ${outdset}+orig
# clean up - remove temporary files
rm -f temp_${dset}_${stattype}*
END: