Sorts a DICOM stack by image number.
(ImageStack stack)
| 10 | |
| 11 | /** Sorts a DICOM stack by image number. */ |
| 12 | public static ImageStack sort(ImageStack stack) { |
| 13 | if (IJ.debugMode) IJ.log("Sorting by DICOM image number"); |
| 14 | if (stack.size()==1) return stack; |
| 15 | String[] strings = getSortStrings(stack, "0020,0013"); |
| 16 | if (strings==null) return stack; |
| 17 | StringSorter.sort(strings); |
| 18 | ImageStack stack2 = null; |
| 19 | if (stack.isVirtual()) |
| 20 | stack2 = ((VirtualStack)stack).sortDicom(strings, sliceLabels, MAX_DIGITS); |
| 21 | else |
| 22 | stack2 = sortStack(stack, strings); |
| 23 | return stack2!=null?stack2:stack; |
| 24 | } |
| 25 | |
| 26 | private static ImageStack sortStack(ImageStack stack, String[] strings) { |
| 27 | ImageProcessor ip = stack.getProcessor(1); |