Need to open several images in a folder in file order but not as a stack
Posted by eglass on Mar 24, 2017; 3:43pm
URL: http://imagej.273.s1.nabble.com/Need-to-open-several-images-in-a-folder-in-file-order-but-not-as-a-stack-tp5018368.html
Hi All,
Quite new to ImageJ here, but i have been searching and looking for a solution to this for days!
This should be quite simple I think but for some reason isnt working.
I want to open all the image (DICOM) files in a folder in filename order (eg: 2cm, 3cm, 4cm, 4.5cm etc.) and then apply ROI's and do some calculations and it all gets written to a results table.
As the operator needs to be able to view the ROI's on the images after processing to check the positions I need the images to remain open individually - so not open them as a stack.
Currently I have:
inputFolder = getDirectory("Choose the input folder!"); //Chose folder images are in
images = getFileList(inputFolder);
for(Pic=0; Pic<images.length; Pic++) {
inputPath = inputFolder + images[Pic];
open(inputPath);
ROI_CNR(x1,y1); // my function for calculating CNR with several ROI's this spits out a results table in the order of opening
}
My folder contains the DICOM files in the order: 2cm, 3cm, 4cm, 4.5cm, 5cm, 6cm, 7cm. This order is also in ascending time of acquisition and DICOM tag of Image number. (all the same file size etc)
BUT following this code it opens the images in a different order of: 7cm, 2cm, 3cm, 4.5cm, 4cm, 5cm, 6cm.
I have repeated this with other image folders (copying and pasting different file combinations) and it seems to follow the order in which the image files were copied into a folder (i hope that makes sense).
Is there anyway of opening the files in filename/numerical order. OR of reordering the results table to be in numerical order?
I have also tried batchmode processing and image sequence import (but dont want a stack) but it doesnt solve it. I have also tried a loop, opening each file that contains each number in ascending order but this gets stuck with the 4.5 file as it gets opened when both 4 and 5 are found in the file name...
Hope that makes sense! Any help reaaallllyyyy appreciated!