Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(createImageIdsAndCacheMetaData): Add Sort Instance Number #1305

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion utils/demo/helpers/createImageIdsAndCacheMetaData.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default async function createImageIdsAndCacheMetaData({
const SOP_INSTANCE_UID = '00080018';
const SERIES_INSTANCE_UID = '0020000E';
const MODALITY = '00080060';
const INSTANCE_NUMBER = '00200013';

const studySearchOptions = {
studyInstanceUID: StudyInstanceUID,
Expand All @@ -51,7 +52,12 @@ export default async function createImageIdsAndCacheMetaData({
}

const modality = instances[0][MODALITY].Value[0];
let imageIds = instances.map((instanceMetaData) => {

const sortedInstances = Object.values(instances).sort(
(a, b) => a[INSTANCE_NUMBER].Value[0] - b[INSTANCE_NUMBER].Value[0]
);
Comment on lines +56 to +58
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you will be interested in checking out this helper: utilities.sortImageIdsAndGetSpacing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already tested it and it's not right.

image

async function fetchDicom() {
    // Get Cornerstone imageIds for the source data and fetch metadata into RAM
    imageIds = await createImageIdsAndCacheMetaData(dev.getConfig.fetchDicom);

    //
    const { sortedImageIds } = csUtilities.sortImageIdsAndGetSpacing(imageIds);

    //
    await loadDicom(sortedImageIds.reverse());
}


let imageIds = sortedInstances.map((instanceMetaData) => {
const SeriesInstanceUID = instanceMetaData[SERIES_INSTANCE_UID].Value[0];
const SOPInstanceUIDToUse =
SOPInstanceUID || instanceMetaData[SOP_INSTANCE_UID].Value[0];
Expand Down