[ImageJ Macro] best practice to analyse only a subset of files in a directory

Dear Forum,
how do you let an user select which file to analyse in IJM macro batch analysis?

Let’s say I am a researcher yesterday I have analysed 100 of 300 images, today I want to restart the analysis from the 101 image without skipping 1 to 100; or ideally a multi file selection.

At the moment, the only thing I have implemented is that:

an IJM macro that shows the list of the folder to analyse and then ask for the first index to (re)start, I really think there would be a more elegant solution.

// @File(label = "Input directory", style = "directory") input

processFolder(input);
function processFolder(input) {	
        list = getFileList(input);
	list = Array.sort(list);
        Array.show("file List (indexes)",list);
        waitForUser("SELECT Files","scroll the file list and check the first index to analyse then click OK");        
        first_index = getNumber("insert index of the first file to analyse, 0 for all", 0);

       // list processing
       for (i = first_index; i < list.length; i++) {
             processFile(input, output, list[i])
       }
}

As you can see, for example I need to put a WaitForUserDialog to let the user scrolls the list.
So, how do you do usually to perform this kind of files selection?

Have a nice day,
thank you
Emanuele Martini

Hi Emanuele,

Two choices for us.

  1. Get the user to move the non-analyzsed data to a subfolder.

  2. If we generate an output folder, check that the output corresponding to the image about to be opened does not already exist (output image file, line in results table, …)

Hope this helps

Oli

2 Likes

Maybe @imagejan’s scijava-batch-processor might be useful in future. Motivated by that project, there are also some discussions going on in that direction, although I am not entirely sure how well they will work with the macro language…

4 Likes

Thank you @oburri and @stelfrich

yes that what I always suggest them.

good idea, I will try to implement that:)

I think it could be useful to have a “style” script-parameter that permits to get a folder, a file or multi-file selection
but I don’t know how much it could be hard to implement.

Thank you,
Emanuele

I actually don’t think that this is desirable because you’d have to figure out yourself from one File instance what exactly was selected. Using something like #@File[] files is more explicit about that and, in my opinion, better suited for your purpose. But again, that raises the question, how the ImageJ1 macro language would handle such a case…

Same here… (totally forgot that in my last comment ;-))

1 Like