Hey guys, I’ve been trying to create a macro to perform a batch analysis of a lot of z-stack images I got for Golgi analysis. The macro so far looks like this:
//Ask the user to select the source directory - tiff stacks from batch conversion
dir1 = getDirectory("Select NEURONS folder");
//Ask the user to select the destination directory - where to save images and results
dir2 = getDirectory("Select TRACES folder");
Ask the user to select the destination directory - where to save images and results
dir3 = getDirectory("Select OUTPUT folder"); //don't worry about this folder for now
list1 = getFileList(dir1); //neurons list
Array.sort(list1);
//Array.print(list1);
list2 = getFileList(dir2); //traces list
Array.sort(list2);
//Array.print(list2);
for (i=0; i<list1.length; i++) {
filename = dir1 + list1[i];
tracename = dir2 + list2[i];
open(filename);
nameStore = getTitle();
newname = substring(nameStore, 0, lengthOf(nameStore)-10);
run("Sholl Analysis (Tracings)...", "traces/(e)swc=[tracename] image=[] load center=[Start of main path] radius=15 enclosing=1 #_primary=[] infer linear polynomial=[Best fitting degree] most normalizer=Area/Volume directory=[]");
}
Don’t worry about “nameStore” and “newname”, I’ll use those later. The actual problem comes from the plugin line "run(“Sholl…” not recognising the traces file. When I run the debug mode, it says
Error: Invalid image or invalid Traces/(e)SWC file
tracename in line 25:
run ( "Sholl Analysis (Tracings)..." , "traces/(e)swc=[tracename] image=[] load center=[Start of main path] radius=15 e...
But it also says that “tracename” is correct. In this case, “tracename” corresponds to “C:\Users\Sebastian\Desktop\Golgi_test\19222\Traces\19222-01-G.traces”. The debug window looks like this:
Name * Value
Memory * 100MB of 6046MB (1%)
nImages() 2
getTitle() "19222-01-G.nd2 - C=1"
dir1 * "C:\Users\Sebastian\Desktop\Golgi_test\19222\Neurons\"
dir2 * "C:\Users\Sebastian\Desktop\Golgi_test\19222\Traces\"
list1 array[40]
list2 array[23]
i 0
filename * "C:\Users\Sebastian\Desktop\Golgi_test\19222\Neurons\19222-01-G.nd2"
tracename * "C:\Users\Sebastian\Desktop\Golgi_test\19222\Traces\19222-01-G.traces"
nameStore "19222-01-G.nd2 - C=1"
newname "19222-01-G"
--- ---
Error: Invalid image or invalid Traces/(e)SWC file
tracename in line 25:
run ( "Sholl Analysis (Tracings)..." , "traces/(e)swc=[tracename] image=[] load center=[Start of main path] radius=15 e...
Record: run("Sholl Analysis (Tracings)...", "traces/(e)swc=[C:/Users/Sebastian/Desktop/Golgi_test/19222/Traces/19222-01-G.traces] image=[] load center=[Start of main path] radius=15 enclosing=1 #_primary=[] infer linear polynomial=[Best fitting degree] most normalizer=Area/Volume directory=[]");
When I run the analysis manually for the same file, and I bring up the recorder to observe the plugin behaviour, the recorder looks like this:
run("Sholl Analysis (Tracings)...", "traces/(e)swc=[C:/Users/Sebastian/Desktop/Golgi_test/19222/Traces/19222-01-G.traces] image=[] load center=[Start of main path] radius=15 enclosing=1 #_primary=[] infer linear polynomial=[Best fitting degree] most normalizer=Area/Volume directory=[]");
And of course it brings up the expected results windows and graphs.
This confirms that the traces file both in the macro instance and in the manual instance correspond to the same file and same path (for this analysis I’m loading the traces without the image). So I’m confused as to why the macro is not working, as everything looks in order. Any idea?
Let me know if you need me to upload more information.
Cheers, Seb,