Macros using multiple input directories

I am trying to write a macro where I have 2 input directories. For Images in “dir” I want to process then get roi’s added to the manager, for Images in “dir2” I want to process and get measurements on the roi’s from the first directory. I have the two pieces working independently and have the output saved in a third directory “dir3” but I’m not sure how to switch input directories, is there a command where you can switch the input directory in the middle of a macro, or is there another more elegant way to do this?

Start from the “Process Folder” template in Templates :arrow_forward: ImageJ 1.x :arrow_forward: Examples :arrow_forward: Process Folder (IJ1 Macro) of the Script Editor.

Modify the processFile method to perform the operations you need per image.

And on line 13, change:




where dir1 and dir2 are the two folders you want to process.

Or if the inputs from the two directories are more “interconnected” (it sounds like they may be, from your description), you can modify the processFolder(input) method to instead take two directories (processFolder(dir1, dir2)). The tricky part is correlating the files of one directory with those of the other. Presumably they have some naming convention? Can you list the (partial is OK) contents of each directory, to give us an idea?

1 Like

Thanks for the help, I’m starting to work through the script editor work flow you directed me towards…

In the meantime…

Currently my Directory 1 are the segments or predictions that come out of Ilastik for a given image for example…
"13236M-272-0004_Simple Segmentation.tiff"
In Directory 2 I have the original Images "13236M-272-0004.tif"
What I want is to get the defined ROIs from the Ilastik training and make a measurement on the original Image from that.
Its Important to track which ROI gives me which measurement as some Images will have several ROis

Thanks for the details. For better coherency, let’s migrate this discussion to the other thread you started. Otherwise, it is hard to follow all the information across these two different threads.