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

Two series in a scn tiff image, but only first series are used. #21

Closed
One-sixth opened this issue Mar 18, 2022 · 2 comments · Fixed by #22
Closed

Two series in a scn tiff image, but only first series are used. #21

One-sixth opened this issue Mar 18, 2022 · 2 comments · Fixed by #22
Labels
compatibility OpenSlide compatibility related help wanted Extra attention is needed

Comments

@One-sixth
Copy link
Contributor

My scn tiff image has two series, the first layer is low resolution and the second layer is high resolution.
Only the first series is seen, the second series.

Maybe we can add a parameter like this " slide = TiffSlide('abc.scn', use_series='auto') ".
When in " use_series='auto' " the series with the largest resolution is automatically selected.

Below is the shape of each page.

(4668, 1616, 3)
(4668, 1616, 3)
(1167, 404, 3)
(291, 101, 3)
(67552, 43392, 3)
(16888, 10848, 3)
(4222, 2712, 3)
(1055, 678, 3)
(263, 170, 3)

This is my tifffile scn tiff scn_metadata output.

<?xml version="1.0"?>
<scn xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" uuid="urn:uuid:d9fcefd6-4a8c-4807-86ba-085e664f1f76" xmlns="http://www.leica-microsystems.com/scn/2010/10/01">
  <collection name="ImageCollection_0000001862" uuid="urn:uuid:04538c70-e2e7-40d1-9ae8-fd9f20285542" sizeX="26564529" sizeY="76734666">
    <image name="image_0000004202" uuid="urn:uuid:a56cc2a7-61fe-448c-9591-442461e81e3c">
      <creationDate>2020-08-19T12:06:35.19Z</creationDate>
      <device model="Leica SCN400;Leica SCN" version="1.5.1.10804 2012/05/10 13:29:07;1.5.1.10864" />
      <pixels sizeX="1616" sizeY="4668">
        <dimension sizeX="1616" sizeY="4668" r="0" ifd="0" />
        <dimension sizeX="404" sizeY="1167" r="1" ifd="1" />
        <dimension sizeX="101" sizeY="291" r="2" ifd="2" />
      </pixels>
      <view sizeX="26564529" sizeY="76734666" offsetX="0" offsetY="0" spacingZ="0" />
      <scanSettings>
        <objectiveSettings>
          <objective>0.60833</objective>
        </objectiveSettings>
        <illuminationSettings>
          <numericalAperture>0.7</numericalAperture>
          <illuminationSource>brightfield</illuminationSource>
        </illuminationSettings>
      </scanSettings>
    </image>
    <image name="image_0000004206" uuid="urn:uuid:a6cdd838-572f-400b-8337-fab8740856aa">
      <creationDate>2020-08-19T12:13:04.14Z</creationDate>
      <device model="Leica SCN400;Leica SCN" version="1.5.1.10804 2012/05/10 13:29:07;1.5.1.10864" />
      <pixels sizeX="43392" sizeY="67552">
        <dimension sizeX="43392" sizeY="67552" r="0" ifd="3" />
        <dimension sizeX="10848" sizeY="16888" r="1" ifd="4" />
        <dimension sizeX="2712" sizeY="4222" r="2" ifd="5" />
        <dimension sizeX="678" sizeY="1055" r="3" ifd="6" />
        <dimension sizeX="170" sizeY="263" r="4" ifd="7" />
      </pixels>
      <view sizeX="21696000" sizeY="33776000" offsetX="1019179" offsetY="16624923" spacingZ="400" />
      <scanSettings>
        <objectiveSettings>
          <objective>20</objective>
        </objectiveSettings>
        <illuminationSettings>
          <numericalAperture>0.4</numericalAperture>
          <illuminationSource>brightfield</illuminationSource>
        </illuminationSettings>
      </scanSettings>
    </image>
  </collection>
</scn>
@ap--
Copy link
Collaborator

ap-- commented Mar 20, 2022

Hi @One-sixth

I think that your suggestion to allow selecting the underlying series is very reasonable and we should discuss adding this functionality in another issue.

Regarding scn support, I think we should default to follow openslide's behavior.
The important things happen in here
https://github.com/openslide/openslide/blob/2d5b9aa5d87ad8a6f9e6c47e5423c5e421a39e9c/src/openslide-vendor-leica.c#L590-L800

You can see that the first series are skipped, if those are not macro images:
https://github.com/openslide/openslide/blob/2d5b9aa5d87ad8a6f9e6c47e5423c5e421a39e9c/src/openslide-vendor-leica.c#L612

The test for this is can be found here: https://github.com/openslide/openslide/blob/2d5b9aa5d87ad8a6f9e6c47e5423c5e421a39e9c/src/openslide-vendor-leica.c#L496-L499

Would you want to work on a PR to add support for this? If so, that would be awesome ❤️

To make it easier, I refactored the TiffSlide class a bit to allow adding new support for other formats in a more clear way.

Basically you would add support here https://github.com/bayer-science-for-a-better-life/tiffslide/blob/8ab9ab301bb6c1f2eee68270516a5b442b16e9cc/tiffslide/tiffslide.py#L213-L217
by testing:

elif tf.is_scn:
    desc = ...
    _md = _parse_metadata_scn(...)  # would need to be implemented
    series_idx = ...
    ...

Let me know if there are any questions, or if I can help somehow!

Cheers,
Andreas 😃

@ap-- ap-- added help wanted Extra attention is needed compatibility OpenSlide compatibility related labels Mar 20, 2022
@One-sixth
Copy link
Contributor Author

One-sixth commented Mar 21, 2022

@ap--
Hi, I created a PR, here #22 . Added Openslide method to determine which scn series to use.

I added a new parameter to choose which series, it can be 'auto' or a valid series idx.
When in auto mode, only use openslide-like for scn series. All other formats use series idx 0 by default.
If we don't want the user to access the series_idx variable directly, we can hide it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility OpenSlide compatibility related help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants