Open images/ROI with different names

Hello,
I want to do intensity measurements of nuceli on different images . Therefore I have images from different channels (DAPI and target protein) in different folders
images example
ATP4_24h_2_+TGFb005_RAW_ch01.tif (2.8 MB)
ATP4_24h_2_+TGFb005_RAW_ch00.tif (2.8 MB)

To do this i create a binary depending on the DAPI (1.image) image and make a selection (ROI) and save both.
Binary_ATP4_24h_2_+TGFb005_RAW_ch00.tif (1.5 MB)

  • ROI saved

Macro for it: (working)
To make the binary//selection

//öffnen der DAPI Bilder
#@ File (label = “Input directory_DAPI”, style = “directory”) input
#@ File (label = “Output directory_DAPI”, 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.
setBatchMode(“hide”);
open(input+"/"+ file);
//Definition
originalimage=getTitle();
// herstellen Binary
run(“Auto Threshold”, “method=RenyiEntropy white”);
// Zellkern ROI
run(“Create Selection”);
roiManager(“Add”);
roiManager(“Select”, 0);
roiManager(“Rename”, “Kern”);
//Speichern ROI
roiManager(“Save”, output+File.separator+originalimage+“KernROI.roi”);
//Zwischenspeichern Binary DAPI
saveAs(“Tiff”, output+File.separator+“Binary_”+originalimage);
savedimage = getTitle();
roiManager(“Select”, “Kern”);
roiManager(“Delete”);

}

Then i want to overlay the roi taken from the first image over the second image in another macro.
But i have the problem how to open the right ROI fitting to the second image ?

Macro (not working)

// 2. protein image open
#@ File (label = “Input directory_Smad2.3”, style = “directory”) input3
#@ File (label = “Output directory_Smad2.3”, style = “directory”) output3
#@ File (label = “Input directory_DAPI”, style = “directory”) input
#@ String (label = “File suffix”, value = “.tif”) suffix3
#@ String (label = “File suffix”, value = “.roi”) suffix

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

processFolder(input3);

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

function processFile(input3, output3, file) {
// Do the processing here by adding your own code.

   setBatchMode("hide");
open(input3+"/"+ file);
//Open ROI fitting to the image
   originalimage = getTitle();
    **roiManager("open", input +File.separator+originalimage+"KernROI.roi")**;
    //measure ROI
    roiManager("Select", "Kern");
roiManager("Measure");
roiManager("Deselect");
roiManager("Delete");
close("*");

}

this was my idea to solve the problem but the program can’t find the right roi because in this case the “originalimage” has another channel number (instead of ch00 , ch01)
roi is saved as
ATP4_24h_2
+TGFb005_RAW_ch00.tifKern.roi
and the program looks after
ATP4_24h_2
+TGFb005_RAW_ch01.tifKern.roi

does somebody know how i can solve this Problem?

Many thanks in advance…