3dClusterize error - bad index

Hello! I’m hoping to get insight into an error I’m getting trying to run 3dClusterize. We ran our models in neuropointillist (in R), and then completed our cluster correction with 3dFWHMx/3dClustSim. We’re now trying to use 3dClusterize on our neuropointillist output with the command below:

3dClusterize -inset fl.modperson.tvalue.nii.gz -ithr 2 -idat 1 -mask mask.nii.gz -NN 1 -bisided -5 5 -clust_nvox 36 -pref_map ClusterMap_biTHR5nvox36 > attempt1

++ Neighborhood definition (NN=1) accepted
++ User input stat threshold: -5
++ User input stat threshold: 5
[b] FATAL ERROR: Bad index (too large) for data volume[/b]: 1
** Program compile date = Dec 11 2018

Any ideas why we are getting this error? Thanks in advance for any assistance!

Howdy-

Hmm, OK. I note that I am not familiar with neuropointillist.

My guess is that the input volume (fl.modperson.tvalue.nii.gz) has only 1 volume (or at least fewer than 2). What is the output of:


3dinfo -nv fl.modperson.tvalue.nii.gz

? That will state the number of volumes, and the largest index you can use will be: that number minus one.

With something like a t-test result output from an AFNI program, there are a couple of volumes of information—both a Coefficient (or beta weight) value for each voxel, and a (t-)statistic value for each voxel. There might also be an F-stat output, too. These are all glued together in a single volume, and you specify which one you want for something using the “sub-volume” or “sub-brick” index. If you have 3 volumes—an F-stat, a Coef and a t-stat—then you can specify each with index 0, 1 or 2, respectively.

Another nice thing about AFNI-produced stats datasets is that the degree of freedom information is put into the output header, too, so you can do stats-to-p and other conversions. I am a bit curious if neuropointillist has something like this (though I doubt it would be in AFNI-header format). Do you know how many pieces of info neuropointillist outputs (e.g,. both a coefficient and a corresponding stat?), and therefore how many volumes should be there?

If there is no PII in the dataset header, could you please output that, so we can see what is there:


3dinfo -verb fl.modperson.tvalue.nii.gz

From those pieces of info, we can try to decide what is best with the indexing.

–pt

Thanks so much for your response!

Here are the outputs of the two pieces of information you requested:
3dinfo -nv fl.modperson.tvalue.nii.gz:
1

3dinfo -verb fl.modperson.tvalue.nii.gz:
ataset File: fl.modperson.tvalue.nii.gz
Identifier Code: NII_G_PWJLmhH94Mzx_T7_pFLA Creation Date: Wed Aug 25 10:10:26 2021
Template Space: MNI
Dataset Type: Anat Bucket (-abuc)
Byte Order: LSB_FIRST {assumed} [this CPU native = LSB_FIRST]
Storage Mode: NIFTI
Storage Space: 1,301,300 (1.3 million [mega]) bytes
Geometry String: “MATRIX(-3,0,0,96.5,0,-3,0,132.5,0,0,3,-78.5):65,77,65”
Data Axes Tilt: Plumb
Data Axes Orientation:
first (x) = Left-to-Right
second (y) = Posterior-to-Anterior
third (z) = Inferior-to-Superior [-orient LPI]
R-to-L extent: -95.500 [R] -to- 96.500 [L] -step- 3.000 mm [ 65 voxels]
A-to-P extent: -95.500 [A] -to- 132.500 [P] -step- 3.000 mm [ 77 voxels]
I-to-S extent: -78.500 [I] -to- 113.500 [S] -step- 3.000 mm [ 65 voxels]
Number of values stored at each pixel = 1
– At sub-brick #0 ‘?’ datum type is float

Neuropointillist is an R based stats packaged developed for neuroimaging data. As it is R based, it is very flexible, allowing for more complicated modeling than traditional neuroimaging stats software. For the current model we are running, Neuropointillist outputs both a coefficient and a corresponding stats file - they are separate output files. I forgot that AFNI outputs these glued in a single volume where you have to specify the sub-brick (I have used AFNI in the past).

I believe that’s everything you asked for - let me know if you need any other pieces of information. Thanks for your help with figuring out what is best for our indexing!
-Nicole

Hi, Nicole-

