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

Data z-spacing is suspicious in certain cases #8

Closed
neheller opened this issue Mar 21, 2019 · 9 comments
Closed

Data z-spacing is suspicious in certain cases #8

neheller opened this issue Mar 21, 2019 · 9 comments
Assignees
Labels
Label Error All issues pertaining to the provenence of the segmentation labels

Comments

@neheller
Copy link
Owner

This is referencing an issue first raised on Discourse here. case_00002 and case_00003 were mentioned in particular but the report is that there may be others.

@neheller neheller self-assigned this Mar 21, 2019
@neheller neheller added the Label Error All issues pertaining to the provenence of the segmentation labels label Mar 21, 2019
@ghumpire
Copy link

ghumpire commented Apr 1, 2019

@neheller, Were you able to reproduce this issue?

@neheller
Copy link
Owner Author

neheller commented Apr 2, 2019

Sorry for the delay. I was able to verify that the released spacing does match the values from the DICOM imaging, but of course that doesn't necessarily mean it matches the real world.

Sometime between now and April 15, we will be releasing a copy of the data with fixed spacing all around. We will take care to ensure that the spacing truly is consistent from case to case.

@neheller
Copy link
Owner Author

On further exploration, the issue was the way I was extracting spacing from the DICOM imaging. Thanks again for discovering this, and it will be fixed in the release next week.

@neheller
Copy link
Owner Author

This has been addressed in the amended training data release. Please feel free to reopen if you still see any that look suspicious.

@ghumpire
Copy link

Thanks for the update. After pulling your changes, I visualized the new CT scans and found issues in other orthogonal directions. Before going into details, just to be in the same page, I attached an image below where: sagital, coronal, and axial orthogonal views are displayed in the first, second, and third columns respectively. Now, just to summarize what I found in the first and second versions:

  • In your first version (March ~15th), the CT scans looked natural in the axial view but the coronal and sagittal. See first row of the image below.
  • In your second version (April 15th), the CT scans look better in coronal view but axial and sagittal look distorted. See second row of the image below.

I tried to fix this issue and I think I did it, or at least the images I generated look more natural. Firstly, I think this issue is related to #9 (any Software that visualizes the CT scans shows the scans in sagittal view, which usually should be axial view). My workaround is simple (a similar workaround reported in #15 by @huyu398 using SimpleITK):

  • Read a case from the repo.
  • Swap axis 0 and 2 of the CT scan.
  • Open the json file, retrieve the captured_pixel_width and captured_pixel_width values for the case you are reading.
  • Replace the old voxel spacing with [captured_slice_thickness, captured_pixel_width, captured_pixel_width].

Sorry if I did not use nibabel to show my workaround, I am not familiar to it and I preferred to show the steps instead of making a mistake.

My workaround generates more natural CT scans. Below you can find screenshots of the first version, second version, and my suggestion. Note that red boxes represent slices that does not look natural, the green boxes show slices that (I think) look natural. Also note that the second version and my suggestion have green boxes but I think that my workaround looks slightly more natural.

image

@neheller
Copy link
Owner Author

neheller commented Apr 16, 2019

Thanks for the thorough report!

To clarify the intended spacing:

  • captured_slice_thickness is the distance in the z-direction between axial slices.
  • captured_pixel_width is the distance in the x and y-directions between adjacent pixels within axial slices.

The data array stored within nibabel is indexed by (z, y, x). In commit 236685c I changed the spacing to

array([[0.                   , 0.                   , captured_slice_thickness , 0. ],
       [0.                   , captured_pixel_width , 0.                       , 0. ],
       [captured_pixel_width , 0.                   , 0.                       , 0. ],
       [0.                   , 0.                   , 0.                       , 1. ]])

But I see now that this still has a few issues. (1) it disobeys the sign convention, and (2) it's actually the transpose of what I want. I have now changed it to

array([[0.                          , 0.                      , -1*captured_pixel_width , 0. ],
       [0.                          , -1*captured_pixel_width , 0.                      , 0. ],
       [-1*captured_slice_thickness , 0.                      , 0.                      , 0. ],
       [0.                          , 0.                      , 0.                      , 1. ]])

And ITK-SNAP finally shows natural looking images.

Screenshot from 2019-04-16 10-08-10

Thanks so much for your patience and help through this process. The commit with the fix has been pushed to master: 8b73b04.

@neheller neheller reopened this Apr 16, 2019
@neheller
Copy link
Owner Author

I'm going to leave this open until I hear confirmation that it looks good on your end as well.

@dericdesta
Copy link

Thanks for the final fix. Looks good to me 🙂.

@ghumpire
Copy link

Looks good now! thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Label Error All issues pertaining to the provenence of the segmentation labels
Projects
None yet
Development

No branches or pull requests

3 participants