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

Read and set several metadata items, if available #1378

Merged
merged 5 commits into from
Dec 14, 2023

Conversation

psavery
Copy link
Collaborator

@psavery psavery commented Nov 17, 2023

When DICOMweb series are imported, several metadata entries from each series are now extracted and set on the item metadata.

We are extracting most of the metadata that is displayed in the SLIM viewer: https://imagingdatacommons.github.io/slim/

Most of the metadata entries are available as series-level metadata items. However, some of the metadata entries are only available on the instances themselves (in particular, the "Specimen" information, which is nested several dataset layers deep).

The SLIM viewer sets most of its metadata by locating the first WSI Volume dataset, and using that (it appears that the metadata for WSI volume datasets in a series are almost completely identical to other WSI volume datasets in the series). We are also using that approach here.

We are using a slightly different approach for displaying the Specimen metadata, but that is something we can always improve upon.

Additionally, the SLIM viewer is finding the first WSI Volume dataset in a whole study, and using that for the metadata for the whole study. We are currently doing it on a series-level, though (we find the first WSI Volume dataset for a series, and use that to set the metadata on the girder item that represents that series).

Here are some examples:

TCGA-05-4244

C3N-01016

HTA9_1

Fixes: #1314

@psavery psavery force-pushed the dicomweb-metadata branch 2 times, most recently from 75ee764 to 3c05c99 Compare November 17, 2023 22:20
@manthey
Copy link
Member

manthey commented Nov 19, 2023

This is great. In other tile sources, we have an internal source dictionary (read when the source is opened) that is exposed via the tile source's getInternalMetadata method. This data can optionally be shown on the item page (see the settings on the large_image plugin). I'm wondering if this would be better served to be exposed that way, as that data would be available when large_image is used without girder and the dicom image is opened just via url.

@psavery psavery force-pushed the dicomweb-metadata branch 2 times, most recently from 5302826 to 59a2526 Compare November 24, 2023 16:02
@psavery
Copy link
Collaborator Author

psavery commented Nov 30, 2023

This is great. In other tile sources, we have an internal source dictionary (read when the source is opened) that is exposed via the tile source's getInternalMetadata method. This data can optionally be shown on the item page (see the settings on the large_image plugin). I'm wondering if this would be better served to be exposed that way, as that data would be available when large_image is used without girder and the dicom image is opened just via url.

Yeah, we can do this! Would we move the REST calls that request for the DICOMweb metadata somewhere else, like inside getInternalMetadata()? Or, for girder, keep them in the database, and add a new method that DICOMGirderTileSource will override that gets the metadata from the database?

@manthey
Copy link
Member

manthey commented Dec 1, 2023

This is great. In other tile sources, we have an internal source dictionary (read when the source is opened) that is exposed via the tile source's getInternalMetadata method. This data can optionally be shown on the item page (see the settings on the large_image plugin). I'm wondering if this would be better served to be exposed that way, as that data would be available when large_image is used without girder and the dicom image is opened just via url.

Yeah, we can do this! Would we move the REST calls that request for the DICOMweb metadata somewhere else, like inside getInternalMetadata()? Or, for girder, keep them in the database, and add a new method that DICOMGirderTileSource will override that gets the metadata from the database?

Yes, inside getInternalMetadata is fine, but we should cache the results so if getInternalMetadata is called multiple times we only fetch it once. If that cache is done on a method (e.g., getInternalMetadata() calls _getDicomMetadata() or some better name), then we should be able to just override that method in the girder tile source; we don't have to do a database lookup there, since the meta tags will be located in self.item['meta'] (but, bear in mind that other metadata might have been added, too).

@psavery psavery force-pushed the dicomweb-metadata branch 2 times, most recently from a3e086e to 7f10a70 Compare December 5, 2023 18:43
@psavery
Copy link
Collaborator Author

psavery commented Dec 5, 2023

@manthey Here is a summary of changes from the latest commit. Please feel free to ask for any changes:

  1. A _getDicomMetadata() function was added, that getInternalMetadata() now calls. getInternalMetadata() now returns two forms of the metadata: one in the dicom key (the old way, using dicom_to_dict), and one in the dicom_meta key, using the new _getDicomMetadata().
  2. The _getDicomMetadata() is cached, and it works for both girder and non-girder tile sources (the girder version overrides the _getDicomMetadata() method so it can get the results from the database). It also works for both file tile sources and DICOMweb tile sources.
  3. The girder DICOMweb version stores this metadata in the database in two places: one is on meta so the user can see it (and modify it), and the other is dicom_meta, which is uneditable by the user and used by _getDicomMetadata().

When DICOMweb series are imported, several metadata entries from each
series are now extracted and set on the item metadata.

We are extracting most of the metadata that is displayed in the SLIM
viewer: https://imagingdatacommons.github.io/slim/

Most of the metadata entries are available as series-level metadata
items. However, some of the metadata entries are only available on
the instances themselves (in particular, the "Specimen" information,
which is nested several dataset layers deep).

The SLIM viewer sets most of its metadata by locating the first
WSI Volume dataset, and using that (it appears that the metadata
for WSI volume datasets in a series are almost completely identical
to other WSI volume datasets in the series). We are also using that
approach here.

We are using a slightly different approach for displaying the Specimen
metadata, but that is something we can always improve upon.

Additionally, the SLIM viewer is finding the first WSI Volume dataset
in a whole study, and using that for the metadata for the whole study.
We are currently doing it on a series-level, though (we find the first
WSI Volume dataset for a series, and use that to set the metadata on
the girder item that represents that series).

Fixes: girder#1314

Signed-off-by: Patrick Avery <[email protected]>
We also added some logic so it will work for non-girder tile sources,
both for local files and for DICOMweb files.

Signed-off-by: Patrick Avery <[email protected]>
This also only stores the dicomweb metadata in the item for actual
DICOMweb cases. The regular file cases will just call the super() method.

Signed-off-by: Patrick Avery <[email protected]>
Signed-off-by: Patrick Avery <[email protected]>
Just in case it is modified by some girder event...

Signed-off-by: Patrick Avery <[email protected]>
@manthey manthey merged commit b033f18 into girder:master Dec 14, 2023
12 checks passed
@psavery psavery deleted the dicomweb-metadata branch December 16, 2023 03:30
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.

Add support for metadata to DICOMweb assets
2 participants