0

I am an oceanographer and I have a problem in my research. I am working on the FIJI software (Image J) and I have to process many images to do some quantification.

I have images of samples taken with different Fluorescence : CY3 ; TxET , and DAPI

I would like to do a batch processing thanks to a MACRO code in .ijm allowing to process all my images by doing the following manipulation:

Image n°1 fluo TxET - image n°1 fluo CY3

The goal would be to process all the images of my file.

But the problem is that my code (below) is not working, with the error : Error: ')' expected in line 10: list = getFileList ( inputDir <,> prefixes [ p ] + "_*.tif" ) ;

Here is the code that I started to write :

// Define the folder containing the input images

inputDir = "/path/to/folder/containing/images/",

// Define the file name prefixes for each fluorescence

prefixes = ["CY3", "TxET", "DAPI"];

// Browse all prefixes and subtract the corresponding images

for (p = 0; p < prefixes.length; p++) {

// Get the list of files corresponding to the current prefix

list = getFileList(inputDir, prefixes[p] + "_*.tif");

// Browse all files matching the current prefix

for (i = 0; i < list.length; i++) {

// Get the name of the current file

filename = list[i];

// Extract the number of the current image from the filename

num = parseInt(filename.replace(prefixes[p] + "_", "").replace(".tif", ""));





// Subtract the current image of the current fluorescence with the corresponding image of the CY3 fluorescence

if (prefixes[p] != "CY3") {
  cy3Filename = "CY3_" + num + ".tif";
  txetFilename = "TxET_" + num + ".tif";
  outputFilename = "TxET-CY3_" + num + ".tif";
  run("Image Calculator...", "operand1=[" + inputDir + txetFilename + "] operand2=[" + inputDir + cy3Filename + "] operation=Subtract create");
  saveAs("Tiff", inputDir + outputFilename);
}

} }

And i expect to obtain a new image with only the fluorescence of TxET - CY3

ArthurCo
  • 1
  • 1

1 Answers1

0

I would recommend starting with the batch macro script which can be found in the script editor under "Templates" and I have pasted below (this is the ImageJMacro Language version) from: https://imagej.nih.gov/ij/docs/pdfs/ImageJBatchProcessing.pdf.

/*
 * 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.
    // Leave the print statements until things work, then remove them.
    print("Processing: " + input + File.separator + file);
    print("Saving to: " + output);
}

You will find fast help on the imageJ forum https://forum.image.sc/

dandrews
  • 967
  • 5
  • 18