Login  Register

Re: How can I open compressed DICOM slices in a sorted way?

Posted by Martin Höhne on Dec 03, 2013; 9:33am
URL: http://imagej.273.s1.nabble.com/How-can-I-open-compressed-DICOM-slices-in-a-sorted-way-tp5005773p5005793.html

Hello Clare,

I don´t have much expericence with DICOM stacks, but the one I worked with was also sorted in a weird way. The stack I had could be sorted as follows.

1) Open the DICOM series with  File > Import > Image sequence ...
2) Then run the macro pasted below
3) Image>Stacks>Tools>Stack sorter>Sort by label

Hope that works for your stack as well
Martin



for (j=1; j<=nSlices; j++) {
        setSlice(j);
        imageNumber = getInfo("0020,0013");
        imageNumber=IJ.pad(imageNumber,3); //three digit number. Otherwise sorting will be 1,10,2 ...
        seriesNumber = getInfo("0020,0011");
        seriesNumber=IJ.pad(seriesNumber,3);
        setMetadata("Label", seriesNumber+"_"+imageNumber);
        run("Properties...", "voxel_depth=sliceSpacing");
}
// the stack needs to be sorted by clicking on "sort by label"
// Image>Stacks>Tools>Stack sorter>Sort by label
run("Stack Sorter");