From 167db85f5142e174f58d6127c18e761acd649b83 Mon Sep 17 00:00:00 2001 From: Ibrahim <93064150+IbrahimCSAE@users.noreply.github.com> Date: Thu, 19 Oct 2023 00:36:12 -0400 Subject: [PATCH 1/4] fixes --- src/createDicomWebTreeApi.ts | 4 +-- src/imageLoader/loadImageSets.ts | 49 +++++++++++++++++++------------- src/utils/DicomTreeClient.ts | 17 +++++++++-- 3 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/createDicomWebTreeApi.ts b/src/createDicomWebTreeApi.ts index b5d3350..a8d68c6 100644 --- a/src/createDicomWebTreeApi.ts +++ b/src/createDicomWebTreeApi.ts @@ -514,9 +514,9 @@ function createDicomWebTreeApi(dicomWebConfig, UserAuthenticationService) { return imageIds; }, - getImageIdsForInstance({ instance, frame = 1 }) { + getImageIdsForInstance({ instance, frame = 0 }) { const { DatastoreID, ImageFrames, ImageSetID } = instance; - const frameID = ImageFrames?.[frame - 1]?.ID; + const frameID = ImageFrames?.[frame]?.ID; const healthlakeParam = qidoDicomWebClient.healthlake?.images ? "true" : "false"; const extraParameters = (DatastoreID && { diff --git a/src/imageLoader/loadImageSets.ts b/src/imageLoader/loadImageSets.ts index d448cc1..61de99c 100644 --- a/src/imageLoader/loadImageSets.ts +++ b/src/imageLoader/loadImageSets.ts @@ -24,25 +24,36 @@ const getBody = (awsFilter) => { } async function getImageSets(datastoreId, config, awsFilter, _nextToken = '') { - const uri = `${config.endpoint}/datastore/${datastoreId}/searchImageSets?maxResults=50&${_nextToken ? 'nextToken='+_nextToken : ''}`; - - const body = getBody(awsFilter) - - const response = await getFetch(config)(uri, { - method: 'POST', - headers: { - "Content-type": "application/json" - }, - body: JSON.stringify(body) - }) - const { - imageSetsMetadataSummaries, - nextToken - } = await response.json(); - if (nextToken) { - return imageSetsMetadataSummaries.concat(await getImageSets(datastoreId, config, awsFilter, nextToken)); - } - return imageSetsMetadataSummaries; + + console.log('awsFilter=', awsFilter) + + let imageSetSummaries : any[] = [] + const maxImageSetsToReturn = 300 + do { + + const uri = `${config.endpoint}/datastore/${datastoreId}/searchImageSets?maxResults=50&${_nextToken ? 'nextToken='+_nextToken : ''}`; + + const body = getBody(awsFilter) + + const response = await getFetch(config)(uri, { + method: 'POST', + headers: { + "Content-type": "application/json" + }, + body: JSON.stringify(body) + }) + const { + imageSetsMetadataSummaries, + nextToken + } = await response.json(); + + console.log('imageSetsMetadataSummaries', imageSetsMetadataSummaries) + + imageSetSummaries = imageSetSummaries.concat(imageSetsMetadataSummaries) + _nextToken = nextToken + + } while (imageSetSummaries.length < maxImageSetsToReturn && _nextToken) + return imageSetSummaries; } const loadImageSetsCache = new Map(); diff --git a/src/utils/DicomTreeClient.ts b/src/utils/DicomTreeClient.ts index c80cac8..f256ef2 100644 --- a/src/utils/DicomTreeClient.ts +++ b/src/utils/DicomTreeClient.ts @@ -130,7 +130,7 @@ export default class DicomTreeClient extends api.DICOMwebClient { datastoreID = this.healthlake?.datastoreID, } = options; if (this.healthlake) { - const studies = await this.searchForStudies({ + let studies = await this.searchForStudies({ ...options, queryParams: { StudyInstanceUID: studyInstanceUID @@ -145,7 +145,20 @@ export default class DicomTreeClient extends api.DICOMwebClient { const metadataLoaded = await loadMetaDataInternal(datastoreID, imageSetId, this.healthlake); return enrichImageSetMetadataWithImageSetId(metadataLoaded, imageSetId); })); - const finalMetadata = reduceMetadata(metadataArray, this.healthlake); + let finalMetadata = reduceMetadata(metadataArray); + // filter out PR + const keys = Object.keys(finalMetadata.Study.Series) + + for(const key of keys) { + const series = finalMetadata.Study.Series[key] + for(const key2 of Object.keys(series.Instances)) { + const instance = series.Instances[key2] + // HACK workaround for bug in Cornerstone with floating point rescale slope causing thumbnails to look wrong (speckled) + instance.DICOM.RescaleSlope = Math.floor(instance.DICOM.RescaleSlope) + instance.DICOM.RescaleIntercept = Math.floor(instance.DICOM.RescaleIntercept) + } + } + return finalMetadata; } From 7686a0723d26790b5a779ddc0c3a2c93cada9a9e Mon Sep 17 00:00:00 2001 From: Ibrahim <93064150+IbrahimCSAE@users.noreply.github.com> Date: Thu, 19 Oct 2023 00:37:50 -0400 Subject: [PATCH 2/4] 0.9.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 276921f..46562f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ohif-aws-healthimaging", - "version": "0.9.1", + "version": "0.9.2", "description": "Support reading tree structured metadata", "author": "Bill Wallace, Mateus Freira,Radical Imaging", "keywords": [ From 972a9abfd080d8f5499298dd9952864f6f8d040f Mon Sep 17 00:00:00 2001 From: Ibrahim <93064150+IbrahimCSAE@users.noreply.github.com> Date: Thu, 19 Oct 2023 00:39:12 -0400 Subject: [PATCH 3/4] remove ts --- src/imageLoader/loadImageSets.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/imageLoader/loadImageSets.ts b/src/imageLoader/loadImageSets.ts index 61de99c..f58e1c5 100644 --- a/src/imageLoader/loadImageSets.ts +++ b/src/imageLoader/loadImageSets.ts @@ -27,7 +27,7 @@ async function getImageSets(datastoreId, config, awsFilter, _nextToken = '') { console.log('awsFilter=', awsFilter) - let imageSetSummaries : any[] = [] + let imageSetSummaries = [] const maxImageSetsToReturn = 300 do { From 52a6fe9e543f42aa5cedcfcc5f41bd3900cd9354 Mon Sep 17 00:00:00 2001 From: Ibrahim <93064150+IbrahimCSAE@users.noreply.github.com> Date: Thu, 19 Oct 2023 00:39:58 -0400 Subject: [PATCH 4/4] read me --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cb58890..dca6218 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ Support metadata and imaging data loading from AWS HealthImaging ## Authors -Bill Wallace, Mateus Freira, Radical Imaging, Chris Hafey +Bill Wallace, Mateus Freira, Radical Imaging, Chris Hafey, Ibrahim Mohamed ## License MIT diff --git a/package.json b/package.json index 46562f7..d3dd3b0 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "ohif-aws-healthimaging", "version": "0.9.2", "description": "Support reading tree structured metadata", - "author": "Bill Wallace, Mateus Freira,Radical Imaging", + "author": "Bill Wallace, Mateus Freira,Radical Imaging, Ibrahim Mohamed", "keywords": [ "ohif-extension" ],