Greetings,
> On 15 Apr 2022, at 18:17,
lyam.m...@gmail.com <
lyam.m...@gmail.com> wrote:
>
> I am trying to load an fMRI dataset in native subject space, and mask the dataset with an ROI that is also in native (functional) space, using comso_fmri_dataset(ds_fname, 'mask', mask_fname). ds = the functional dataset, mask= the ROI.
>
> This returns an error: "voxel dimension mismatch between data and mask:max difference is 2.02620 > 0.00010"
>
> I dug into ds.a.vol.mat (loaded without a mask) and mask.a.vol.mat. Sure enough, the matrices are _slightly_ different (see attached images). My understanding is that values on the diagonal of .a.vol.mat are the XYZ dimensions (and these values match between ds and mask), so what are the first three values in the 4th column?
The .a.vol.mat field contains the voxel-to-world mapping information, which is contained in an affine transformation matrix. See for details
https://en.wikipedia.org/wiki/Transformation_matrix#Affine_transformations, expect that voxel data uses 3 dimensions instead of the 2 used in the wikipedia article. The first three values in the 4th column are the position offset. If you think of all voxels being contained in a box, then the coordinates of these three values are one of the eight corners; or more precisely one voxel away from one of the corners due to base-1 indexing.
>
> While debugging I tried copying those mis-matched values from ds.a.vol.mat into mask.a.vol.mat, and this allowed me to apply the mask as intended. So, it seems that the mis-matched values in .a.vol.mat are indeed the problem. Is it "safe" to hack this by copying over the values, or do I need to fix an underlying problem?
Copying the mis-matched values actually translates (moves) all voxels virtually. In your case about 0.5 mm in the first dimension and 2 mm in the second dimension. This does not seem ideal, and it would suggest something is not working ok in your processing pipeline. I would suggest you try to figure out how / where the difference in voxel position could happen.
Somewhat peculiar is the the position in the third dimension matches between functional volume and mask, if that were not the case I would have suspected you might have taken the mask from one participant’s brain and the functional data from another.
Best,
Nick.