Thanks for all that info. And indeed, I think you have diagnosed the issue: this is only a single, 3D dataset, and for separate idat and ithr values, one would need at least 2. So, you could concatenate the coefficient and stats dsets:


3dTcat -prefix DSET_CONCAT   DSET_COEF   DSET_STAT

… and then run an edited 3dClusterize command (note: the indexing here has to match the order of concatenation above):


3dClusterize -inset DSET_CONCAT -ithr 1 -idat 0 -mask mask.nii.gz -NN 1 -bisided -5 5 -clust_nvox 36 -pref_map ClusterMap_biTHR5nvox36 > attempt1

AFNI uses zero-based indexing (like Python, C, etc.), so the “first” volume is the [0]th volume, indexwise. (I believe R is one-based indexing.)

If you have questions about stats modeling in AFNI that might be useful, you could ping Gang, local statistician extraordinaire. But, if you are happy with Neuropointillist, that is cool, too.

–pt

Wonderful! Thank you so much for your help in diagnosing our problem.

Thanks again for your help!
Nicole

Hi, Nicole-

Rockin’, glad that helped.

–pt

Hello,

Hopefully a quick follow-up question: I was able to concatenate the files and run 3dClusterize (thank you!), however, we’re only able to get results for the positive threshold. We first tried to run it bi-sided, but we got an error (see attempt 1). We then tried running it as a right_tail 1 sided, and we got results, and everything looked as we expected (attempt 2). So then we tried to run it as a 1 sided, left tail, and we again received an error (attempt 3). When we look at our t file and change the thresholds accordingly, we can see negative results, so not sure why we’re not able to view these with 3dClusterize? Any ideas? Thank you!

Attempt 1:
3dClusterize -inset modperson_concat.nii -ithr 1 -mask mask.nii.gz -NN 1 -bisided -5 5 -clust_nvox 36 -pref_map ClusterMap_biTHR5nvox36 > attempt1
++ Neighborhood definition (NN=1) accepted
++ User input stat threshold: -5
++ User input stat threshold: 5
++ No extra data block input (via ‘-idat …’): using threshold dset for all computations and info.
++ Threshold volume: [1] ‘fl.modperson.tva[0]’
** FATAL ERROR: You are asking for multisided clustering on a single-sided stat!

Attempt 2:
3dClusterize -inset modperson_concat.nii -ithr 1 -mask mask.nii.gz -NN 1 -1sided RIGHT_TAIL 5 -clust_nvox 36 -pref_map RightSide_Person.nii > attempt1
++ Neighborhood definition (NN=1) accepted
++ User input stat threshold: 5
++ No extra data block input (via ‘-idat …’): using threshold dset for all computations and info.
++ Threshold volume: [1] ‘fl.modperson.tva[0]’
++ Opt code: 1sided,RIGHT_TAIL,5,clust_nvox,36,NN1
++ Reading in user’s mask
++ Threshold volume [1] does not appear to be a stat!
++ Sorting clusters by size.
++ Writing out map of cluster ROIs.
++ Output dataset ./RightSide_Person.nii

Follow up question: Should we be concerned that it states “Threshold volume [1] does not appear to be a stat!” - this is our t statistic volume?

Attempt 3:
3dClusterize -inset modperson_concat.nii -ithr 1 -mask mask.nii.gz -NN 1 -1sided LEFT_TAIL -5 -clust_nvox 36 -pref_map LeftSide_Person.nii > attempt2
++ Neighborhood definition (NN=1) accepted
++ User input stat threshold: -5
++ No extra data block input (via ‘-idat …’): using threshold dset for all computations and info.
++ Threshold volume: [1] ‘fl.modperson.tva[0]’
** FATAL ERROR: The Glen Rule applies here:
Can’t run a left-sided test on this stat, as it only has one (positive) side.

Follow up question:What does the [0] refer to in ‘fl.modperson.tva[0]’? (The t value was specified to be sub-brick 1, assuming that’s the ‘[1]’ before fl.mod…)

Thanks again for helping us get this all sorted!

Hi, Nicole-

A) Re. “Follow up question: Should we be concerned that it states “Threshold volume [1] does not appear to be a stat!” - this is our t statistic volume?”:
No, this should not be concerning. I guess I should change the message to be “…does not appear to be an AFNI-produced stat”. It is looking for header info created by AFNI programs when creating stats. Since this statistic volume came from outside software, it doesn’t bear any of those markings, which is fine. Sorry for this confusion.

