Batch processing subfolders not saving

batch-processing
ijm
macro
Tags: #<Tag:0x00007fa3073f5370> #<Tag:0x00007fa3073f5230> #<Tag:0x00007fa3073f5050>

#1

I have a set of folders with binary images, I want to remove the outliers from these images and keep the folder structure. I tried the template script for batch processing folders.

/*
 * Macro template to process multiple images in a folder
 */

#@ File (label = "Input directory", style = "directory") input
#@ File (label = "Output directory", style = "directory") output
#@ String (label = "File suffix", value = ".tif") suffix

// See also Process_Folder.py for a version of this code
// in the Python scripting language.

processFolder(input);

// function to scan folders/subfolders/files to find files with correct suffix
function processFolder(input) {
    list = getFileList(input);
    list = Array.sort(list);
    for (i = 0; i < list.length; i++) {
        if(File.isDirectory(input + File.separator + list[i]))
            processFolder(input + File.separator + list[i]);
        if(endsWith(list[i], suffix))
            processFile(input, output, list[i]);
    }
}

function processFile(input, output, file) {
    // Do the processing here by adding your own code.
    run("Remove Outliers...", "radius=2 threshold=50 which=Bright slice");
    // Leave the print statements until things work, then remove them.
    print("Processing: " + input + File.separator + file);
    print("Saving to: " + output);
} 

I only added the remove outliers command. When I run this script the program does seem to work but when I look in the folders the files aren’t changed.


#2

Welcome to the forum, @Stijn_Delnoij!

You don’t open or save any image here. The template is meant as a starting point for you to add code, but it doesn’t contain any logic for file reading yet. That’s entirely up to you.

You can generate the required statements using the macro recorder.

Also have a look at the batch processing page:

To get to know more about the ImageJ macro language, please consult the documentation: