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

Add Cuttlebase cuttlefish atlas #338

Open
wants to merge 45 commits into
base: main
Choose a base branch
from

Conversation

kjungwoo5
Copy link
Contributor

@kjungwoo5 kjungwoo5 commented Aug 2, 2024

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?
We would like to add support for the cuttlebase.org cuttlefish atlas.

What does this PR do?
This adds a packaging script for the cuttlefish atlas.

References

Issue #206

How has this PR been tested?

The code has been tested locally.

Is this a breaking change?

No.

Does this PR require an update to the documentation?

If any features have changed, or have been added. Please explain how the documentation has been updated (and link to the associated PR). See here for details.

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality (unit & integration)
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@kjungwoo5 kjungwoo5 reopened this Aug 2, 2024
kjungwoo5 and others added 25 commits August 8, 2024 22:32
… and right sides of regions to hierarchy file
…ous code, mesh name did not match the region ID)
…use map_points_to, but currently the meshes are still not correctly aligned.
…an matrix multiplication, and attempted to translate meshes.
@kjungwoo5
Copy link
Contributor Author

Hi @alessandrofelder, I think the code is ready for review now. Thank you!

@kjungwoo5 kjungwoo5 marked this pull request as ready for review January 31, 2025 19:25
Copy link
Member

@alessandrofelder alessandrofelder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kjungwoo5 - one last hurdle!


# process brain template MRI file
print("Processing brain template:")
brain_template = load.load_nii(template_path, as_array=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to rescale the template image here, because otherwise it get naively converted from np.float64 to np.uint16. For an example of how this is done, see

Lines 94-99

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I'll try to get working on this soon!

@alessandrofelder
Copy link
Member

alessandrofelder commented Feb 3, 2025

Thanks @kjungwoo5 - one last hurdle!

I spoke too soon 🤦 - sorry. There is a second final hurdle: the annotation pixel value of equivalent regions in left and right hemisphere has to be the same in BrainGlobe - downstream tools depend on this. So we need some code to replace the pixels in the right hemisphere with the value of the pixel of the equivalent region in the left. I can help with this, if you like, @kjungwoo5 ?

@PolarBean
Copy link
Member

In addition to the brain atlas there is also a whole body cuttlefish atlas mentioned in this publication. It would be really cool to see that as another atlas available in brainglobe!
Congratulations on this pull request it looks good :)

@PolarBean
Copy link
Member

@PolarBean
Copy link
Member

One thing I noticed is that you include mesh url to the cuttlfish meshes but you don't use it, instead generating your own meshes from the segmentation. Is this intended?

@adamltyson
Copy link
Member

One thing I noticed is that you include mesh url to the cuttlfish meshes but you don't use it, instead generating your own meshes from the segmentation. Is this intended?

I assume not. If there are existing meshes, we should use them.

@alessandrofelder
Copy link
Member

alessandrofelder commented Feb 4, 2025

@kjungwoo5 and I tried very hard to use the existing meshes.

  • They are in a format that standard Python mesh reading libraries can't read, so we made our own reader.
  • Then we noticed that they were in a different coordinate space to the image, and the transformation was undocumented, as far as we could see.
  • So we decided to reduce the scope of v1 of the cuttlefish atlas to recompute the meshes ourselves for now.

@PolarBean
Copy link
Member

What an effort! Just goes to show the value of standardising all components of atlases :)

@kjungwoo5
Copy link
Contributor Author

Thanks @kjungwoo5 - one last hurdle!

I spoke too soon 🤦 - sorry. There is a second final hurdle: the annotation pixel value of equivalent regions in left and right hemisphere has to be the same in BrainGlobe - downstream tools depend on this. So we need some code to replace the pixels in the right hemisphere with the value of the pixel of the equivalent region in the left. I can help with this, if you like, @kjungwoo5 ?

I would appreciate your help on this, thank you!

@kjungwoo5
Copy link
Contributor Author

One thing I noticed is that you include mesh url to the cuttlfish meshes but you don't use it, instead generating your own meshes from the segmentation. Is this intended?

Ah yes, thank you for pointing that out. That is a remnant of our previous attempts to use the existing meshes, as per @alessandrofelder's explanation. I will remove it in my next commit.

@PolarBean
Copy link
Member

PolarBean commented Feb 5, 2025

Hey I made a commit to update the script name to match the api name :) Let me know if this is the right way to do this. I'm not sure how to use the github propose changes feature,. This is something introduced previously here #462

@alessandrofelder
Copy link
Member

@kjungwoo5 I had some time to work on symmetrising the annotations for this atlas.
Can I ask some clarifying questions:

  • what were the hierarchy[-3] and hierarchy[-4] that had an extra key? I didn't run into this problem after my modifications (maybe they were in the right hemisphere, and I'm only keeping the left)?
  • what allowed you to deduce that we needed additional ids for SB and IB?
  • remind me what you mean by dummy values in your comment on line 166

Thanks :)

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

Successfully merging this pull request may close these issues.

4 participants