amongst extremes

Greetings,

I used 3dcalc with a very long list of parameters in an ‘amongst()’ expression. The program ran but the output was incorrect. I rewrote my code to split the expression into shorter ones and I get the expected result. Thought to let you know however, since this bug can go undetected.

To test, replace the ‘a’ dataset below with any aparc.a2009s+aseg_rank.nii and try:

Bad output due to large number of parameters:
3dcalc -a aparc.a2009s+aseg_rank.nii -expr ‘a*amongst(a,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192)’ -prefix bad.nii

Work around for correct output:
3dcalc -a aparc.a2009s+aseg_rank.nii -expr ‘a*step(amongst(a,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74)+amongst(a,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104)+amongst(a,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134)+amongst(a,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164)+amongst(a,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192))’ -prefix good.nii

Afni version: Precompiled binary macos_10.12_local: Jan 22 2019 (Version AFNI_19.0.01 ‘Tiberius’)

Cheers,
ZXu

Hi, ZXu-

Thanks for pointing that out. I had to deal with that with generating a couple commands in @SUMA_renumber_FS: For going through lots of FS ROIs, I used “equals(a,…)”, and for a smaller list, I could use “amongst(a,…,…,…)”. I think the magic number is between the number of ROIs in the FS-2000 and FS-2009 parcellations.

I used a Python loop to glue little strings of “equals(a,…)+” together, so it wasn’t too painful to construct.

And here it looks like you are selecting FS ROIs in a “rank” file by integer value, and not by label? I would be careful with that… the REN file output would be much more stable.

–pt

It looks like the parser might have a limit of 128 entries for evaluation in a single expression. Assuming there is indeed a fixed limit, I am not sure what we should go for, maybe 512? You seem to be using 150, perhaps. So is 256 too tight, begging for another round?

Such memory goes into many programs (AFNI and SUMA), but not all.

  • rick

That should probably be fixed or at least a warning show up. I will point out that the particular goal of the 3dcalc with the amongst operator could also be done now with a comma-separated list in the range selector. I haven’t tried for a very long list, so I’m not sure what the limits are for that.

3dcalc -a mydset’<2,3,5,7,10,…,1234>’ -expr a