ImagingDataCommons / slim

Interoperable web-based slide microscopy viewer and annotation tool
https://imagingdatacommons.github.io/slim/
Apache License 2.0
111 stars 36 forks source link

Failure to view a seemingly valid SM series: "`resolutions` must be sorted in descending order" #175

Open fedorov opened 8 months ago

fedorov commented 8 months ago

@igoroctaviano can you please help with this? This is a top priority at the moment, since it blocks ingestion of a dataset on our side.

We have Slim failure for this case: https://andrey-slim-test.web.app/studies/2.25.55130914676639429536393362988538406158/series/1.3.6.1.4.1.5962.99.1.1070220424.1519847303.1697582335112.4.0 (restricted access, @igoroctaviano should be clear)

That study/series is located in this DICOM store: https://healthcare.googleapis.com/v1/projects/idc-sandbox-000/locations/us-central1/datasets/fedorov-dev-healthcare/dicomStores/mci-test/dicomWeb (restricted access, @igoroctaviano should be clear), and also in this bucket folder: https://console.cloud.google.com/storage/browser/af-dev-storage/idc-conversion-outputs-mci-test/0DBVRM_121349.

This is the error:

image

Those images were converted by @dclunie, and he had to say the following about this error:

I can't see anything peculiar about these files as compared to any other:

Filename  "Transfer Syntax UID"   "Image Type"    "Primary Anatomic Structure Sequence"   "Primary Anatomic Structure Modifier Sequence"  "Frame Type"    "Clinical Trial Protocol ID"    "Instance Number"   "Frame of Reference UID"    "Photometric Interpretation"    "Number of Frames"  "Rows"  "Columns"   "Pixel Spacing" "Lossy Image Compression"   "Lossy Image Compression Ratio" "Lossy Image Compression Method"    "X Offset in Slide Coordinate System"   "Y Offset in Slide Coordinate System"   "Imaged Volume Width"   "Imaged Volume Height"  "Imaged Volume Depth"   "Image Orientation (Slide)" "Objective Lens Power"
"DCM_0"   "1.2.840.10008.1.2.4.50"    "DERIVED\PRIMARY\VOLUME\NONE "      "('363654007','SCT','Orbit')"   "('108369006','SCT','Tumor')"   "DERIVED\PRIMARY\VOLUME\NONE "      "phs002790 "    "1 "    "1.3.6.1.4.1.5962.99.1.1070220424.1519847303.1697582335112.7.0" "YBR_FULL_422"  "12947 "    "0x0100"    "0x0100"    ".000263447\.000263447 "    "01"    "32.677"    "ISO_10918_1 "  "0 "    "0 "    "8.14578"   "7.17393"   "0" "0\-1\0\-1\0\0 "    "40"
"DCM_1"   "1.2.840.10008.1.2.4.50"    "DERIVED\PRIMARY\THUMBNAIL\RESAMPLED "  "('363654007','SCT','Orbit')"   "('108369006','SCT','Tumor')"   "DERIVED\PRIMARY\THUMBNAIL\RESAMPLED "  "phs002790 "    "2 "    "1.3.6.1.4.1.5962.99.1.1070220424.1519847303.1697582335112.7.0" "YBR_FULL_422"  "1 "    "0x069a"    "0x0780"    ".004243766\.004243766 "    "01"    "62.215"    "ISO_10918_1 "  "0 "    "0 "    "8.14803"   "7.17196"   "0" "0\-1\0\-1\0\0 "    "40"
"DCM_2"   "1.2.840.10008.1.2.4.50"    "DERIVED\PRIMARY\VOLUME\RESAMPLED"  "('363654007','SCT','Orbit')"   "('108369006','SCT','Tumor')"   "DERIVED\PRIMARY\VOLUME\RESAMPLED"  "phs002790 "    "3 "    "1.3.6.1.4.1.5962.99.1.1070220424.1519847303.1697582335112.7.0" "YBR_FULL_422"  "837 "  "0x0100"    "0x0100"    ".001053848\.001053848 "    "01"    "48.133"    "ISO_10918_1 "  "0 "    "0 "    "8.14625"   "7.17354"   "0" "0\-1\0\-1\0\0 "    "40"
"DCM_3"   "1.2.840.10008.1.2.4.50"    "DERIVED\PRIMARY\VOLUME\RESAMPLED"  "('363654007','SCT','Orbit')"   "('108369006','SCT','Tumor')"   "DERIVED\PRIMARY\VOLUME\RESAMPLED"  "phs002790 "    "4 "    "1.3.6.1.4.1.5962.99.1.1070220424.1519847303.1697582335112.7.0" "YBR_FULL_422"  "56"    "0x0100"    "0x0100"    ".004216865\.004216865 "    "01"    "46.599"    "ISO_10918_1 "  "0 "    "0 "    "8.14698"   "7.17289"   "0" "0\-1\0\-1\0\0 "    "40"
"DCM_4"   "1.2.840.10008.1.2.1"       "DERIVED\PRIMARY\LABEL\NONE"        "('363654007','SCT','Orbit')"   "('108369006','SCT','Tumor')"   "DERIVED\PRIMARY\LABEL\NONE"        "phs002790 "    "5 "    "1.3.6.1.4.1.5962.99.1.1070220424.1519847303.1697582335112.7.0" "RGB "  "1 ""0x0269"    "0x0283"    ""  "00"    ""  ""  "0 "    "0 "    ""  ""  ""  "0\-1\0\-1\0\0 "    "40"
"DCM_5"   "1.2.840.10008.1.2.4.50"    "DERIVED\PRIMARY\OVERVIEW\NONE "    "('363654007','SCT','Orbit')"   "('108369006','SCT','Tumor')"   "DERIVED\PRIMARY\OVERVIEW\NONE "    "phs002790 "    "6 "    "1.3.6.1.4.1.5962.99.1.1070220424.1519847303.1697582335112.8.0" "RGB "  "1 "    "0x026c"    "0x05f7"    ".040967741935484\.040967741935484 "    "01"    "15.735"    "ISO_10918_1 "  "0 "    "0 "    "62.5577"   "25.4"  ""  "0\-1\0\-1\0\0 "    "40"

