aicsimageio icon indicating copy to clipboard operation
aicsimageio copied to clipboard

Add a dedicated reader for Leica SCN files (`tifffile` backend)

Open NHPatterson opened this issue 4 years ago • 16 comments

Description

This PR adds a dedicated reader for Leica SCN files (the vendor format for the Leica SCN-400 and SCN-400F slide scanner) that can access macro, label, and full resolution images from multiple scenes. It has been tested with RGB bright field scans and fluorescence scans, but not yet for either scan type with Z-stacks (I don't believe time-lapse imaging is possible with this scanner).

tifffile already supported this format and can access all layers. This PR maps the image metadata to what is expected by aicsimageio. This is significantly faster than using bioformats.

Tests for the reader and the AICSImage are added.

Pull request recommendations:

  • [x] Name your pull request your-development-type/short-description. Ex: feature/read-tiff-files
  • [x] Provide relevant tests for your feature or bug fix.
  • [ ] Provide or update documentation for any feature added by your pull request.

I should be able to do something similar for .svs soon, addressing #228.

For testing, 2 images will need to be added: this image and an image from my lab. Please let me know how I can send this to you, it is fine if it is in the public domain.

NHPatterson avatar Oct 27 '21 18:10 NHPatterson

Hey @NHPatterson what is your hopeful timeline on getting this in? I am a bit busy but can review this weekend.

I should be able to do something similar for .svs soon, addressing #228 Note: we still haven't really decided on how to handle pyramid data. So while it would be great to address the file format issue, the API for how to handle pyramid / multi-scale still needs to be locked in by all the various users and maintainers of this package :sweat_smile:

evamaxfield avatar Oct 27 '21 21:10 evamaxfield

Oh and I can download the linked image so can simply upload it to our test resources as well. Will give you a HASH to use this weekend.

evamaxfield avatar Oct 27 '21 21:10 evamaxfield

Hey @NHPatterson what is your hopeful timeline on getting this in? I am a bit busy but can review this weekend.

I should be able to do something similar for .svs soon, addressing #228

No urgency on the SVS, it will probably be a week and a half before I can start. It may takea bit more time. I think my overall goal is to add readers to all vendor formats read by tifffile (.ndpi is another, many of them overlap with openslide which is a dependency to avoid IMO). These formats all have a similar interface in tifffile it is just a matter of collecting the metadata correctly.

Note: we still haven't really decided on how to handle pyramid data. So while it would be great to address the file format issue, the API for how to handle pyramid / multi-scale still needs to be locked in by all the various users and maintainers of this package 😅

Yeah, I am definitely interested in this and will keep an eye on any conversations. My first thought would be to not break anything in the readers, but add methods for accessing pyramids at AICSImage. From what I gather most sub-resolutions are separated as different scenes so checking the array shape on each could indicate where pyramids are stored because I have doubts about using image metadata in some cases.

NHPatterson avatar Oct 28 '21 14:10 NHPatterson

Thanks for contributing this! I have a few comments regarding structure 🙂

Thanks for the careful review! I've done as you suggested for all the issues.

NHPatterson avatar Oct 28 '21 18:10 NHPatterson

Yeah, I am definitely interested in this and will keep an eye on any conversations. My first thought would be to not break anything in the readers, but add methods for accessing pyramids at AICSImage. From what I gather most sub-resolutions are separated as different scenes so checking the array shape on each could indicate where pyramids are stored because I have doubts about using image metadata in some cases.

This is an interesting idea to me - if "scenes" are always the way to get pyramid info, then that takes some burden off of aicsimageio to make very specific changes to handle multiresolution storage (for reading). I'm interested in talking about what kind of public API needs we would then have, if any.

toloudis avatar Oct 28 '21 20:10 toloudis

Looks like there is a conflict after GlobReader merge.

evamaxfield avatar Oct 30 '21 15:10 evamaxfield

SCN containing Z-stacks are not supported yet by tifffile. Can you please provide a sample file?

cgohlke avatar Oct 30 '21 18:10 cgohlke

SCN containing Z-stacks are not supported yet by tifffile. Can you please provide a sample file?

I'm not able to find one publicly unfortunately. I have a Leica SCN400 in lab were I work though and can scan a test dataset when I get back from traveling the week after next. It would be a RGB z-stack image so hopefully that works. We don't have the fluorescence module for this scanner.

NHPatterson avatar Oct 31 '21 18:10 NHPatterson

Overall, this all looks good. Some minor comments at specific lines, my high level comment is that it would be great to add a few more comments. Largely around the metadata handling.

Added the test file to the test dataset, the new hash is: 0816cdcf4f70c67bf409098c9059b5e8a1e127be2102667ec168279756828318

(don't worry this hash includes the test file for this PR and for #336)

Thanks for this review. I will add some clarifying comments.

NHPatterson avatar Oct 31 '21 18:10 NHPatterson

Overall, this all looks good. Some minor comments at specific lines, my high level comment is that it would be great to add a few more comments. Largely around the metadata handling.

@JacksonMaxfield I tried to add more comments and information throughout. Also, could you add one more image to the test repo (smaller file size RGB SCN image than what is on OpenSlide from my group): image

NHPatterson avatar Nov 04 '21 18:11 NHPatterson

Overall, this all looks good. Some minor comments at specific lines, my high level comment is that it would be great to add a few more comments. Largely around the metadata handling.

@JacksonMaxfield I tried to add more comments and information throughout. Also, could you add one more image to the test repo (smaller file size RGB SCN image than what is on OpenSlide from my group): image

Sounds good. Will review and add that file later tonight or tomorrow. Hoping to get out 4.5.0 today though with the TiffGlobReader and your dask chunking on yx for bioformats!

evamaxfield avatar Nov 04 '21 18:11 evamaxfield

SCN containing Z-stacks are not supported yet by tifffile. Can you please provide a sample file?

@cgohlke I collected this image, it's a brightfield z-stack from a Leica SCN400. Feel free to use it how you want.

NHPatterson avatar Nov 05 '21 20:11 NHPatterson

@cgohlke I collected this image, it's a brightfield z-stack from a Leica SCN400. Feel free to use it how you want.

Thank you! Turns out that current tifffile correctly handles the file. No changes necessary.

cgohlke avatar Nov 05 '21 23:11 cgohlke

I was about to close this due to inactivity... but I don't see anything wrong with this?? Why did we never merge this. Was it just me not uploading the test file you sent?? @toloudis do you remember anything?

@NHPatterson so sorry if this just entirely fell off my stack. I can take a look again if you would like me to?

evamaxfield avatar Feb 22 '22 17:02 evamaxfield

I was about to close this due to inactivity... but I don't see anything wrong with this?? Why did we never merge this. Was it just me not uploading the test file you sent?? @toloudis do you remember anything?

@NHPatterson so sorry if this just entirely fell off my stack. I can take a look again if you would like me to?

I'm thinking at the very least the conflicts need to be resolved... but otherwise, idk! We can re-review.

toloudis avatar Feb 22 '22 17:02 toloudis

I was about to close this due to inactivity... but I don't see anything wrong with this?? Why did we never merge this. Was it just me not uploading the test file you sent?? @toloudis do you remember anything?

@NHPatterson so sorry if this just entirely fell off my stack. I can take a look again if you would like me to?

No worries @JacksonMaxfield. I'm happy to take another look in next couple of days and sort out the conflicts.

NHPatterson avatar Feb 22 '22 18:02 NHPatterson

Closing this, will revisit as an independently plugin when time permits.

NHPatterson avatar Aug 19 '22 17:08 NHPatterson