Identifying Slice Timing Order from DICOM and nifti

Thank you so much @Chris_Rorden !
I have tried this and unfortunately it does not work…
On surface I’m having similar issues as this

When I look at SOPinstanceUID seems it contains datetime but I’m uncertain of slice time

SOPinstanceUID=1.3.46.670589.11.42363.5.0.4672.2017072418220221349

I updated the script as follows

But I’m stuck at finding FrameContentSequence[0].TemporalPositionIndex
The series contain children which points to all the slices

If I understand correctly, here what you are doing is to extract the timing information of when a slice is acquired, namely 2017072418220221349 would encode each slice acquisition time and we reconstruct the order based on this.

For Multiple images, say in our case 180 scans * 48 slices = 8460 DICOM files, I tried to sort all the slices and had some interesting result.
result.txt (124.9 KB)

Namely, for slices 0-48, the sequence is
[0, 4-48, 1, 2, 3]

I’m not certain of ways to tell which 48 slices/DICOM contributes to a single scan so here I assumed sequential data.

Based on what I’m seeing I suspect it’s ascending, but can’t quite explain why the mismatch of slice 1,2 and 3…