I had no trouble loading this series with QuPath using either OpenSlide or BioFormats.

igoroctaviano commented 8 months ago

@igoroctaviano can you please help with this? This is a top priority at the moment, since it blocks ingestion of a dataset on our side.

We have Slim failure for this case: https://andrey-slim-test.web.app/studies/2.25.55130914676639429536393362988538406158/series/1.3.6.1.4.1.5962.99.1.1070220424.1519847303.1697582335112.4.0 (restricted access, @igoroctaviano should be clear)

That study/series is located in this DICOM store: https://healthcare.googleapis.com/v1/projects/idc-sandbox-000/locations/us-central1/datasets/fedorov-dev-healthcare/dicomStores/mci-test/dicomWeb (restricted access, @igoroctaviano should be clear), and also in this bucket folder: https://console.cloud.google.com/storage/browser/af-dev-storage/idc-conversion-outputs-mci-test/0DBVRM_121349.

This is the error:

image

Those images were converted by @dclunie, and he had to say the following about this error:

I can't see anything peculiar about these files as compared to any other:

Filename    "Transfer Syntax UID"   "Image Type"    "Primary Anatomic Structure Sequence"   "Primary Anatomic Structure Modifier Sequence"  "Frame Type"    "Clinical Trial Protocol ID"    "Instance Number"   "Frame of Reference UID"    "Photometric Interpretation"    "Number of Frames"  "Rows"  "Columns"   "Pixel Spacing" "Lossy Image Compression"   "Lossy Image Compression Ratio" "Lossy Image Compression Method"    "X Offset in Slide Coordinate System"   "Y Offset in Slide Coordinate System"   "Imaged Volume Width"   "Imaged Volume Height"  "Imaged Volume Depth"   "Image Orientation (Slide)" "Objective Lens Power"
"DCM_0" "1.2.840.10008.1.2.4.50"    "DERIVED\PRIMARY\VOLUME\NONE "      "('363654007','SCT','Orbit')"   "('108369006','SCT','Tumor')"   "DERIVED\PRIMARY\VOLUME\NONE "      "phs002790 "    "1 "    "1.3.6.1.4.1.5962.99.1.1070220424.1519847303.1697582335112.7.0" "YBR_FULL_422"  "12947 "    "0x0100"    "0x0100"    ".000263447\.000263447 "    "01"    "32.677"    "ISO_10918_1 "  "0 "    "0 "    "8.14578"   "7.17393"   "0" "0\-1\0\-1\0\0 "    "40"
"DCM_1" "1.2.840.10008.1.2.4.50"    "DERIVED\PRIMARY\THUMBNAIL\RESAMPLED "  "('363654007','SCT','Orbit')"   "('108369006','SCT','Tumor')"   "DERIVED\PRIMARY\THUMBNAIL\RESAMPLED "  "phs002790 "    "2 "    "1.3.6.1.4.1.5962.99.1.1070220424.1519847303.1697582335112.7.0" "YBR_FULL_422"  "1 "    "0x069a"    "0x0780"    ".004243766\.004243766 "    "01"    "62.215"    "ISO_10918_1 "  "0 "    "0 "    "8.14803"   "7.17196"   "0" "0\-1\0\-1\0\0 "    "40"
"DCM_2" "1.2.840.10008.1.2.4.50"    "DERIVED\PRIMARY\VOLUME\RESAMPLED"  "('363654007','SCT','Orbit')"   "('108369006','SCT','Tumor')"   "DERIVED\PRIMARY\VOLUME\RESAMPLED"  "phs002790 "    "3 "    "1.3.6.1.4.1.5962.99.1.1070220424.1519847303.1697582335112.7.0" "YBR_FULL_422"  "837 "  "0x0100"    "0x0100"    ".001053848\.001053848 "    "01"    "48.133"    "ISO_10918_1 "  "0 "    "0 "    "8.14625"   "7.17354"   "0" "0\-1\0\-1\0\0 "    "40"
"DCM_3" "1.2.840.10008.1.2.4.50"    "DERIVED\PRIMARY\VOLUME\RESAMPLED"  "('363654007','SCT','Orbit')"   "('108369006','SCT','Tumor')"   "DERIVED\PRIMARY\VOLUME\RESAMPLED"  "phs002790 "    "4 "    "1.3.6.1.4.1.5962.99.1.1070220424.1519847303.1697582335112.7.0" "YBR_FULL_422"  "56"    "0x0100"    "0x0100"    ".004216865\.004216865 "    "01"    "46.599"    "ISO_10918_1 "  "0 "    "0 "    "8.14698"   "7.17289"   "0" "0\-1\0\-1\0\0 "    "40"
"DCM_4" "1.2.840.10008.1.2.1"       "DERIVED\PRIMARY\LABEL\NONE"        "('363654007','SCT','Orbit')"   "('108369006','SCT','Tumor')"   "DERIVED\PRIMARY\LABEL\NONE"        "phs002790 "    "5 "    "1.3.6.1.4.1.5962.99.1.1070220424.1519847303.1697582335112.7.0" "RGB "  "1 ""0x0269"    "0x0283"    ""  "00"    ""  ""  "0 "    "0 "    ""  ""  ""  "0\-1\0\-1\0\0 "    "40"
"DCM_5" "1.2.840.10008.1.2.4.50"    "DERIVED\PRIMARY\OVERVIEW\NONE "    "('363654007','SCT','Orbit')"   "('108369006','SCT','Tumor')"   "DERIVED\PRIMARY\OVERVIEW\NONE "    "phs002790 "    "6 "    "1.3.6.1.4.1.5962.99.1.1070220424.1519847303.1697582335112.8.0" "RGB "  "1 "    "0x026c"    "0x05f7"    ".040967741935484\.040967741935484 "    "01"    "15.735"    "ISO_10918_1 "  "0 "    "0 "    "62.5577"   "25.4"  ""  "0\-1\0\-1\0\0 "    "40"

