2015-11-11 123 views
1

我想在ImageJ中使用批处理脚本批量转换200多个原始.img文件。我的脚本:ImageJ批量图像转换

//-----------Code starts here--------------------- 
dir1 = getDirectory("path/source"); 
dir2 = getDirectory("path/target"); 
list = getFileList(dir1); 
setBatchMode(true); 

for (i=0; i<list.length; i++) { 
     showProgress(i+1, list.length); 
     if(endsWith(list[i],".IMG")) 
     run("Raw...", open=["+dir1+list[i]+"] image=[16-bit Unsigned] width=2048 height=2048 offset=359 number=1 gap=0"); 
     else 
     open(dir1+list[i]); 
     saveAs(format, dir2+list[i]); 
     close(); 
    } 

然而,当我尝试运行它,我得到以下错误:

我不知道为什么但是,由于我有一个;关闭线...

enter image description here

回答

5

错误消息是误导,因为你错过了你的第二个参数的开头一个引号(“),以run()

run("Raw...", "open=["+dir1+list[i]+"] image=[16-bit Unsigned] width=2048 height=2048 offset=359 number=1 gap=0"); 

的错误消息中的<>字符指示解析器发现意外事件的位置。

我编辑了您的原始代码以包含语法highlig hting,这有助于找到这种错误。斐济的script editor包含语法高亮显示,并且在使用ImageJ宏时建议使用。

一般来说,特定ImageJ的,问题是更可能发生在专门的论坛贴出要及时回答:http://forum.imagej.net/

+0

谢谢! :) – MrD