我想将文件夹名称传递给 run() 函数和 save() 函数,但它们在引号内,我不知道如何传递变量名。
我使用 imageJ 中的记录命令生成了 run() 和 save() 函数。
该程序的目的是自动化在多个文件夹上运行插件“T2 分析鼠标”的过程。任何其他推文或帮助将不胜感激。
我找到了这个在线资源https://imagej.nih.gov/ij/macros/ArgumentPassingDemo.txt但它不起作用。
我尝试了多种方法,包括/&foldername/3 T2
&filename/3 T2
/&foldername 3 T2``/&foldername3 T2
/&filename 3 T2``/&filename3 T2
以下是我编写的代码:
function makeT2(foldername)
{
filename = foldername;
print(filename);
run("T2 Analysis mouse", "select=[/Users/Vineeth/Desktop/New stuff Feb 5/&filename 3 T2]
image=[32-bit Signed] width=256 height=128 offset=0 number=902 gap=0 little-endian");
run("Save", "save=[/Users/Vineeth/Desktop/New stuff Feb 5/&foldername3 T2/T2map.tif]");
close();
}
folders = getFileList("/Users/Vineeth/Desktop/New stuff Feb 5/");
for( i = 0; i < folders.length; i++)
{
print(folders[i]);
file = getFileList("/Users/Vineeth/Desktop/New stuff Feb 5/" + folders[i]);
for( j = 0; j < file.length; j++)
{
if(file[j] == "3 T2/")
{
print("made t2 for " + folders[i] + file[j]);
makeT2(folders[i]);
}
}
}
各种print()
功能用于测试代码,并且代码大部分适用于 makeT2 功能。
这是错误:
java.lang.NullPointerException
at T2_Analysis_mouse.getImage(T2_Analysis_mouse.java:183)
at T2_Analysis_mouse.run(T2_Analysis_mouse.java:56)
at ij.IJ.runUserPlugIn(IJ.java:183)
at ij.IJ.runPlugIn(IJ.java:150)
at ij.Executer.runCommand(Executer.java:124)
at ij.Executer.run(Executer.java:61)
at ij.IJ.run(IJ.java:249)
at ij.macro.Functions.doRun(Functions.java:561)
at ij.macro.Functions.doFunction(Functions.java:79)
at ij.macro.Interpreter.doStatement(Interpreter.java:203)
at ij.macro.Interpreter.doBlock(Interpreter.java:518)
at ij.macro.Interpreter.runUserFunction(Interpreter.java:278)
at ij.macro.Interpreter.doStatement(Interpreter.java:206)
at ij.macro.Interpreter.doBlock(Interpreter.java:518)
at ij.macro.Interpreter.doStatement(Interpreter.java:239)
at ij.macro.Interpreter.doIf(Interpreter.java:852)
at ij.macro.Interpreter.doStatement(Interpreter.java:215)
at ij.macro.Interpreter.doBlock(Interpreter.java:518)
at ij.macro.Interpreter.doStatement(Interpreter.java:239)
at ij.macro.Interpreter.doFor(Interpreter.java:464)
at ij.macro.Interpreter.doStatement(Interpreter.java:221)
at ij.macro.Interpreter.doBlock(Interpreter.java:518)
at ij.macro.Interpreter.doStatement(Interpreter.java:239)
at ij.macro.Interpreter.doFor(Interpreter.java:464)
at ij.macro.Interpreter.doStatement(Interpreter.java:221)
at ij.macro.Interpreter.doStatements(Interpreter.java:191)
at ij.macro.Interpreter.run(Interpreter.java:102)
at ij.macro.Interpreter.run(Interpreter.java:72)
at ij.macro.MacroRunner.run(MacroRunner.java:124)
at java.lang.Thread.run(Thread.java:695)
这是运行程序后的日志:
LeeMouseOld_30Jan18.LH1/
made t2 for LeeMouseOld_30Jan18.LH1/3 T2/
LeeMouseOld_30Jan18.LH1/
Please choose a directory where the T1 or T2 folder is the last item in the path (i.e. 5_t1 or 6_t2)
Directory return for General T folder: /Users/Vineeth/Desktop/New stuff Feb 5/&filename 3 T2/
Please adjust import settings to:
Image type: 32-bit signed
Width: 128 pixels
Height: 256 pixels
Number of images: 50 images
Check Little-endian byte order
如您所见&filename
,保持不变,但我希望变量filename
中的数据位于其位置。