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

Allow loading multiple series with DICOMweb #122

Merged

Conversation

psavery
Copy link
Contributor

@psavery psavery commented Nov 7, 2023

WsiDicom.open_web() was modified to be able to either take a single series uid (as before) or a list of series uids. If a list of series uids is passed, their instances are all loaded together. This can be useful for cases where, for instance, different optical paths are located in different series.

This also loosens the UID matching to only check the frame of references.

This also adds TotalPixelMatrixOriginSequence matching when comparing datasets.

Fixes: #118

@erikogabrielsson Let me know what you think.

`WsiDicom.open_web()` was modified to be able to either take a single
series uid (as before) or a list of series uids. If a list of series
uids is passed, their instances are all loaded together. This can be
useful for cases where, for instance, different optical paths are located
in different series.

This also loosens the UID matching to only check the frame of references.

This also adds `TotalPixelMatrixOriginSequence` matching when comparing
datasets.

Fixes: imi-bigpicture#118

Signed-off-by: Patrick Avery <[email protected]>
wsidicom/uid.py Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@erikogabrielsson
Copy link
Collaborator

Nice work. The series_uids to list handling prevents the integration tests to pass.

@erikogabrielsson erikogabrielsson merged commit 61fbe0d into imi-bigpicture:main Nov 8, 2023
13 checks passed
erikogabrielsson pushed a commit to psavery/wsidicom that referenced this pull request Nov 8, 2023
* Allow loading multiple series with DICOMweb

`WsiDicom.open_web()` was modified to be able to either take a single
series uid (as before) or a list of series uids. If a list of series
uids is passed, their instances are all loaded together. This can be
useful for cases where, for instance, different optical paths are located
in different series.

This also loosens the UID matching to only check the frame of references.

This also adds `TotalPixelMatrixOriginSequence` matching when comparing
datasets.

Fixes: imi-bigpicture#118

Signed-off-by: Patrick Avery <[email protected]>

* Fix `isinstance()` check for series uids

Signed-off-by: Patrick Avery <[email protected]>

* Fix logic in `SlideUids.matches()`

Signed-off-by: Patrick Avery <[email protected]>

* Remove unused import

Signed-off-by: Patrick Avery <[email protected]>

---------

Signed-off-by: Patrick Avery <[email protected]>
erikogabrielsson added a commit that referenced this pull request Nov 9, 2023
* Add property to count number of tile frames

