Discrepancy in Image Origin Values between 3D Slicer and SimpleITK

Hi all,

I’m encountering an issue when loading a label in 3D Slicer. The image origin is displayed as follows: -8.7478mm, -66.3176mm, -70.4628mm. However, when I read the same label using SimpleITK, I get an output of (8.74779987335205, 66.31759643554688, -70.46279907226562). Additionally, I’m experiencing a similar problem with the IJK TO RAS DIRECTION MATRIX; in 3D Slicer, values that are +1 appear as -1 in SimpleITK.

Could someone please shed light on why this might be happening?

Thanks in advance!

This info should help: Coordinate systems — 3D Slicer documentation

Thanks for your prompt response. I think I may not have explained what I need properly. When I load the same Nifti file in both 3D Slicer and SimpleITK, the origins appear differently as shown in the screenshots I provided. In 3D Slicer, it’s one value, while in SimpleITK, it’s another.


Values are the same, but the signs of the first two axis are different. That because Slicer uses a RAS coordinate system and ITK uses LPS. Please read the coordinate system documentation that was shared.

I am encountering an issue while trying to align DICOM images converted to NIfTI format with their corresponding labels. Despite my attempts to match the spacing direction and origin values, I am facing the following error. I believe the issue may be related to the 4th dimension, but I’m uncertain how to address it. Could someone please provide guidance on how to properly align the image and label in NIfTI format? Additionally, I’m unclear about the significance of the 4th dimension and how to ensure compatibility between the image and label.

Thank you for your assistance.

I apologize for any grammatical or syntactical errors due to my limited proficiency in English.


slc

The direction should be only the rotation component of the transform matrix (3x3).
The Direction you are showing in the prompt is a 4x4, as an homogeneous transform matrix (even if translations are set to zero).

I guess that passing only the rotational component should fix the problem.

Thank you for the response, but I didn’t quite understand the solution you mentioned. I’m using SimpleITK to convert DICOM to NIfTI, and I’m still unclear on how to implement the solution you suggested. Could you please provide a more detailed explanation on how to apply it in the context of SimpleITK or a DICOM to NIfTI library?

This is already answered here:

Where are you having these issues? Is this in Slicer? How are these files generated? I see one is DICOM, but where is the labelmap coming from?

In any event, if you create a lineaer transformation with first two diagonal values are -1, and everythig left as unchanged and put the labelmap under this transform you should be able to line up your two dataset.

In the dataset I’m working on related to breast cancer, the label file is in .dcm format, while the images are in a series of .dcm files. To be able to train them in an nnU-Net model, I’ve used a Python script with libraries like SimpleITK or DICOM to NIfTI to convert both files’ formats from DICOM to NIfTI. However, when I reload them into the 3D Slicer program, I encounter discrepancies between the images and the labels. These issues were not present when the files were in DICOM format.

I suspect these discrepancies arise from the images being in 4D format and the inadequacy of the libraries I’m using for this conversion process. I sought assistance regarding these transformations, aiming to preserve values like spacing, direction, origin, etc., without distortion.

What happens when you create a transform like this, and assign your segmentation to it?

Did you use dcm2niix?

You can also load you DICOM images in Slicer and save them as nifti. This would allow you to double check the issues after converting DICOM to nifti when using your scripts.

I hope this could help.

1 Like