I’m attempting to use @animalwarper to apply warps to a series of atlases and such, however I’m consistently running into an error while 3dNwarpApply is being applied to a reference 5TT mask.
The first 4 layers appear to go just fine (as indicated by `mswr_01_modsmoo.nii.gz’ to  progressing just fine), however it reliably errors out on . Here’s the error message from that:
++ Voxel count of mask 'mswr_01_modsmoo.nii.gz' is (in mm): 0
** ERROR: zero voxels in mask 'mswr_01_modsmoo.nii.gz'
grep: rep_00004.txt: No such file or directory
grep: rep_00004.txt: No such file or directory
check_diff: Subscript out of range.
** ERROR: program failed (base2osh atl/seg foll, @dj)
... for dset: /media/dan/storage/gitDir/CMRR_NHP_DWI_PROC/minimalAtlases/5TT.nii.gz
If my understanding of the 5TT mask is correct, this would be the “pathology” layer, which, for a reference atlas, should be empty. As such, it’s not particularly surprising that it’s an empty mask with voxel count 0. Indeed it’s clear what in the AFNI code is triggering this error. Is there a way to force AFNI to just continue processing the empty volume without erroring?
I can think of an ugly way round this: just lopping off the last block of the 4th dimension in the 5TT mask, sending it through the warp, and then appending a block of zeros on to the post-warp output. However, I can’t really think of a concise way to do this using AFNI command line (which would be preferred, as this is part of a dockerized script).
What are my alternatives here?
I see… So, is it correct then that you have an atlas follower with multiple subvolumes, and one or more of these subvolumes might empty, systematically by design?
Let’s say it were a 10-subvolume (or 10 layer) atlas called DSET_ATLAS, so the volumes are selectable with zero-based indices  through , inclusively. Then if you know that volume  is always empty, you could provide it to the atlas follower option with subbrick selectors to skip the empty volume:
I might call that a “quick fix” or hacky way to get around the problem, because it would change the number of volumes in your output data. (As you note, you could stick back in an empty volume later.) It does seem a bit inelegant.
I have to take a deeper look at the code, but I could probably add an option whereby the “all zero dset output” would not exit the code. How would that be? For most people, I think having an all-zero output would be an error that should be brought to the attention dramatically, so I think that should still be default behavior. But how would that “override” option be?
Actually, can you please post your full @animal_warper command?
I am a little confused by the description of the 5TT dset, and would like to see whether it is a mask or an atlas_follower. No mask should have multiple subvolumes—
adjunct_aw_tableize_roi_info.py checks for this, and would error out if it were.
-skullstrip brainmask .. should only be followed by the name of a single volume dset.
Thanks for the response!
By design, the mrtrix 5TT format has 5 different layers corresponding to different tissue types. Typically, the last one (pathology) tends to be empty unless you’re dealing with a special case. This would be doubly true if you’re generating this 5TT object from an atlas (which presumably features no consistent pathology).
So to answer the question posed, yes, one of the sub-volumes is typically empty by design.
Insofar as the inelegant / hacky fix: that was basically the route I was thinking, but I didn’t know of straightforward AFNI commands to append an empty volume or extend an existing volume.
In a certain sense sense I’m kind of surprised that his hasn’t been encountered before (due to mrtrix ACT being fairly common). If I had to guess, it’s likely due to some of the unique characteristics of the inherited pipeline I’m converting and updating. I think typically, you would generate the 5TT mask from images that are in subject space already, so there would be no need to try and warp the thing from an atlas space to subject space. For the moment though, I’m just working with what I have.
I’d hate to add to increasingly complicated option lists, but the proposed option would likely work.
In the current script, the 5TT nifti is being passed with
-seg_followers, which, to my reading of the documentation, is essentially the same as
I’m not really clear as to what this dataset is. If each volume is essentially a probability of a tissue class, and not one that has an index value associated with every voxel, then you should use -template_followers instead. The interpolation would not use nearest neighbor interpolation, and there would be no modal smoothing on the output.