I had no trouble loading this series with QuPath using either OpenSlide or BioFormats.

Sure, I'll take a look at it.

igoroctaviano commented 8 months ago

@fedorov This was caused by rounding the zoom factor.

(level 0) baseTotalPixelMatrixColumns / totalPixelMatrixColumns = 30920 / 30920 = 1 (level 1) baseTotalPixelMatrixColumns / totalPixelMatrixColumns = 30920 / 1932 = 16.00414078674948 (16) (level 2) baseTotalPixelMatrixColumns / totalPixelMatrixColumns = 30920 / 1920 = 16.104166666666668 (16)

This way the resolutions array will be [16, 16, 1], and although its descending OpenLayers assertion doesn't allow equivalent numbers, the resolutions array should be composed of unique resolutions in descending order.

Removing the rounding here: https://github.com/ImagingDataCommons/dicom-microscopy-viewer/blob/bda0cfea6f906a7c46f525cad2a5210d0722869b/src/pyramid.js#L211

Results:

Screenshot 2023-10-30 at 19 21 13
fedorov commented 8 months ago

This is interesting. Why would there be two resolutions that are so close to each other? I would want to wait to hear back from @dclunie to confirm this is expected.

@DanielaSchacherer have you ever seen this in any other dataset?

DanielaSchacherer commented 7 months ago

