One application I am working on uses dcmtk to create a DICOM file, which I then load into Slicer, along with an STL file I have. I want the voxel volume from the DICOM file be positioned in a specific way with respect to the triangle mesh in the STL file (think to this as positioning a SPECT-reconstructed volume with respect the mesh of a patient). To this end, I use Image Position (Patient) Attribute (0020,0032) when I create the DICOM file. However, Slicer seems to ignore anything I set for Image Position (Patient) Attribute, and it is always using (0, 0, 0) for that attribute. Am I doing something wrong?
Be sure you are importing via the DICOM module. Slicer is pretty careful to respect whatās in the dicom header so I suspect the alignment error is elsewhere, such as the coordinate system assumptions of the STL file.
If you do find any issues with coordinate system handling please report it with example (anonymized) data to reproduce.
Thanks for getting back to me that fast. I took some time to go over the DICOM documentation to diligently come up with a piece of code that produces the result I want (i.e., a DICOM file with Image Position (Patient) Attribute (0020,0032) being accounted for when I load the file into Slicer). I think I got it now!
It seems to me that Slicer uses DCMTK to look for Tag (5200,9229) āShared Functional Groups Sequence Attributeā and if it does not find it, it looks for Tag (5200,9239), which I could not find in the DICOM documentation. I think the logical thing to do would be to look for āPer-frame Functional Groups Sequence Attributeā (5200,9230) instead.
I have not run any test to confirm that this is indeed a typo-induced bug.
Good catch, indeed the file reader should use (0x5200, 0x9230) instead of (0x5200, 0x9239). It seems that itkDCMTKFileReader.cxx was copied from ITK in 2012 and all the changes since then were just to fix compilation issues.
It seems that we can switch to the DCMTK reader in ITK, where the correct tags are used. Iāve submitted a pull request with this change: