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

[BUG] "Check orientation" button in napari not consistent with registration results for hemisphere #200

Open
pderdeyn opened this issue May 19, 2024 · 11 comments · Fixed by #207
Assignees
Labels
bug Something isn't working

Comments

@pderdeyn
Copy link

Describe the bug
Orientation doesn't seem to be consistent between the "Check orientation" button in napari brainreg plugin versus when running the registration. The "left-right" lateral direction seems to be flipped between the two for my useage. Note that I am using a single hemisphere

To Reproduce
I have one hemisphere of an imaged brain to align with an atlas. Using the check orientation button in napari's brain reg plugin, I find that my data orientation should be lpi for a brain geometry of Left hemisphere (screenshot 1). However, when I run this hemisphere through brain reg, I find that the atlas is actually the incorrect lateral orientation and left and right need to be flipped (screenshot 2). I'm able to fix my brain my switching to rpi (screenshot 4), even though the "check orientation" results don't look correct anymore (screenshot 3).

Expected behaviour
Registration should occur with the correct orientation if the "Check orientation" results look good

Screenshots

"Check orientation" results for lpi
image

Registration results for lpi
image

"Check orientation" results for rpi
image

Registration results for rpi
image

Computer used (please complete the following information):

  • OS: Windows
  • Version: Windows 11, Version 23H2
  • Hardware specs: 32 GB RAM.
@pderdeyn pderdeyn added the bug Something isn't working label May 19, 2024
@adamltyson
Copy link
Member

Thanks for raising this @pderdeyn, we'll take a look.

@alessandrofelder I wonder if this is related to what we saw with napari in 2D/3D on Friday? Is it possible that there's something going on with 2D and 3D visualisation in napari, so that in one of the views, the data is (or at least appears to be) flipped?

@alessandrofelder
Copy link
Member

alessandrofelder commented May 20, 2024

I wonder if this is related to what we saw with napari in 2D/3D on Friday?

Maybe... we should find a clear way to check this for ourselves (that doesn't require neuroanatomy knowledge) and then discuss it with the napari community if needed?

@adamltyson
Copy link
Member

A quick test on the latest napari suggests that it isn't a napari thing, this looks fine to me:
2D
2d

3D
3d

@adamltyson
Copy link
Member

I had a quick look at this last week, and it looks like the issue is somewhere in the intersection of setting the hemisphere and creating the projections.

@adamltyson
Copy link
Member

adamltyson commented Jun 24, 2024

I had a quick look at this last week, and it looks like the issue is somewhere in the intersection of setting the hemisphere and creating the projections.

Actually I think I'm wrong, I think the issue is just in creating the projections. I (very scientifically!) created an image with an L marked into it in two axes, so that you can always tell which axis is which.
3d

This brain is psl and registering it with this orientation appears to work correctly. The downsampled_standard.tiff image is correctly oriented:
downsampled_standard

This suggests that brainreg and brainglobe-space are working properly. Of course they could be cancelling each other out, but I'm assuming that these two mature packages are correct.

However, if I click on Check orientation then the brain appears flipped (hard to see, but there's a slight mark in the left hemisphere, which is now rendered on the right).

orientation

I assume this is the reason for the issue reported here. I haven't worked out why this is happening yet.

@adamltyson
Copy link
Member

I think I'm missing something here. In the orientation checking function, the input data (napari layer) is reoriented (using brainglobe-space) to the atlas orientation. This looks correct (L is in the correct place):

remapped_image

However, when looking at the projection images in the above comment, it seems that the first projection (bottom left) is correct (assuming the view is front to back), but the second (bottom middle) is not (assuming the view is top down). I don't think we can say anything about the third (bottom right).

@alessandrofelder
Copy link
Member

@IgorTatarnikov and I spent some time diagnosing this.
Our conclusions are:

  • there is a bug in the check_orientation code, which hides the left hemisphere when we actually want to show it (and same for right hemisphere)
  • there is an additional false assumption by us that the middle view of the "Check orientation" result is top-down. It is actually bottum-up, because that's is the view that results from the anterior-most, right-most pixel of a 2d projection along the S-I axis displayed on the top-left.

IgorTatarnikov pushed a commit that referenced this issue Jun 26, 2024
* add test for check_orientation bug #200

* hide left hemi when right requested, and vice-versa
@pderdeyn
Copy link
Author

Fantastic. Thanks for the fix you all <3

@adamltyson
Copy link
Member

Hey @pderdeyn, a new version with this fix should be out in an hour or so. pip install brainreg -U will update.

@pderdeyn
Copy link
Author

I just wanted to confirm that I tried this today on an updated version and it works as expected. Thanks again

@adamltyson adamltyson reopened this Nov 11, 2024
@adamltyson
Copy link
Member

Reopening this, as this image.sc issue suggests that there may still be a problem:
https://forum.image.sc/t/struggling-to-find-the-correct-atlas-orientation-for-brainreg-single-hemisphere/104818

@IgorTatarnikov IgorTatarnikov self-assigned this Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants