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

[Feature] Implement custom sorting of series in study panel #4083

Open
sedghi opened this issue May 4, 2024 · 8 comments
Open

[Feature] Implement custom sorting of series in study panel #4083

sedghi opened this issue May 4, 2024 · 8 comments
Assignees
Labels
Design Needed Epic Epic fixed-in-dev-await-release This issue is fixed in master (viewer-dev) but we are pending testing for release (viewer.ohif.org)

Comments

@sedghi
Copy link
Member

sedghi commented May 4, 2024

@IbrahimCSAE Updated the descriptions on this, thanks !

Context

The goal of this epic is to enhance the OHIF Viewer by implementing a custom sorting feature for series within the study panel. This feature will improve the user experience by allowing users to sort series based on different criteria, such as acquisition datetime, series number, or any other relevant metadata.

Background

The current implementation of the OHIF Viewer does not support flexible sorting of series in the study panel. Users have requested the ability to sort series according to specific needs, which is essential for efficient navigation and review of medical images. This feature has been highlighted in various issues and discussions within the OHIF community.

Related Issues and Discussions

Objectives

Custom Sorting Implementation: Allow users to sort series based on various criteria.

  • AcquisitionDate
  • Series Number
  • Modality
  • Any other relevant DICOM metadata

User Interface Enhancements:

  • Update the study panel UI to include sorting options.
  • Provide an intuitive and user-friendly sorting interface.

Allow users to override the initially used default sort

  • Create a customization module to replace the default sort if available on study panel load
@sedghi sedghi added Awaiting Reproduction Can we reproduce the reported bug? and removed Awaiting Reproduction Can we reproduce the reported bug? labels May 4, 2024
@sedghi sedghi self-assigned this May 4, 2024
@niirdan
Copy link

niirdan commented May 5, 2024

@sedghi thanks for gathering all information , unfortunately all of them are unsolved / answered
currently I'm trying to implement a custom function which solve this topic, hope to hear from someone which already deal with this subject

@niirdan
Copy link

niirdan commented May 5, 2024

UPDATE :

function getDisplaySetsFromSeries(instances) {
  // If the series has no instances, stop here
  if (!instances || !instances.length) {
    throw new Error('No instances were provided');
  }

  var displaySets = [];
  const sopClassUids = getSopClassUids(instances);

  // Search through the instances (InstanceMetadata object) of this series
  // Split Multi-frame instances and Single-image modalities
  // into their own specific display sets. Place the rest of each
  // series into another display set.
  const stackableInstances = [];
  instances.forEach(instance => {
    // All imaging modalities must have a valid value for sopClassUid (x00080016) or rows (x00280010)
    if (!isImage(instance.SOPClassUID) && !instance.Rows) {
      return;
    }

    let displaySet;

    //if (isMultiFrame(instance)) {
    displaySet = makeDisplaySet([instance]);

    displaySet.setAttributes({
      sopClassUids,
      isClip: isMultiFrame(instance) === true ? true : false,
      instanceNumber: instance.InstanceNumber,
      acquisitionDatetime: instance.AcquisitionDateTime,
    });
    // Case when Clip set numImagesFrames to be number of frames
    if (instance.NumberOfFrames !== undefined) {
      displaySet.setAttribute('numImageFrames', instance.NumberOfFrames)
    }
    displaySets.push(displaySet);
    //} else if (isSingleImageModality(instance.Modality)) {
    // displaySet = makeDisplaySet([instance]);
    //displaySet.setAttributes({
    // sopClassUids,
    // instanceNumber: instance.InstanceNumber,
    // acquisitionDatetime: instance.AcquisitionDateTime
    //});
    // displaySets.push(displaySet);
    // } else {
    //   stackableInstances.push(instance);
    // }
  });
  // igorned - never arrive this statement
  if (stackableInstances.length) {
    const displaySet = makeDisplaySet(stackableInstances);
    displaySet.setAttribute('studyInstanceUid', instances[0].StudyInstanceUID);
    displaySet.setAttributes({
      sopClassUids,
    });
    displaySets.push(displaySet);
  }

  function sortByAcquisitionDatetime(a, b) {
    if (a.acquisitionDatetime && b.acquisitionDatetime) {
      return a.acquisitionDatetime.localeCompare(b.acquisitionDatetime);
    }
  }
  // Sort the array
  let newDisplaySets = displaySets.sort(sortByAcquisitionDatetime)
  return newDisplaySets //displaySets;
}

I Edited getDisplaySetsFromSeries function which located in getSopClassHandlerModule.js

  • Each single frame now individually displayed as one "displaySet" and not as a stack of single frame images.
  • I created a function which orders each DisplaySet to be sorted by AcquisitionDateTime , and returns a new array

When i log the newDisplaySets , it seems that it indeed sorted the AcquisitonDateTIme correctly but when i Return it from the main function - it doesn't really sort it properly

Screenshot 2024-05-05 125355

Any advise/ something I missed?

@sedghi
Copy link
Member Author

sedghi commented May 6, 2024

@niirdan We will tackle this for the next release. You could help us with the requirement gathering - what do you want to achieve, and what is your use case?

@niirdan
Copy link

niirdan commented May 6, 2024 via email

@sedghi
Copy link
Member Author

sedghi commented May 6, 2024

Thanks, here is the link for donation
CleanShot 2024-05-06 at 10 24 37@2x

@sedghi
Copy link
Member Author

sedghi commented May 6, 2024

@niirdan So you want to stack single images or you don't want?

@niirdan
Copy link

niirdan commented May 6, 2024 via email

@sedghi sedghi assigned IbrahimCSAE and unassigned sedghi Jun 5, 2024
@IbrahimCSAE IbrahimCSAE changed the title [Bug] Custom Sorting epic issue [Feature] Implement custom sorting of series in study panel Jun 5, 2024
@jmaratt
Copy link

jmaratt commented Jun 20, 2024

Would it be possible to present studies in panel in the same order it is passed into the url with?StudyInstanceUIDs=?

I have found that manipulating tabData.studies in StudyBrowser.tsx can impact the presentation order. I was having trouble identifying where the study list was being initially sorted to try to address it at that point. Could you point me to that function? Thanks!

Update: I found where it does this and can see why my ask would be difficult and a fringe use case. I think I accomplish what i need just by sorting by date there. Thank you.

@sedghi sedghi added fixed-in-dev-await-release This issue is fixed in master (viewer-dev) but we are pending testing for release (viewer.ohif.org) and removed Feature Request labels Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Design Needed Epic Epic fixed-in-dev-await-release This issue is fixed in master (viewer-dev) but we are pending testing for release (viewer.ohif.org)
Projects
None yet
Development

No branches or pull requests

4 participants