3dresample makes mask smaller and 3dcalc does not binarize the mask in some cases

Hello,

I have two questions.

  1. I resampled a mask from T1 (1x1x1mm) space to functional (2.3x2.3x3.99) space using 3dresample (nearest neighbour interpolation). This cut off the mask in some areas and also made it smaller than the original mask. Using cubic interpolation, the mask looks better. Why does this happen with 3dresample?

  2. After creating the cubic interpolated mask, I used 3dcalc to binarize the mask using the boolean function but in some cases 3dcalc is setting voxel values to 0 even if the voxel has a value above 0 in the input image. Why does this happen with 3dcalc?

Thank you for your help.

Hi-

Can you please provide the 3dresample and 3dcalc commands you used? That will help.

--pt

And note that when resampling a mask onto a different grid (e.g. with 3dresample), one main aspect that might drive whether the mask gets larger or smaller is... luck. An ROI volume (nvoxels * voxel size) might go up or down, depending on how the new grid lands on top of the old grid, whether some of the new edge voxel centers just happen to land closer to original mask voxel centers, or closer to non-mask ones. Using cubic interpolation and truncating above zero will almost certainly make the new mask volume larger. What is better depends on your perspective.

3dfractionize is also an option for this operation.

  • rick
1 Like

Here is my 3dresample command for a given participant using the cubic interpolation:

3dresample -master ../func/sub-1003_task-facerep_run-01_bold_space-MNI152NLin2009cAsym_brainmask.nii.gz -prefix 3dresample_sub-1003_rmode.nii.gz -rmode Cubic -input sub-1003_output_warped_refT1anat.nii.gz

Here is my 3dcalc command for a given participant:

3dcalc -a '3dresample_sub-1003_rmode.nii.gz' -expr 'bool(a)' -prefix 3dresample_mask_sub_1003_rmode_binarized_bool.nii.gz

I forgot to also mention that I preciously used 'step(a)' instead of 'bool(a)' in the 3dcalc command; however, I found that bool(a) worked better.

Hi Rick,

Thank you for your help.

I tried 3dfractionize and it worked well; however, the same issue is happening when I apply 3dcalc to the mask to binarize it (3dcalc is setting voxel values to 0 even if the voxel has a value above 0 in the input image).

My afni version is 22.1.12.

Thanks again.