B) Re. “Follow up question:What does the [0] refer to in ‘fl.modperson.tva[0]’? (The t value was specified to be sub-brick 1, assuming that’s the ‘[1]’ before fl.mod…)”:
So, the [1] in the output is describing the “ithr” index—which is correctly listed here.
The second part of that line in single quotes—what appears as ‘fl.modperson.tva[0]’—is the string “label” of the volume, which here does look a bit odd, but I don’t see how it has an affect. To verify this, what is the output of:


3dinfo -label modperson_concat.nii

? Normally, the label would be something descriptive—in an AFNI-produced dataset, for example, one might have something meant to codify what the item is (what kind of stat, or a coefficient) and where it came from (e.g., visual contrast, auditory contrast, visual - auditory contrast, etc.):
Full_Fstat
vis#0_Coef
vis#0_Tstat
vis_Fstat
aud#0_Coef
aud#0_Tstat
aud_Fstat
V-A_GLT#0_Coef
… etc.
I am not sure where the displayed string label would be coming from—but let’s see what the output of that 3dinfo command above is.

C) Re. the 1sided/2sided aspects:
Some statistics (like the F-stat) only have values zero and greater; others (like the Pearson correlation or t-stat) can be negative or positive. For the former, which are >=0, I believe only (rightward) 1sided testing is ever performed. For the latter, 2sided testing can be performed.

This program is complaining about running a 2sided test on somethign that looks like it only has values >=0 (so, like an F-stat), for which 2sided testing would be inappropriate. I am not sure what statistic your volume holds—what is it?

Also, to check the range of values, what is the output of:


3dinfo -dmin -dmax modperson_concat.nii'[1]'

When you are displaying your data–the modperson_concat.nii file–are you specifying the [1]th volume for both overlay and thresholding? Or is the [0]th volume the overlay, and the [1]th volume the thresholder? (In AFNI default file loading, I would expect the latter–we like to view the Beta weights or coefficients, and threshold based on the statistic, making use of both pieces of modeling information.)

–pt

A.) Ah, great. Thanks for the explanation.

B.) RE the [0] at the end of the fl.modperson.tva[0]
The output of 3dinfo -label modperson_concat.nii is:
fl.modperson.pva[0] | fl.modperson.tva[0]

So I’m assuming the [0] here is OK - it’s just referring the the fact that modperson.tva has 1 volume?

C.) Right. Our file is a t-stat file, so we should be able to see bi-sided results.
The output of 3dinfo -dmin -dmax modperson_concat.nii’[1]’ is:
-17.3254 999

As to the question: “When you are displaying your data–the modperson_concat.nii file–are you specifying the [1]th volume for both overlay and thresholding? Or is the [0]th volume the overlay, and the [1]th volume the thresholder?”

Originally we tried it the latter, as you stated, to make use of both pieces of information. However, when I got the bi-sided error, I tried running it the first way - with specifying hte [1]th volume for both overlay and thresholding. I got the same error.

Thanks so much for your help getting this figured out!

Hi, Nicole-

A) Cool.

B) Yes, you are correct.

C.) Huh, OK, I am a bit confused. In the code, the first check is whether the “ithr” volume is detected as being an AFNI-stats volume—if not, allow any sidedness of testing (the User Must Know All, about whether a given test is appropriate). The restrictions on sidedness-by-type-of-stat should only be coming from AFNI-created dsets, where we can be sure because of the header info. So, since your volume comes from non-AFNI, you should not be being hit by that error message…

What version of AFNI are you running? That is, what is the output of:


afni -ver

?

–pt

We are using version AFNI_18.3.16 ‘Augustus’

Oooooohhhhh, that is from The Ancient Times.

The modern sidedness-checking-and-allowing went in in April, 2020…

For this specific cases—and probably for many updates, improvements, fixes and new functionalities—updating your AFNI would be good:


@update.afni.binaries -d

You shouldn’t be having issue “C” with the modern code.

–pt

Yep! That fixed it! Glad it was just a version issue and not a problem with our files, etc. Thank again SO MUCH for all of your help!

Sure thing, glad that sorted it.

–pt