Thank you for your answer.
Of course, I’m tried something. Here is the macro I have done and with which I am working at the moment.
// “BatchProcessFolders”
//
// This macro batch processes all the files in a folder and any
// subfolders in that folder. In this example, it runs the Subtract
// Background command of TIFF files. For other kinds of processing,
// edit the processFile() function at the end of this macro.
requires(“1.33s”);
dir = getDirectory(“Choose a Directory “);
count = 0;
countFiles(dir);
n = 0;
processFiles(dir);
//print(count+” files processed”);
function countFiles(dir) {
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], “/”))
countFiles(""+dir+list[i]);
else
count++;
}
}
function processFiles(dir) {
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], “/”))
processFiles(""+dir+list[i]);
else {
showProgress(n++, count);
path = dir+list[i];
processFile(path);
}
}
}
function processFile(path) {
if (endsWith(path, “.env”)) {
// Importer le stack directement
run(“Bio-Formats Windowless Importer”, “open=path autoscale color_mode=Default view=Hyperstack”);
//transformer l’image en 8-bit
run(“8-bit”);
//Remettre l’image à l’echelle avec la fonction ci dessous :
// run(“Scale…”, “x=1.0 y=0.42236328 z=1.0 width=865 height=865 depth=71 interpolation=None average create”);
//Modifier l’ordre des images pour pouvoir appliquer le plugin 3D drift
run(“Re-order Hyperstack …”, “channels=[Channels ©] slices=[Frames (t)] frames=[Slices (z)]”);
//Remettre les canaux dans les bonnes couleurs
Stack.setChannel(1)
run(“Blue”);
run(“Enhance Contrast”,“saturated=0.35”);
resetMinAndMax();
Stack.setChannel(2)
run(“Green”);
run(“Enhance Contrast”,“saturated=0.35”);
resetMinAndMax();
Stack.setChannel(3)
run(“Red”);
run(“Enhance Contrast”,“saturated=0.35”);
resetMinAndMax();
//Supprimer les frames qui n’ont pas de datas correctes
//car le piezo fait une image au milieu du stack à la fin de l’acquisition
//car les premières et dernières images sont moins intenses que celles au centre du stack
Stack.setFrame(3)
run(“Delete Slice”,“delete=frame”);
Stack.setFrame(2)
run(“Delete Slice”,“delete=frame”);
Stack.setFrame(1)
run(“Delete Slice”,“delete=frame”);
//Corriger le drift dû aux battements du coeur avec le channel 2 (vert) pour référence
run(“Correct 3D drift”, “channel=2 only=0 lowest=1 highest=1”);
//Sauver l’image tif dans le fichier parent
newpath=File.getParent(path);
saveAs(“tiff”,newpath);
run(“Close All”);
}
}
My problem is that on my 90 stacks: some have the first black slices, others the last, sometimes only one, sometimes six or seven. So with my current macro it happens that I delete data or on the contrary that I leave black slices which gives me a bad shift later.
So I tend to eliminate more than enough and I would like to succeed in writing a macro that allows me to obtain a clean and repeatable result on each manipulation.