Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Siemens voxel oriented incorrectly with respect to structural MR #163

Open
PichardRarker opened this issue Jan 11, 2023 · 4 comments
Open

Comments

@PichardRarker
Copy link

Hi Suspect gurus.

I'm having trouble processing some Siemens Prisma data. If I use the following to co-register my MRS and T1-MRI data:

mrs = suspect.io.load_siemens_dicom("/path/to/mrs/dicom")
anat = suspect.image.load_nifti("/path/to/corresponding/t1.nii.gz")
voxel_mask = suspect.image.create_mask(mrs, anat)

... then the voxel is rotated 90 degrees compared to the true location (as confirmed using the voxel-T1 overlay DICOM image produced by the scanner). The oblong voxel is rotated, but still in the correct hemisphere (in other words, I cannot recover the true orientation via applying np.rot90 to the image voxel array)

Is there something I'm missing? Unfortunately I cannot share the data as it is from a clinical trial.

Best,

Rich

@bennyrowland
Copy link
Member

Hi @PichardRarker, sorry to hear you are having trouble with this. I always found the Siemens data formats to be annoyingly under specified in terms of orientation, and in particular my experience is mostly with either .RDA or TWIX formats, rather than Siemens DICOM, but it looks like you have got things correct. There are lots of things that could be going on, but without any data it is hard to narrow down the problem. When you say that the voxel is rotated, do you mean rotated about its center, or about the centre of the image, or the isocentre of the magnet? Are these images axial/sagittal/coronal? How did you convert the image slices to .nii?

Is this a one off or happening reliably on your data? Can you either obtain some shareable data or do some anonymisation of the data you do have? Without some kind of data it is going to be really hard to do more than suggest possible problems that you will have to investigate further.

@PichardRarker
Copy link
Author

PichardRarker commented Jan 13, 2023

Hi Ben,

Thanks for the detailed reply. I'm currently in talks with trial sponsor about getting permission to share some data with you. In the meantime, here are the answers to your questions, in case they are particularly informative:

do you mean rotated about its center, or about the centre of the image, or the isocentre of the magnet?

Rotated around the centre of the voxel, it seems. The true voxel location is the left-hemipshere putamen, with the longest axis of the oblong in the anterior-posterior plane. The voxel I'm seeing is still in the left hemisphere, but is rotated so that the longest axis runs left to right in real-world space.

Are these images axial/sagittal/coronal?

The T1 was acquired sagittaly

How did you convert the image slices to .nii?

An old build of dcm2nii (I can find find the exact build, if helpful). The conversion was run without reorienting the data (as is standard practice nowadays with dcm2niix). As part of my initial investigation I tried reorienting the T1 to match that of the MRS (by calling nibabel.aff2axcodes on the .transform attribute of the MRSData object, then reorienting the T1 accordingly) but this produced the same result

Best,

Rich

@bennyrowland
Copy link
Member

If the voxel appears rotated through 90 degrees about its own centre, the most likely thing is that the length/width/height of the voxel are being read into the wrong fields. This could be a bug in Suspect caused by only previously using square voxels with Siemens DICOM files, or it could be something more subtle relating to the voxel being planned sagittally (I am assuming the voxels were planned on the T1?) that is not being correctly taken into account.

Looking back at the code (io/siemens.py) I am reminded that Siemens specifies the voxel with a normal vector and a rotation angle in the plane. I don't believe this is enough information to uniquely specify a voxel, but I have never been able to get Siemens to confirm to me how to get the X/Y/Z vectors from the values they provide, and so everything is basically a best guess on my part, working with a small amount of data, and it looks like you have found something where it is different.

To work around this, you can probably just permute the columns of the transform of the MRS voxel to swap the two offending direction vectors over, everything else should then work correctly. If you fancy having a look at the loading code, I think this is the problem line:

x_vector = numpy.array([-1, 0, 0])

which needs to be different for sagittal voxels if we can figure out which voxels are sagittal/axial/coronal from some other data.

@PichardRarker
Copy link
Author

PichardRarker commented Jan 17, 2023

I think that did the trick! If I set the vector to [0, -1, 0], and additionally flip the sign of the in-plane rotation angle, I seem to recover the correction orientation

Thank you so much for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants