Skip to content

Commit

Permalink
Merge pull request #24 from RadicalImaging/chris-fixes
Browse files Browse the repository at this point in the history
fixes
  • Loading branch information
IbrahimCSAE authored Oct 19, 2023
2 parents 6f15e32 + 52a6fe9 commit 3ca3f7c
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
4 changes: 2 additions & 2 deletions src/createDicomWebTreeApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 && {
Expand Down
49 changes: 30 additions & 19 deletions src/imageLoader/loadImageSets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
17 changes: 15 additions & 2 deletions src/utils/DicomTreeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand Down

0 comments on commit 3ca3f7c

Please sign in to comment.