This is indeed interesting. As you might remember we also had some issues with different resolutions being available or not being available and how to deal with that. But I can't remember that we had two resolutions being so close to each other. @ahomeyer - do you remember anything about that?

ahomeyer commented 7 months ago

I never encountered a problem like this.

fedorov commented 7 months ago

Upon discussing this with @dclunie today, it is very suspicious that it is the thumbnail image that has nearly the same resolution as one of the pyramid layers. David will look again at the data and conversion process. No action from you at this point @igoroctaviano! Thank you for the investigation.

dclunie commented 7 months ago

Though it is unusual for the thumbnail to have a pixel spacing close to one of the other pyramid layer files, this seems to be what is actually in the TIFF file and the way the images actually are - look at the MPP values and the Image Width and Image Length for the relevant entries; so the issue does not seem to be with the data but the viewer's inability to handle this unusual situation (of two layers of similar size - not sure if "Avoid rounding zoom factors that are too close to avoid duplicated resolution errors" #107 fixes this or not):

TIFF Directory at offset 0x49b8138 (77300024)
  Subfile Type: (0 = 0x0)
  Image Width: 30920 Image Length: 27231 Image Depth: 1
  Tile Width: 256 Tile Length: 256
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Planar Configuration: single image plane
  ImageDescription: Aperio Leica Biosystems GT450 v1.0.1 
30920x27231 [0,0,30920x27231] (256x256) JPEG/YCC Q=91|AppMag = 40|Date = 07/05/2023|Exposure Scale = 0.000001|Exposure Time = 8|Filtered = 3|Focus Offset = 0.500000|Gamma = 2.2|Left = 16.38109588623|MPP = 0.263447|Rack = 10|ScanScope ID = SS12035|Slide = 6|StripeWidth = 4096|Time = 12:13:49|Time Zone = GMT-0400|Top = 33.567771911621
  ICC Profile: <present>, 13113264 bytes
TIFF Directory at offset 0x56927fa (90777594)
  Subfile Type: (0 = 0x0)
  Image Width: 1920 Image Length: 1690
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Rows/Strip: 1690
  Planar Configuration: single image plane
  ImageDescription: Aperio Leica Biosystems GT450 v1.0.1 
