3dSkullStrip seems to change Sform and Qform of oblique datasets


I was testing a couple of options to skullstrip some MP2RAGE data, and I noticed that if I don’t deoblique the volume first, 3dSkullStrip changes the Qform and Sform in the header of the file - apparently rounding it up to 1 or down to 0.

See the attached files - the headers (skullstripped volume on the right) and the skullstripped volume (in blue-lightblue) over the original image (the green volume is the result of BET). Note that the voxel offset is also different in the headers.

Is there a way to avoid this behaviour? I am trying to avoid deobliquing the original files, in order to not introduce an extra interpolation in the data. Would overwriting the headers be a good move, or since the change in Qform and Sform happened already, it is too late?

Stefano Moia

Hi Stefano,
Hmm, it seems you are right about this. I haven’t tracked this down to where it happens inside 3dSkullstrip, but it’s not too bad a workaround using the recommended code for masking the original volume that comes at the end of its terminal output:

3dcalc -a anat_oblique.nii.gz -b anat_ns_notoblique.nii.gz -expr ‘a*step(b)’ -prefix anat_ns_oblique.nii.gz

The obliquity will come from the original dataset. The other way to do this is to use either nifti_tool to modify the header or 3dinfo to modify the AFNI header which propagates from AFNI’s IJK_TO_DICOM_REAL attribute down to the NIFTI header’s sform matrix.

3drefit -atrcopy IJK_TO_DICOM_REAL original_dset modified_dset

Thanks for letting me know about this. I’ll look into this some more.

I was reading this message because I had the same problem.
It seems that 3dZeropad does the same thing

3dZeropad changes the geometry, so that, at least, is an expected outcome.