converting 3D+time files to binary time courses

Hi,

We would be most grateful for assistance with the following issue. We’d like to take a 3d+time file for a single participant (used as input to 3dDeconvolve and 3dREMLfit; normalized, smoothed, clipped, etc.) and transform the BOLD signal for each voxel’s time course into a binary sequence, where a 1 at each time point indicates that the BOLD signal was above a threshold, and 0 indicates that it was below. In other words, we want to create a parallel 3D+time file with binary time courses instead of continuous ones. The reason that we want to do this is so that we can assess the breadth of activation in an ROI, relative to baseline, rather than the ROI’s average activation intensity.

We’d also like to have the flexibility of setting different thresholds, so that we can assess the implications of using different ones. In general, the threshold would be some level of “significance” above the baseline model, at each time point, for each voxel. So, for example, we could define 1 as a voxel showing a BOLD level at a time point that occurs less than 5% of the time in the upper tail of activations for the baseline condition. Alternatively, we could define 1 as an activation occurring <.1% or <20% of the time in the upper tail for the baseline.

We’ve been exploring AFNI tools for how to do this. We could perhaps use 3dmaskdump to create a file with time courses for all voxels in it, which could then be processed to produce a binary version. I’m not sure then, though, how to get this back into a 3d+time image file.

We can also see that –Rbeta for 3dREMLfit produces a baseline model in the beta bucket, specified as polart coefficients that capture the drift in the baseline over time in a given voxel. We can also see that the mean and SD of each voxel time course appears in Graph panels of the AFNI window, which could also be used for this purpose. Perhaps these sources of information could be easily recruited to create the files we’re after.

What we wonder, though, is whether there is a relatively simple and straightforward way to produce the desired files using existing AFNI programs that has escaped our search (such as using 3dSynthesize, 3dcalc, 3dmaskave, 3dttest++, etc.).

Again, we’d be most grateful for any assistance.

Best regards, Larry Barsalou

We could perhaps use 3dmaskdump to create a file with time courses for all voxels in it, which could then be
processed to produce a binary version. I’m not sure then, though, how to get this back into a 3d+time image file.

For this part, use 3dUndump.

Thanks so much, Gang! L

Actually, in thinking about this a little more, I want to be sure that I understand what you’re saying, Is it that what we want to do isn’t possible using existing AFNI tools, such that we need to capture all the time courses using 3dmaskdump and compute everything outside AFNI? We understand if this is the case, but just want to be sure before we attempt to reconstruct the baseline, map the stim_times files into the raw time series, etc. ourselves. Reconstructing what AFNI does is beyond what we had in mind.

What we’re trying to do is something like AM regression on the breadth of activation in an ROI, rather than on the average intensity. In other words, we want to correlate behavioral regressors with the number of voxels active above baseline in an ROI over time, rather than with their average intensity. This is why we want to convert the continuous time series in 3D+time files to binary time series. We’ve been finding in current work that breadth of activation in an ROI above baseline tends to be more informative than intensity, but at the 3D level without time. We now want to check this out for 3D+time, and see if it’s true for AM regression as well.

Any further thoughts on what we’re trying to do would be most appreciated.

Thanks again, Larry

Hi, Larry-

I don’t have a full picture of what you want to do, but here are some pieces that sound like they would be appropriate. These are just a couple programs just a couple example usages of each.

You can binarize a dset with something like 3dcalc. Let’s say you want to input a volumetric (3D or 4D) dset INFILE and output a volume of the same size where there is a 1 wherever a voxel in INFILE was greater than some value, say >T. This could be done with either of the following:


3dcalc -a INFILE -expr "step(a - T)" -prefix OUTFILE
3dcalc -a INFILE -expr "ispositive(a - T)" -prefix OUTFILE

You could also binarize based on being less than a value (make a 1 where a value <T):


3dcalc -a INFILE -expr "step(T-a)" -prefix OUTFILE
3dcalc -a INFILE -expr "ispositive(T-a)" -prefix OUTFILE

… or based on having an absolute value of a voxel greater than T (|value| > T):


3dcalc -a INFILE -expr "step(abs( a- T))" -prefix OUTFILE

If you want to find what a value in 3D volume corresponding to the, say, 98%ile of values in that volume, you can use 3dBrickStat:


3dBrickStat -percentile 98  1 98 INFILE

The 3 arguments after ‘-percentile …’ are START STEP STOP; hence, this will just give you the 98%ile value (but you could output a range if you changed the start or stop value). This will output 2 numbers: first, your percentile (here, 98.000) and second the value (whatever it calculates).

If you want the 98ile of values within a specific ROI or MASK, you can input that file as MMM and use:


3dBrickStat -percentile 98  1 98 -mask MMM  INFILE

If you want the distribution that the percentile is taken from to ignore 0-valued voxels, you can include a “-non-zero” flag:


3dBrickStat -percentile 98  1 98 -mask MMM  INFILE
3dBrickStat -non-zero -percentile 98  1 98 -mask MMM  INFILE

Here is also a clustered list of AFNI programs, that might be useful:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/educational/classified_progs.html

–pt

Actually, I do have question. Is there a way to create a file that contains the betas for the baseline model? Or does it already exist somewhere? If I understand correctly, I can see the polort parameters for the baseline in the -Rbeta file, but is there a way actually turn these into a 3D+time volume of betas for the baseline?

Thanks again for your help, Larry

I can see the polort parameters for the baseline in the -Rbeta file, but is there a way actually turn these
into a 3D+time volume of betas for the baseline?

I cannot find the option -Rbeta, but there is an option -bout in 3dDeconvolve that provides the baseline regression coefficients and their t-statistics in the output. You can then extract any of those sub-bricks using -3dbucket.