1920x1690 [0,0,1920x1690] (1920x1690) JPEG/YCC Q=100|AppMag = 40|Date = 07/05/2023|Exposure Scale = 0.000001|Exposure Time = 8|Focus Offset = 0.000000|Left = 25.012786865234|MPP = 4.243766|Rack = 10|ScanScope ID = SS12035|Slide = 6|StripeWidth = 4096|Time = 12:13:49|Time Zone = GMT-0400|Top = 9.207160949707
  ICC Profile: <present>, 13113264 bytes
TIFF Directory at offset 0x6634cb4 (107170996)
  Subfile Type: (0 = 0x0)
  Image Width: 7730 Image Length: 6807
  Tile Width: 256 Tile Length: 256
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Planar Configuration: single image plane
  ImageDescription: Aperio Leica Biosystems GT450 v1.0.1 
7730x6807 [0,0,7730x6807] (256x256) JPEG/YCC Q=91|AppMag = 40|Date = 07/05/2023|Exposure Scale = 0.000001|Exposure Time = 8|Filtered = 3|Focus Offset = 0.500000|Gamma = 2.2|Left = 16.380306243896|MPP = 1.053848|Rack = 10|ScanScope ID = SS12035|Slide = 6|StripeWidth = 4096|Time = 12:13:49|Time Zone = GMT-0400|Top = 33.567771911621
  ICC Profile: <present>, 13113264 bytes
TIFF Directory at offset 0x72ed5c0 (120509888)
  Subfile Type: (0 = 0x0)
  Image Width: 1932 Image Length: 1701
  Tile Width: 256 Tile Length: 256
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Planar Configuration: single image plane
  ImageDescription: Aperio Leica Biosystems GT450 v1.0.1 
1932x1701 [0,0,1932x1701] (256x256) JPEG/YCC Q=91|AppMag = 40|Date = 07/05/2023|Exposure Scale = 0.000001|Exposure Time = 8|Filtered = 3|Focus Offset = 0.500000|Gamma = 2.2|Left = 16.377145767212|MPP = 4.216865|Rack = 10|ScanScope ID = SS12035|Slide = 6|StripeWidth = 4096|Time = 12:13:49|Time Zone = GMT-0400|Top = 33.567771911621
  ICC Profile: <present>, 13113264 bytes
TIFF Directory at offset 0x802a4aa (134390954)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 643 Image Length: 617
  Bits/Sample: 8
  Compression Scheme: LZW
  Photometric Interpretation: RGB color
  Samples/Pixel: 3
  Rows/Strip: 617
  Planar Configuration: single image plane
  ImageDescription: Aperio Leica Biosystems GT450 v1.0.1 
label 643x617
  Predictor: horizontal differencing 2 (0x2)
TIFF Directory at offset 0x8056708 (134571784)
  Subfile Type: reduced-resolution image (9 = 0x9)
  Image Width: 1527 Image Length: 620
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: RGB color
  Samples/Pixel: 3
  Rows/Strip: 620
  Planar Configuration: single image plane
  ImageDescription: Aperio Leica Biosystems GT450 v1.0.1 
macro 1527x620
igoroctaviano commented 7 months ago

Though it is unusual for the thumbnail to have a pixel spacing close to one of the other pyramid layer files, this seems to be what is actually in the TIFF file and the way the images actually are - look at the MPP values and the Image Width and Image Length for the relevant entries; so the issue does not seem to be with the data but the viewer's inability to handle this unusual situation (of two layers of similar size - not sure if "Avoid rounding zoom factors that are too close to avoid duplicated resolution errors" #107 fixes this or not):

TIFF Directory at offset 0x49b8138 (77300024)
  Subfile Type: (0 = 0x0)
  Image Width: 30920 Image Length: 27231 Image Depth: 1
  Tile Width: 256 Tile Length: 256
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Planar Configuration: single image plane
  ImageDescription: Aperio Leica Biosystems GT450 v1.0.1 
