Matching up nii.gz and a list of dicom files

100 views
Skip to first unread message

David Choi

unread,
Oct 7, 2022, 2:19:31 AM10/7/22
to itksnap-users
Many, many thanks to the developers who have contributed to such an amazing tool.

I've looked into all the conversations back to 2017s, but failed to find the similar issue I'm facing now.

Every time I try to match up dicom slices of MRI and the .nii.gz file of segmentation.

To simplify my story:

I've got a list of 10 dicom slices of MRI, all of which are named as FILE0001.dcm, FILE0002.dcm, FILE0003.dcm, and so on. On ITK-SNAP I've added 6 segmentations to each slice and export all the segmentations of the 10 slices to MRI.nii.gz.

Now I open both dcm files and MRI.nii.gz and start matching them up to view if the segmentation results work fine. The segmentation array looks like (640,640,10) and I fetch the very first one, which I suppose is located at [..., 0], and then throw it over FILE0000.dcm, ending up frustrated. They never match up. Then I try with the last one, which is located at [..., 9], again ending up disappointed.

At this time, I suspect that ITK-SNAP never cares for the naming of dcm files, either ascending or descending when it exports the segmentations. Then I look into the SliceLocataion tag of each dcm file and realize that each dcm file has a different slice location, which makes me think that ITK-SNAP might be using this information when it display all the slices in 3D. Hence, I collect all the SliceLocation information and sort it out either in descending or ascending order, and then try matching up. Whooray! Now I learn that when PACS generates dcm files the naming rule of file names should be trusted.

Now that I've got a lesson, I apply this methodology to all the other MRI slices of different patients. To make myself 100% confident, I randomly sample 4 slices and their counterparts of segmenations and match them up. Oh my! Still there are mis-matches. I'm about to pull my hair. Help me out folks.

Jilei Hao

unread,
Nov 17, 2022, 2:23:00 PM11/17/22
to itksnap-users
ITK-SNAP is using normalized Image Position (Patient) (0020,0032), instead of SliceLocation Tag for sorting dicom series. Can you try to the IPP tag to see if it brings consistency?

Best,
Jilei

David Choi

unread,
Nov 17, 2022, 7:24:22 PM11/17/22
to itksnap-users
Thanks Jilei,

IPP works perfectly!

2022년 11월 18일 금요일 오전 4시 23분 0초 UTC+9에 jile...@gmail.com님이 작성:
Reply all
Reply to author
Forward
0 new messages