Skip to content

Commit 032df04

Browse files
fix: Turn off interpolation for special unmatched resolution seg case (#196)
* Turn off interpolation for special matching case * Update ol version and address points layer issue * Update interpolate criteria for segmentation * Lint * Add skip thumbnails option
1 parent 455e63c commit 032df04

File tree

4 files changed

+95
-152
lines changed

4 files changed

+95
-152
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"dicomicc": "^0.1",
7878
"image-type": "^4.1",
7979
"mathjs": "^11.2",
80-
"ol": "^10.4.0",
80+
"ol": "^10.6.0",
8181
"uuid": "^9.0"
8282
},
8383
"resolutions": {

src/pyramid.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function _computeImagePyramid ({ metadata }) {
146146
rawMetadata['00280008'].Value[0] += numberOfFrames
147147
if ('PerFrameFunctionalGroupsSequence' in metadata[index]) {
148148
rawMetadata['52009230'].Value.push(
149-
...metadata[i].PerFrameFunctionalGroupsSequence
149+
...metadata[index].PerFrameFunctionalGroupsSequence
150150
)
151151
}
152152
if (!('SOPInstanceUIDOfConcatenationSource' in metadata[i])) {
@@ -613,13 +613,14 @@ function _fitImagePyramid (pyramid, refPyramid) {
613613
console.warn('No matching pyramid levels found, handling fixed pixel spacing case...')
614614

615615
const refBaseLevel = refPyramid.metadata[refPyramid.metadata.length - 1]
616-
const refBaseTotalPixelMatrixColumns = refBaseLevel.TotalPixelMatrixColumns
617616

618617
for (let j = 0; j < pyramid.metadata.length; j++) {
619-
const imageLevel = pyramid.metadata[j]
620-
const totalPixelMatrixColumns = imageLevel.TotalPixelMatrixColumns
618+
const segmentation = pyramid.metadata[j]
619+
const refBasePixelSpacing = getPixelSpacing(refBaseLevel)
620+
const segPixelSpacing = getPixelSpacing(segmentation)
621621

622-
const resolution = refBaseTotalPixelMatrixColumns / totalPixelMatrixColumns
622+
/** Calculate resolution based on ratio of pixel spacings */
623+
const resolution = segPixelSpacing[0] / refBasePixelSpacing[0]
623624
const roundedResolution = Math.round(resolution)
624625

625626
/** Handle resolution conflicts similar to _computeImagePyramid */
@@ -674,7 +675,9 @@ function _fitImagePyramid (pyramid, refPyramid) {
674675
}
675676
}
676677

677-
return [fittedPyramid, minZoom, maxZoom]
678+
const hasMatchingLevels = matchingLevelIndices.length > 0
679+
680+
return [fittedPyramid, minZoom, maxZoom, hasMatchingLevels]
678681
}
679682

680683
export {

0 commit comments

Comments
 (0)