The "NumberOfFrames" attribute on a dataset takes into account not just
the number of frames corresponding to tiles, but also the number of
focal planes and optical paths (for example, see [here](https://github.com/imi-bigpicture/wsidicom/blob/774fe3ca00096e3fd2556fc956520dbfabc81311/wsidicom/instance/dataset.py#L651-L655)).

When I was trying to view a dataset with multiple optical paths, I would
encounter errors in the `image_size` property since it did not distinguish
frames that came from optical paths and tiles.

This fixes viewing [this example](https://imagingdatacommons.github.io/slim/studies/2.25.23897195960526781231486877255455994829/series/2.25.83282858720704132758110891374375550907) via DICOMweb in [large_image](https://github.com/girder/large_image).

I am new to the field, so please feel free to correct any naming issues
or misconceptions...

Signed-off-by: Patrick Avery <[email protected]>

* Add option to provide a session to the web client (#117)

* Add option to provide web client a session

We would like to create the `requests.Session` object on our own
and pass it into `WsiDicomWebClient`, since we are not using an object
derived from `AuthBase` to create it.

This PR adds support to pass a session to `WsiDicomWebClient` directly.

Signed-off-by: Patrick Avery <[email protected]>

* Refactor __init__ method of WsiDicomWebClient

The `__init__` method now accepts a `DICOMwebClient` object.

The previous `__init__` method was moved into a `create_client()`
class method.

Signed-off-by: Patrick Avery <[email protected]>

* Remove `WsiDicomFileClient` and update README.md

Signed-off-by: Patrick Avery <[email protected]>

---------

Signed-off-by: Patrick Avery <[email protected]>

* Dicomweb get multiple frames (#121)

* Get multiple frames from dicom web

* Allow loading multiple series with DICOMweb (#122)

* Allow loading multiple series with DICOMweb

`WsiDicom.open_web()` was modified to be able to either take a single
series uid (as before) or a list of series uids. If a list of series
uids is passed, their instances are all loaded together. This can be
useful for cases where, for instance, different optical paths are located
in different series.

This also loosens the UID matching to only check the frame of references.

This also adds `TotalPixelMatrixOriginSequence` matching when comparing
datasets.

Fixes: #118

Signed-off-by: Patrick Avery <[email protected]>

* Fix `isinstance()` check for series uids

Signed-off-by: Patrick Avery <[email protected]>

* Fix logic in `SlideUids.matches()`

Signed-off-by: Patrick Avery <[email protected]>

* Remove unused import

Signed-off-by: Patrick Avery <[email protected]>

---------

Signed-off-by: Patrick Avery <[email protected]>

* Remove unsafe number_of_focal_planes and number_of_optical_paths properties

* FIx if

* Skip frame count check for concatenated instances

---------

Signed-off-by: Patrick Avery <[email protected]>
Co-authored-by: Erik O Gabrielsson <[email protected]>
Co-authored-by: Erik O Gabrielsson <[email protected]>
erikogabrielsson pushed a commit to sectra-medical/wsidicom that referenced this pull request Nov 9, 2023
* Allow loading multiple series with DICOMweb

`WsiDicom.open_web()` was modified to be able to either take a single
series uid (as before) or a list of series uids. If a list of series
uids is passed, their instances are all loaded together. This can be
useful for cases where, for instance, different optical paths are located
in different series.

This also loosens the UID matching to only check the frame of references.

This also adds `TotalPixelMatrixOriginSequence` matching when comparing
datasets.

Fixes: imi-bigpicture#118

Signed-off-by: Patrick Avery <[email protected]>

* Fix `isinstance()` check for series uids

Signed-off-by: Patrick Avery <[email protected]>

* Fix logic in `SlideUids.matches()`

Signed-off-by: Patrick Avery <[email protected]>

* Remove unused import

Signed-off-by: Patrick Avery <[email protected]>

---------

Signed-off-by: Patrick Avery <[email protected]>
erikogabrielsson added a commit to sectra-medical/wsidicom that referenced this pull request Nov 9, 2023
* Add property to count number of tile frames

The "NumberOfFrames" attribute on a dataset takes into account not just
the number of frames corresponding to tiles, but also the number of
focal planes and optical paths (for example, see [here](https://github.com/imi-bigpicture/wsidicom/blob/774fe3ca00096e3fd2556fc956520dbfabc81311/wsidicom/instance/dataset.py#L651-L655)).

When I was trying to view a dataset with multiple optical paths, I would
encounter errors in the `image_size` property since it did not distinguish
frames that came from optical paths and tiles.

This fixes viewing [this example](https://imagingdatacommons.github.io/slim/studies/2.25.23897195960526781231486877255455994829/series/2.25.83282858720704132758110891374375550907) via DICOMweb in [large_image](https://github.com/girder/large_image).

I am new to the field, so please feel free to correct any naming issues
or misconceptions...

Signed-off-by: Patrick Avery <[email protected]>

* Add option to provide a session to the web client (imi-bigpicture#117)

* Add option to provide web client a session

We would like to create the `requests.Session` object on our own
and pass it into `WsiDicomWebClient`, since we are not using an object
derived from `AuthBase` to create it.

This PR adds support to pass a session to `WsiDicomWebClient` directly.

Signed-off-by: Patrick Avery <[email protected]>

* Refactor __init__ method of WsiDicomWebClient

The `__init__` method now accepts a `DICOMwebClient` object.

The previous `__init__` method was moved into a `create_client()`
class method.

Signed-off-by: Patrick Avery <[email protected]>

* Remove `WsiDicomFileClient` and update README.md

Signed-off-by: Patrick Avery <[email protected]>

---------

Signed-off-by: Patrick Avery <[email protected]>

* Dicomweb get multiple frames (imi-bigpicture#121)

* Get multiple frames from dicom web

* Allow loading multiple series with DICOMweb (imi-bigpicture#122)

* Allow loading multiple series with DICOMweb

`WsiDicom.open_web()` was modified to be able to either take a single
series uid (as before) or a list of series uids. If a list of series
uids is passed, their instances are all loaded together. This can be
useful for cases where, for instance, different optical paths are located
in different series.

This also loosens the UID matching to only check the frame of references.

This also adds `TotalPixelMatrixOriginSequence` matching when comparing
datasets.

Fixes: imi-bigpicture#118

Signed-off-by: Patrick Avery <[email protected]>

* Fix `isinstance()` check for series uids

Signed-off-by: Patrick Avery <[email protected]>

* Fix logic in `SlideUids.matches()`

Signed-off-by: Patrick Avery <[email protected]>

* Remove unused import

Signed-off-by: Patrick Avery <[email protected]>

---------

Signed-off-by: Patrick Avery <[email protected]>

* Remove unsafe number_of_focal_planes and number_of_optical_paths properties

* FIx if

* Skip frame count check for concatenated instances

---------

Signed-off-by: Patrick Avery <[email protected]>
Co-authored-by: Erik O Gabrielsson <[email protected]>
Co-authored-by: Erik O Gabrielsson <[email protected]>
erikogabrielsson added a commit that referenced this pull request Nov 29, 2023
* Inject Decoder to decode frame data to Image

* Move create method to Decoder

* Add image codecs decoders

* Use decoder to chech if transfer syntax is supported

* Simplify create_instance_dataset()

* Add missing properties

* Fix decoding of color image

* Simplify image codecs decoder

* Config for what decoder to use

* Use pydicom config to get pixel data handlers

* Check if image codecs are available

* Use jpeg codecs directly

* Change supported transfer syntaxes to dict

* Add option to provide a session to the web client (#117)

* Add option to provide web client a session

We would like to create the `requests.Session` object on our own
and pass it into `WsiDicomWebClient`, since we are not using an object
derived from `AuthBase` to create it.

This PR adds support to pass a session to `WsiDicomWebClient` directly.

Signed-off-by: Patrick Avery <[email protected]>

* Refactor __init__ method of WsiDicomWebClient

The `__init__` method now accepts a `DICOMwebClient` object.

The previous `__init__` method was moved into a `create_client()`
class method.

Signed-off-by: Patrick Avery <[email protected]>

* Remove `WsiDicomFileClient` and update README.md

Signed-off-by: Patrick Avery <[email protected]>

---------

Signed-off-by: Patrick Avery <[email protected]>

* Dicomweb get multiple frames (#121)

* Get multiple frames from dicom web

* Allow loading multiple series with DICOMweb (#122)

* Allow loading multiple series with DICOMweb

`WsiDicom.open_web()` was modified to be able to either take a single
series uid (as before) or a list of series uids. If a list of series
uids is passed, their instances are all loaded together. This can be
useful for cases where, for instance, different optical paths are located
in different series.

This also loosens the UID matching to only check the frame of references.

This also adds `TotalPixelMatrixOriginSequence` matching when comparing
datasets.

Fixes: #118

Signed-off-by: Patrick Avery <[email protected]>

* Fix `isinstance()` check for series uids

Signed-off-by: Patrick Avery <[email protected]>

* Fix logic in `SlideUids.matches()`

Signed-off-by: Patrick Avery <[email protected]>

* Remove unused import

Signed-off-by: Patrick Avery <[email protected]>

---------

Signed-off-by: Patrick Avery <[email protected]>

* Add property to count number of tile frames (#116)

* Add property to count number of tile frames

The "NumberOfFrames" attribute on a dataset takes into account not just
the number of frames corresponding to tiles, but also the number of
focal planes and optical paths (for example, see [here](https://github.com/imi-bigpicture/wsidicom/blob/774fe3ca00096e3fd2556fc956520dbfabc81311/wsidicom/instance/dataset.py#L651-L655)).

When I was trying to view a dataset with multiple optical paths, I would
encounter errors in the `image_size` property since it did not distinguish
frames that came from optical paths and tiles.

This fixes viewing [this example](https://imagingdatacommons.github.io/slim/studies/2.25.23897195960526781231486877255455994829/series/2.25.83282858720704132758110891374375550907) via DICOMweb in [large_image](https://github.com/girder/large_image).

I am new to the field, so please feel free to correct any naming issues
or misconceptions...

Signed-off-by: Patrick Avery <[email protected]>

* Add option to provide a session to the web client (#117)

* Add option to provide web client a session

We would like to create the `requests.Session` object on our own
and pass it into `WsiDicomWebClient`, since we are not using an object
derived from `AuthBase` to create it.

This PR adds support to pass a session to `WsiDicomWebClient` directly.

Signed-off-by: Patrick Avery <[email protected]>

* Refactor __init__ method of WsiDicomWebClient

The `__init__` method now accepts a `DICOMwebClient` object.

The previous `__init__` method was moved into a `create_client()`
class method.

Signed-off-by: Patrick Avery <[email protected]>

* Remove `WsiDicomFileClient` and update README.md

Signed-off-by: Patrick Avery <[email protected]>

---------

Signed-off-by: Patrick Avery <[email protected]>

* Dicomweb get multiple frames (#121)

* Get multiple frames from dicom web

* Allow loading multiple series with DICOMweb (#122)

* Allow loading multiple series with DICOMweb

`WsiDicom.open_web()` was modified to be able to either take a single
series uid (as before) or a list of series uids. If a list of series
uids is passed, their instances are all loaded together. This can be
useful for cases where, for instance, different optical paths are located
in different series.

This also loosens the UID matching to only check the frame of references.

This also adds `TotalPixelMatrixOriginSequence` matching when comparing
datasets.

Fixes: #118

Signed-off-by: Patrick Avery <[email protected]>

* Fix `isinstance()` check for series uids

Signed-off-by: Patrick Avery <[email protected]>

* Fix logic in `SlideUids.matches()`

Signed-off-by: Patrick Avery <[email protected]>

* Remove unused import

Signed-off-by: Patrick Avery <[email protected]>

---------

Signed-off-by: Patrick Avery <[email protected]>

* Remove unsafe number_of_focal_planes and number_of_optical_paths properties

* FIx if

* Skip frame count check for concatenated instances

---------

Signed-off-by: Patrick Avery <[email protected]>
Co-authored-by: Erik O Gabrielsson <[email protected]>
Co-authored-by: Erik O Gabrielsson <[email protected]>

* Add encoder

* Move decoder and encoder to codec module

* Test decoder against prepared test files

* Add decode test for pillow

* Tests for encoder

* Add property of samples per pixel

* use pyjpeg-rle for rle encoding

* Combine similar settings

* Fix encoding of uncompressed data

* Fix parameter order

* Add  init for Rle settings

* Fix writing tag length

* Add pillow decoder

* Check if decoder is avaiable

* Make codec packages optional

* Use codec

* Make settings dataclass-y

* Skip test if no test data

* Determine transfer syntax for dicom web through optional qido field

* Try transfer syntax until supported

* Skip image test if no test image

* Skip test if optional package

* Take sequence of requested transfer syntaxes

* Remove wsi-standard options from codec

* Open dicom web with threads

* Update python version

* Use pixel data handles directly

* Update shapely

* Fix typing

* Use test data package

* Rle codec based on image codecs PackBits

* Update packages

* Fix jpeg2k_encode import

* Add checks if codec available, skip tests if not

* Run ci with extras

* Update changelog

* Run codespell

* Fix spelling

* Update version

* Add license

* blank_color can be grey level

* Relax requirement for optical dataset

* Use `x-dicom-rle` for rle as that is what dicomwebclient supports

* Try transfer syntaxes that has been detected for other instances first

* Try-load Lut

* add __all__

* Update changelog

* Update readme

* Change default subsampling to 422

* Test using scaled images

* More compact selection for encoder

* Changelog for release 0.14.0

---------

Signed-off-by: Patrick Avery <[email protected]>
Co-authored-by: Patrick Avery <[email protected]>
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.

Support combining multiple series for DICOMweb
2 participants