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

Save raw instance segmentation #742

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Conversation

hermancollin
Copy link
Member

@hermancollin hermancollin commented May 23, 2023

Checklist

  • I've given this PR a concise, self-descriptive, and meaningful title
  • I've linked relevant issues in the PR body
  • I've applied the relevant labels to this PR
  • I've added relevant tests for my contribution
  • I've updated the documentation and/or added correct docstrings
  • I've assigned a reviewer
  • I've consulted ADS's internal developer documentation to ensure my contribution is in line with any relevant design decisions

Description

This PR adds a feature discussed last year in #668 after the instance colorization feature was merged. When using the -c flag, the raw instance map is now also saved alongside the colorized image.

Note 2 things:

  • I changed the colorized image suffix from _instance-map.png to _colorized.png as the former was more appropriate for the raw instance map file.
  • I added back the bitdepth argument in imread which was removed in Improve and force imread/imwrite conversion to 8bit int #669 (I don't recall why). For now it's useless because the raw instance map (saved in 16bit PNG) is never read anywhere. However, if we want to read a 16-bit instance map, we will be able to use our imread function with bitdepth=16.
    def imread(filename, bitdepth=8):

Linked issues

Resolves #668
Resolves #697

@hermancollin hermancollin added enhancement category: the change expands an existing functionality or refactoring feature category: the change introduces a new functionality to AxonDeepSeg morphometrics related to morphometrics script labels May 23, 2023
@coveralls
Copy link

Pull Request Test Coverage Report for Build 5062311337

  • 7 of 7 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 89.302%

Totals Coverage Status
Change from base Build 4958795446: 0.02%
Covered Lines: 1177
Relevant Lines: 1318

💛 - Coveralls

@hermancollin
Copy link
Member Author

By using this feature I found a bug. When the number of axons in the image is inferior to 256, even though we force the datatype to np.uint16, the image is saved as an 8-bit PNG. In that case, I'm not sure if we should try to force the conversion to 16 bits.

On one hand, we would have the guarantee that the instance map is correctly handled by ads_util.imread() if bitdepth=16 is used (predictable interface for the myelin maps). On the other hand, it could be highly inefficient memory-wise.
If we keep the flexibility of using 8b or 16b depending on the number of axons in the image, we could make sure that myelin maps are correctly loaded by catching the myelin map suffix in the filename and using a try-except block to catch conversions from uint16 to uint8 and vice-versa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement category: the change expands an existing functionality or refactoring feature category: the change introduces a new functionality to AxonDeepSeg morphometrics related to morphometrics script
Projects
None yet
2 participants