1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| dir = getDirectory("Choose a Directory");
fileList = getFileList(dir);
setBatchMode(true);
for (fl=0; fl<lengthOf(fileList); fl++)
{
//cherche le fichier .env
imageList = getFileList(dir + fileList[fl]);
for(i=0; i<lengthOf(imageList); i++)
{
if (endsWith(imageList[i], ".env"))
{
run("Image Sequence...", "open=[" + dir + fileList[fl] + imageList[i] + "] sort");
Stack.getDimensions(width, height, channels, slices, frames);
run("Stack to Hyperstack...", "order=xyzct channels=3 slices=" + slices/3 + " frames=1 display=Composite");
}
}
//repère les slices à supprimer
Stack.getDimensions(width, height, channels, slices, frames);
Stack.setChannel(2);
sliceToDelete = newArray(slices);
for (s=1; s<=slices; s++)
{
Stack.setSlice(s);
getStatistics(area, mean, min, max, std, histogram);
if(mean<30) sliceToDelete[s-1] = "delete";
}
//supprime les slices
Stack.setChannel(2);
for (s=slices; s>=1; s--)
{
setSlice(s);
if(toString(sliceToDelete[s-1]) == "delete") run("Delete Slice", "delete=slice");
}
//sauvegarde
save(dir+fileList[fl]+ "Treated " + getTitle());
//correction du drift
run("Arrange Channels...", "new=321");
run("8-bit");
run("Re-order Hyperstack ...", "channels=[Channels (c)] slices=[Frames (t)] frames=[Slices (z)]");
run("Correct 3D drift", "channel=2 only=0 lowest=1 highest=1");
//projection
run("Z Project...", "projection=[Max Intensity]");
//sauvegarde
save(dir+ "Treated " + getTitle());
run("Close All");
showProgress(fl+1, lengthOf(fileList));
}
setBatchMode("exit and display");
//Crée un stack avec les max projections
fileList = getFileList(dir);
n = 1;
concatenateArg = "";
for (fl=0; fl<lengthOf(fileList); fl++)
{
if(endsWith(fileList[fl], ".tif"))
{
open(dir + fileList[fl]);
concatenateArg = concatenateArg + "image" + n + "=[" + fileList[fl] + "] ";
n=n+1;
}
}
run("Concatenate...", "open " + concatenateArg);
save(dir+ "Concatenate");
run("Close All"); |
Partager