OHIF / Viewers

OHIF zero-footprint DICOM viewer and oncology specific Lesion Tracker, plus shared extension packages
https://docs.ohif.org/
MIT License
3.35k stars 3.37k forks source link

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

Closed sedghi closed 1 hour ago

sedghi commented 6 months ago

@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.

User Interface Enhancements:

Allow users to override the initially used default sort

niirdan commented 6 months ago

@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 commented 6 months ago

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

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 commented 6 months ago

@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 commented 6 months ago

Ok course, First of all I want to thank you for the help and I would like to donate to the project if it’s possible .

The end users are cardiologists, In order for them to use the viewer properly is by viewing each series by its acquisitionDateTime tag(0008,002A) (the chronological order which the dicom material created) for example ;

  1. Cine 2024 05 06 14:22:00
  2. Single image 2024 05 06 14:25:12
  3. Cine 2024 05 06 14:30:14

The first thing which prevented this kind of sorting Is the fact that single images stack together (which I solved with the code above)

I hope my explanation was clear enough , please let me know if not

On Mon, 6 May 2024 at 16:29 Alireza @.***> wrote:

@niirdan https://github.com/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?

— Reply to this email directly, view it on GitHub https://github.com/OHIF/Viewers/issues/4083#issuecomment-2096024230, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5B2UZQVWNMKFBTU36F36VDZA6ATFAVCNFSM6AAAAABHG733UWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJWGAZDIMRTGA . You are receiving this because you were mentioned.Message ID: @.***>

sedghi commented 6 months ago

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

sedghi commented 6 months ago

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

niirdan commented 6 months ago

Stack single images together will make it useless to sort all the instances by their chronological order ,so without stacking them On Mon, 6 May 2024 at 17:26 Alireza @.***> wrote:

@niirdan https://github.com/niirdan So you want to stack single images or you don't want?

— Reply to this email directly, view it on GitHub https://github.com/OHIF/Viewers/issues/4083#issuecomment-2096167034, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5B2UZRVP3SRK3GQ67CC4XDZA6HHVAVCNFSM6AAAAABHG733UWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJWGE3DOMBTGQ . You are receiving this because you were mentioned.Message ID: @.***>

jmaratt commented 4 months ago

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 commented 1 hour ago

We released OHIF 3.9 which address this issue