30920x27231 [0,0,30920x27231] (256x256) JPEG/YCC Q=91|AppMag = 40|Date = 07/05/2023|Exposure Scale = 0.000001|Exposure Time = 8|Filtered = 3|Focus Offset = 0.500000|Gamma = 2.2|Left = 16.38109588623|MPP = 0.263447|Rack = 10|ScanScope ID = SS12035|Slide = 6|StripeWidth = 4096|Time = 12:13:49|Time Zone = GMT-0400|Top = 33.567771911621
  ICC Profile: <present>, 13113264 bytes
TIFF Directory at offset 0x56927fa (90777594)
  Subfile Type: (0 = 0x0)
  Image Width: 1920 Image Length: 1690
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Rows/Strip: 1690
  Planar Configuration: single image plane
  ImageDescription: Aperio Leica Biosystems GT450 v1.0.1 
1920x1690 [0,0,1920x1690] (1920x1690) JPEG/YCC Q=100|AppMag = 40|Date = 07/05/2023|Exposure Scale = 0.000001|Exposure Time = 8|Focus Offset = 0.000000|Left = 25.012786865234|MPP = 4.243766|Rack = 10|ScanScope ID = SS12035|Slide = 6|StripeWidth = 4096|Time = 12:13:49|Time Zone = GMT-0400|Top = 9.207160949707
  ICC Profile: <present>, 13113264 bytes
TIFF Directory at offset 0x6634cb4 (107170996)
  Subfile Type: (0 = 0x0)
  Image Width: 7730 Image Length: 6807
  Tile Width: 256 Tile Length: 256
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Planar Configuration: single image plane
  ImageDescription: Aperio Leica Biosystems GT450 v1.0.1 
7730x6807 [0,0,7730x6807] (256x256) JPEG/YCC Q=91|AppMag = 40|Date = 07/05/2023|Exposure Scale = 0.000001|Exposure Time = 8|Filtered = 3|Focus Offset = 0.500000|Gamma = 2.2|Left = 16.380306243896|MPP = 1.053848|Rack = 10|ScanScope ID = SS12035|Slide = 6|StripeWidth = 4096|Time = 12:13:49|Time Zone = GMT-0400|Top = 33.567771911621
  ICC Profile: <present>, 13113264 bytes
TIFF Directory at offset 0x72ed5c0 (120509888)
  Subfile Type: (0 = 0x0)
  Image Width: 1932 Image Length: 1701
  Tile Width: 256 Tile Length: 256
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Planar Configuration: single image plane
  ImageDescription: Aperio Leica Biosystems GT450 v1.0.1 
1932x1701 [0,0,1932x1701] (256x256) JPEG/YCC Q=91|AppMag = 40|Date = 07/05/2023|Exposure Scale = 0.000001|Exposure Time = 8|Filtered = 3|Focus Offset = 0.500000|Gamma = 2.2|Left = 16.377145767212|MPP = 4.216865|Rack = 10|ScanScope ID = SS12035|Slide = 6|StripeWidth = 4096|Time = 12:13:49|Time Zone = GMT-0400|Top = 33.567771911621
  ICC Profile: <present>, 13113264 bytes
TIFF Directory at offset 0x802a4aa (134390954)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 643 Image Length: 617
  Bits/Sample: 8
  Compression Scheme: LZW
  Photometric Interpretation: RGB color
  Samples/Pixel: 3
  Rows/Strip: 617
  Planar Configuration: single image plane
  ImageDescription: Aperio Leica Biosystems GT450 v1.0.1 
label 643x617
  Predictor: horizontal differencing 2 (0x2)
TIFF Directory at offset 0x8056708 (134571784)
  Subfile Type: reduced-resolution image (9 = 0x9)
  Image Width: 1527 Image Length: 620
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: RGB color
  Samples/Pixel: 3
  Rows/Strip: 620
  Planar Configuration: single image plane
  ImageDescription: Aperio Leica Biosystems GT450 v1.0.1 
macro 1527x620

The PR addresses the issue. If the rounded zoom factor conflicts with an existent one, I'm using the zoom factor value rounded to three decimals which doesn't cause conflicts with existent ones and loads the image fine. We could just skip the "too close" resolution too.