Calculating RAS locations directly from DICOM image tags (ImagePosition/ ImageOrientation)

Hello everyone,

I’m currently using 3D Slicer to identify microbleeds in brain MRIs, utilizing RAS coordinates provided in an accompanying Excel file. While manual identification works perfectly, automating the process with Python presents challenges. Specifically, the program inaccurately identifies slices due to discrepancies between the z-coordinate (SliceLocation or ImagePosition) in the DICOM files and the S coordinate from my Excel file.

Given a constant slice thickness of 4 mm, I attempted to correlate the S coordinate with ImagePosition without success. How can I accurately calculate RAS locations directly from ImagePosition or ImageOrientation in the DICOM metadata?

Thank you.

See computations in the script repository: Script repository — 3D Slicer documentation

If you want to jump to positions defined in an excel file then probably the simplest is to save the positions into a Markups control points table CSV file. You can drag-and-drop this file into Slicer and you can jump to a position in Markups module → Control points section. Set Jump SlicesCentered and then click on the point in the table.

1 Like

Thank you very much for your response.

The suggestion to utilize the Markups module in 3D Slicer for jumping to positions defined in an Excel file is very helpful for manual identification.

However,
when attempting to automatically spot microbleeds using Python scripts, the code prompts for RAS locations. Upon inserting the RAS locations, the code fails to correlate the S coordinate with the correct slice. Upon further investigation, I found that the inherent coordinates in the file metadata (such as ImagePosition and SliceLocation) differ from the S coordinate in my Excel file.

How can I effectively correlate the S coordinate with these metadata values? In other words, how can I teach the code to accurately locate the exact slice based on the entered RAS coordinates?

Your guidance would be greatly appreciated.

This entirely depends on who the S coordinate was calculated in your excel file. I.e. what software created the file. If these are MRI for example, if the ImageOrientationPatient vectors are not aligned with patient space the software will have needed to take this into account when calculating the RAS values.

2 Likes

Only ImagePositionPatient and ImageOrientationPatient DICOM tags are allowed to be used when determining physical location of a pixel of an image slice. SliceLocation field is not relevant for this. In head CTs, it is common to have slices with normals that are not parallel to the IS axis. In such images there is no one-to-one correspondence between ImagePositionPatient and slice number (S coordinate varies within a slice; and one S coordinate appears in several slices).

If RAS positions in your Excel file look correct in Slicer then the problem is in those Python scripts that prompt for RAS locations and don’t find the correct Slice.

1 Like

@lassoan @pieper

Thank you very much, gentlemen!