mccquillr
mccquillr

Reputation: 11

ImageJ Macro Path Issue

In a macro I am writing, I am trying to export the results from a plug-in using the following structure:

savePath = newfolder+"\\"+fileid;
run("Export results", "filepath=savePath fileformat=[CSV (comma separated)]...;

where the fileid is simply a name of a file pulled from an array (i.e. "cell_1").

In the debug console, savePath reads "C:\Users\Main\Directory...\file.csv" (i.e. it appears correctly specified) but no file is output to folder specified. Instead, it is output to the ImageJ Plugins folder as a file called "savePath." However, then I manually insert the pathname inside the comment using "\" as the separator, it works.

I am aware that there was an issue concerning how ImageJ handles \ versus \ and / in the past, however I tried a number of fixes for this and none of them have worked. Things I've tried include:

replace(savePath,"\\","\\\\");

as well as

var s = File.separator;
replace(savePath,"\\",s);

and

replace(savePath,"\\","/");

and none have worked.

Interestingly, I use another macro in the sequence that uses the same formatting as savePath and it works fine:

directory = getDirectory("Choose input directory");
newfolder=directory+fileid;
run("Image Sequence...", "open=newfolder file=act" );

where, again, the fileid is simply a name of a file pulled from an array (i.e. "cell_1").

Any help or workaround on this issue would be greatly appreciated!

Upvotes: 0

Views: 1248

Answers (1)

mccquillr
mccquillr

Reputation: 11

Turns out this is more of an issue with the format of the pathname. The pathname contained a space which ImageJ was having a hard time recognizing. In the future, I will avoid using spaces in my folder and file names. Also, the correct format for the export macro is

savePath = newfolder+"\\"+fileid;
run("Export results", "filepath="+savePath+" fileformat=[CSV (comma separated)]...;

using a "+...+" when inputting the variable.

Upvotes: 1

Related Questions