So this macro is not exactly useful to you, but I will paste the whole thing so that you can see the important line in context.
dir1 = getDirectory("Choose Source Directory ");
dir2 = getDirectory("Choose Destination Directory ");
setBatchMode(true);
channelList = getFileList(dir1);
batchList = getFileList(dir1+channelList[0]);
//Open groups of files, one per channel for a set
for (j=0; j<batchList.length; j++){
imageList = getFileList(dir1+channelList[0]+batchList[j]);
for (k=0; k<imageList.length; k++){
for (i=0; i<channelList.length; i++) {
//print(dir1+channelList[i]+batchList[j]+imageList[k]);
open(dir1+channelList[i]+batchList[j]+imageList[k]);
rename(channelList[i]);
run("8-bit");
run("Properties...", "channels=1 slices=1 frames=1 unit=um pixel_width=0.5 pixel_height=0.5 voxel_depth=1");
}
run("Images to Stack", "name=["+imageList[k]+"] title=[] use");
run("Properties...", "channels=6 slices=1 frames=1 unit=µm pixel_width=0.5000000 pixel_height=0.5000000 voxel_depth=1.0000000");
saveAs("TIFF", dir2+imageList[k]);
while (nImages>0) {
selectImage(nImages);
close();
}
}
}
When I am combining my TIFFs into a stack, the line “rename(channelList[i]);” renames the open TIFF, which is then used in the final stack as the name for that image. You can also see the macro handles forcing channel number, as opposed to letting FIJI choose whether to create a Z stack.
The channel list itself, in this case, is pulled from the directory where the TIFFs are stored, so the renamed image will have whatever names were used in the folders. You could also create your own array of text to pull the channel name from.
