dicom_parser
dicom_parser copied to clipboard
Fix Series.get_spatial_resolution() to return correct z-axis values
Hi, this is more of a question... I wanted to calculate voxel size from a dicom series and came across the get_spatial_resolution method from the Series object. I see that it returns pixel spacing together with slice thickness as a tuple. Since spatial_resolution is also used in determining the affine matrix for the series, shouldn't SliceThickness be replaced with "z spacing", calculated from ImagePositionPatient?
Hi @jpcenteno80, thank you for raising this issue - the naive get_spatial_resolution() method was created simply for the purpose of displaying approximate values over my dataset of mostly Siemens MRI data, and seemed to work well enough for that purpose. Looking into it, I found this neurostars discussion, as well as this SO answer, and it certainly seems like calculating the distance between to ImagePositionPatient values from neighboring slices will be more robust.
I am currently working on some other things, but please do feel free to open a PR if you feel so inclined. In any case, thank you very much for reporting.