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 276921f..d3dd3b0 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "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", + "author": "Bill Wallace, Mateus Freira,Radical Imaging, Ibrahim Mohamed", "keywords": [ "ohif-extension" ], 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..f58e1c5 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 = [] + 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; }