Difference in GUI points and 3dmaskdump


I am trying to access the value at a certain voxel using Nibabel. I have imported my AFNI image as a variable called “brik” and applied the get_fdata() to this to get the array containing all the values at each voxel coordinate. I.e.:

brik = nib.load(‘file.BRIK’)
data = brik.get_fdata()

At first I tried to access the value at a certain voxel by using the coordinates of the voxel I wanted coming from the GUI. However, when I used these coordinates, the values did not match up. I have my AFNI set into the default RAI coordinate system. Example:

according to the GUI, the value at 48 (sagittal/R-L view), 76 (coronal/A-P view), 50 (axial/I-S view) is 0.167815.
When I enter these into Nibabel like so: data[48][76][50]
I get a return value of: array([0.05748392])

I then ran 3dmaskdump on my entire image and looked up the coordinates. The value listed under the coordinates 48 76 50 was the same as Nibabel had shown, just too a few less decimals – 0.057484. So it looks like 3dmaskdump and Nibabel are agreeing, and that Nibabel is accessing the same thing as 3dmaskdump.

Is there something different about the coordinate system in the GUI and the coordinate system from 3dmaskdump that I am missing here? I should also note that the values at the origin voxel (for me – 45, 54, 45) agree between the GUI, 3dmaskdump, and Nibabel, but that seems to be the only instance where 3dmaskdump/Nibabel are the same as the GUI.



Yeah, I think you might want to use @xyz_to_ijk to convert an (x, y, z) coordinate location to (i, j, k) indices.

You dset coordinate view may be RAI (=DICOM), but your dataset orientation on the disk might not be (“3dinfo -orient DSET”). The first determines whether you report, say, “left” as a positive or negative coordinate; the second determines the order that rows/columns/slices of your matrices are stored on the disk and thereby what [i][j][k]th voxel corresponds to which physical location.

Note that in the AFNI “Graph” viewers, if your dset is a time series, you will see a set of “I: …”, “J: …”, and “K: …” values that would tell you that information, too.


Thanks so much for the suggestions! Looks like from 3dinfo that my data is in RPI not RAI. Weird! But the @xyz_to_ijk worked!