Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect slice alignment when rounding ImagePositionPatient[2] to int #9

Open
nickhardcastle opened this issue May 3, 2022 · 0 comments

Comments

@nickhardcastle
Copy link

Hi,

We've discovered an issue with PyrexReader whereby using int(ImagePositionPatient[2]) incorrectly orders slices in both the image and mask.

At line 56:
scan.sort(key = lambda x: int(x.ImagePositionPatient[2])) # sort slices based on Z coordinate

We get incorrectly ordered CT slices (see attachment #1)
2022-05-03 12_26_07-3D Slicer 4 11 20210226

Replacing with:
scan.sort(key = lambda x: float(x.ImagePositionPatient[2])) # sort slices based on Z coordinate

And at line 110:
if np.int64(Cpostion_rt) == np.int64(img_vol[i].ImagePositionPatient[2]):

Replacing with:
if float(Cpostion_rt) == float(img_vol[i].ImagePositionPatient[2]):

we get correctly aligned slices for both the CT and the structure mask (see attachment #2)
2022-05-03 12_25_01-3D Slicer 4 11 20210226

This only happens for some CT data sets, still trying to figure out which factors lead to this. It's only visible if you put a line in at the end of PyrexReader to export the images/masks (or an image showing a slice through this). We've since added code to visualise the image/mask as it comes out of PyrexReader to review as a QA check.

Cheers,

Nick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant