Sort instances/study by acquisition datetime

Good Morning,
currently running the latest version of ohif (3.8.0-beta.54) .
I am trying to understand if there is a way to SORT instances INSIDE a study (cine/Img within an exam).
the reason for this is, for instance , cariologies interpret exams by the acquisition date & time .
unfortunately, when displaying studies using ohif - the displayed order isn’t by the acquisition order.
for me I think its quite clear to sort it by this way BUT i Couldn’t find any docs regarding this , only sorting studies(exams) by their dates which this is not the case here.
Hope i clarify myself correctly ,
Dan

Hey there, if I am not mistaken the order whne you are inside of the study is dictated by the hanging protocol applied. If no rule is applied the order can be a bit random, which might be the case for the default protocol.

You could try to create one that applies to the proper modality and add it on the longitudinal mode (the basic mode).

Again, fast answer, but hope it helps. Cheers!

Thanks for your response!
I am using the google health care hanging protocol , tried to do a research on google if they have some configuration about this, found non
Do you know maybe if I can handle it by Ohif?
B.R, Dan

As far as I know it has to be done by Ohif. Sorry for the late answer, was just leaving work.

The file I was referring to is located in extensions > default > src > getHangingProtocolModule.js, there you can find the default protocol.

You will be able to see that it has a seriesMatchingRules attribute, there you can add an object using the attribute from the dicom you need to sort with (AccessionNumber?), put a weight to it, then add a constraint for it to apply that weight.

I think you will not be able to do a direct sort in there, so you might need to get a bit creative with the way to order them.

Might be another way of sorting them though, hope someone else can help as well.

There you have the documentation for the rules. See if you can sort them using any of the DICOM attributes in some way (like if they are have an attriibute that numbers them from 1 to n, making an individual rule for each number if the instances are usually low).

@haldawe2 thanks for your response .
I am not sure I completely understand the mechanism under the getHangingProtocolModule.
my desired way of viewing series is by ‘Acquisition DateTime’ attribute ascending (old to newest).
In addition, I found that Image’s is converged into one series which is not a good behavior when ordering by acquisition datetime.

i hope i got myself clear.
Thanks a lot!,
BR Dan .

Hi - similar issue, needed to sort by Instance Number - ended up modifying getSopClassHandlerModule to change sort order of the SOPClassID specific displayset.

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

const displaySets = ;
const sopClassUids = getSopClassUids(instances);

instances.forEach(instance => {
if (!isImage(instance.SOPClassUID) && !instance.Rows) {
return;
}

let displaySet;

displaySet = makeDisplaySet([instance]);

displaySet.setAttributes({
  sopClassUids,
  instanceNumber: instance.InstanceNumber,
  acquisitionDatetime: instance.AcquisitionDateTime,
});
displaySets.push(displaySet);
displaySets.sort((a, b) => (a.InstanceNumber > b.InstanceNumber ? 1 : -1));

});

return displaySets;
}

thanks for your response! @AugmentedReporting .
looks like the code you posted here

let displaySet;

displaySet = makeDisplaySet([instance]);

displaySet.setAttributes({
  sopClassUids,
  instanceNumber: instance.InstanceNumber,
  acquisitionDatetime: instance.AcquisitionDateTime,
});
displaySets.push(displaySet);
displaySets.sort((a, b) => (a.InstanceNumber > b.InstanceNumber ? 1 : -1));

is the same as the latest version ,
as far as i saw , the issue is that the sort function accepts only integers which is not the case when sorting by acquisition datetime.

thanks we proposed the change in January but haven’t seen it pushed to master branch yet

to sort AcquisitionDateTime, suggest adding a custom function to convert from DICOM date time string to integer