-
-
Save PMLLancao/47ab20b75ef1a2964e0630a14098d8e0 to your computer and use it in GitHub Desktop.
macro "Ratiometric FRET" { | |
path = getDirectory("Choose a Directory"); | |
list = getFileList(path); | |
length = list.length; | |
File.makeDirectory(path + "Imaging/"); | |
//FRET map creation | |
for (i=0; i<length; i++) { | |
n=i+1; | |
open(path+list[i]); | |
img = File.nameWithoutExtension(); | |
selectWindow(img+".lsm"); | |
run("Subtract Background...", "rolling=300 stack"); | |
run("StackReg", "transformation=Translation"); | |
run("Median...", "radius=1.3 stack"); | |
run("Stack to Images"); | |
run("Duplicate...", "title=mask"); | |
run("Threshold..."); | |
setAutoThreshold("Default dark"); | |
waitForUser("Imagen "+n+" de "+length,"Apply Threshold y click OK"); | |
run("16-bit"); | |
run("Divide...", "value=255"); | |
saveAs("Tiff", path + "Imaging/mask 000" + i); | |
imageCalculator("Divide create 32-bit", "1-0002","1-0001"); | |
imageCalculator("Multiply create","Result of 1-0002","mask 000"+i+".tif"); | |
selectWindow("Result of Result of 1-0002"); | |
saveAs("Tiff", path + "Imaging/fret map " + i); | |
run("Close All"); | |
} | |
line 20
run("Stack to Images");
If you want to split channels (step 5), it's much better to use the command [Image > Color Split Chanells], which is
run("Split Channels");
In this way, images after splitting will have suffix "C1-" for the first channel, "C-2" for the second channel... and so on. For this reason, the name of these windows for each single channel becomes
"C1-" + list[ i ]
For the first channel,
"C2" +list[i]
Or. this might be what you want to do?
By the way,
line 14-16
open(path+list[i]);
img = File.nameWithoutExtension();
selectWindow(img+".lsm");
If the original file name is with .lsm
, I just wonder if there is any specific reason for this.
Just to be tidy and better organization, indent lines within a macro. See here
Thank you very much, Kota
the .lsm is because my images are from Zeiss microscope, but I would like to do that generic too
Follow your suggestion, I will use run("Split Channels");
So I wrote again the lines 28-30 , now after Split Channels.
28 imageCalculator("Divide create 32-bit", "C2-" + list[ i ], "C1-" + list[ i ]");
29 imageCalculator("Multiply create","C2-" + list[ i ]","mask 000"+i+".tif");
30 selectWindow("Result of Result of "C2-" + list[ i ]");
However, I am getting this error
How can I fix it? I try to change the " " but nothing works.
Thanks for any help.
So the problem is this line
selectWindow("Result of Result of "C2-" + list[ i ]");
Too many double quoting! It should be enough with
selectWindow("Result of Result of C2-" + list[ i ]);
Hello,
This is the description that what I want to do:
1 Open the files from folder
2 Subtract background to all the channels (300 pixels)
3 Apply median filter to all channels (1.3 pixels)
4 Align channels with pluging “registration”- Stackreg- using the “Translation mode”
5 Split the channels or stack to image
6 Duplicate C1 (channel 1) or image 1 (CFP)
7 Create a binary mask of CFP image with the Threshold tool. (MASK channel 1)
8 Use the tool math, divide the binary mask by 255.
9 Use the tool image calculator: divide C2 (channel 2 or C2 = FRET) by C1 (channel 1 or C1 = CFP) Press 32 bit in the options.
10 Finally, multiply the MASK channel 1 by the result of step 9
11 save image in a new folder in Tiff
I want to make this macro generic for any image name ( I have my images in a folder with numbers from 1 to 10 or more. However, I do not know how to make this generic so then any number or name can be detected and continue with the macro.
I receive this kind of error message in the macro.
Hope can you help me with this doubt,
Thanks a lot,
Kind Regards
Pablo