Hi everyone,
I stumbled upon something that seems very trivial. It is obvious that I am doing something wrong but can't find out what. I have the following problem: When I try to execute the following macro: //subtract dir1 from dir2 inputDir1 = getDirectory("Choose minuend image directory! "); inputDir2 = getDirectory("Choose subtrahend image directory! "); outputDir = getDirectory("Choose Output image directory! "); fileList1 = getFileList(inputDir1); fileList2 = getFileList(inputDir2); if (fileList1.length != fileList2.length) { exit("Input directories must have same number of files."); } for (i = 0; i < fileList1.length; i++) { file1 = fileList1[i]; file2 = fileList2[i]; open(file1); id1 = getImageID(); open(file2); id2 = getImageID(); imageCalculator("Subtract ", id1, id2); outName = File.getName(file1) + "-" + File.getName(file2); saveAs("Tiff", outputDir + "/" + outName); } // the opener returns this message: "File is not in a supported format, a reader plugin is not available or it was not found." The thing is that when I try to open it from the file menu it opens just fine (these are simple tif files generated by imagej). Even more other macros that I use (like the batch folder process macro) also open the files in these directories. I traced the problem to the following (although i am not sure that this is the problem): When i use the File>Open command the Macro recorder shows the path to the file with double backslashes (D:\\My Documents\\Processing\\All-red\\2256_1.tif") When I used the print command it turned out that the getDirectory command writes the path with single backslashes. I do not know what to do. Please help I've got too many files to load and subtract separately. Thanks in advance! Stoyan -- Dr. Stoyan P. Pavlov, MD, PhD Departament of Anatomy, Histology and Embryology Medical University "Prof. Dr. Paraskev Stoyanov", Varna Prof. Marin Drinov Str.55 9002 Varna Bulgaria Tel: +359 (0) 52 - 677 - 086 e-mail: [hidden email] -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dear Stoyan,
file1 is only the filename, without the path. You should use open(inputDir1+file1) instead of open (file1). Same for file2. Sincerely, Jerome On 7 April 2013 17:49, Stoyan Pavlov <[hidden email]> wrote: > Hi everyone, > I stumbled upon something that seems very trivial. It is obvious that I am > doing something wrong but can't find out what. I have the following > problem: > When I try to execute the following macro: > > //subtract dir1 from dir2 > inputDir1 = getDirectory("Choose minuend image directory! "); > inputDir2 = getDirectory("Choose subtrahend image directory! "); > outputDir = getDirectory("Choose Output image directory! "); > fileList1 = getFileList(inputDir1); > fileList2 = getFileList(inputDir2); > if (fileList1.length != fileList2.length) { > exit("Input directories must have same number of files."); > } > for (i = 0; i < fileList1.length; i++) { > file1 = fileList1[i]; > file2 = fileList2[i]; > open(file1); > id1 = getImageID(); > open(file2); > id2 = getImageID(); > imageCalculator("Subtract ", id1, id2); > outName = File.getName(file1) + "-" + File.getName(file2); > saveAs("Tiff", outputDir + "/" + outName); > } > // > > the opener returns this message: > "File is not in a supported format, a reader plugin is not available or it > was not found." > The thing is that when I try to open it from the file menu it opens just > fine (these are simple tif files generated by imagej). Even more other > macros that I use (like the batch folder process macro) also open the files > in these directories. I traced the problem to the following (although i am > not sure that this is the problem): When i use the File>Open command the > Macro recorder shows the path to the file with double backslashes (D:\\My > Documents\\Processing\\All-red\\2256_1.tif") > When I used the print command it turned out that the getDirectory command > writes the path with single backslashes. I do not know what to do. Please > help I've got too many files to load and subtract separately. > Thanks in advance! > > Stoyan > -- > Dr. Stoyan P. Pavlov, MD, PhD > Departament of Anatomy, Histology and Embryology > Medical University "Prof. Dr. Paraskev Stoyanov", Varna > Prof. Marin Drinov Str.55 > 9002 Varna > Bulgaria > Tel: +359 (0) 52 - 677 - 086 > e-mail: [hidden email] > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thank you very much, Jerome!
That did it! Stoyan 2013/4/7 Jerome Mutterer <[hidden email]> > Dear Stoyan, > file1 is only the filename, without the path. > You should use open(inputDir1+file1) instead of open (file1). > Same for file2. > Sincerely, > > Jerome > > > On 7 April 2013 17:49, Stoyan Pavlov <[hidden email]> wrote: > > > Hi everyone, > > I stumbled upon something that seems very trivial. It is obvious that I > am > > doing something wrong but can't find out what. I have the following > > problem: > > When I try to execute the following macro: > > > > //subtract dir1 from dir2 > > inputDir1 = getDirectory("Choose minuend image directory! "); > > inputDir2 = getDirectory("Choose subtrahend image directory! "); > > outputDir = getDirectory("Choose Output image directory! "); > > fileList1 = getFileList(inputDir1); > > fileList2 = getFileList(inputDir2); > > if (fileList1.length != fileList2.length) { > > exit("Input directories must have same number of files."); > > } > > for (i = 0; i < fileList1.length; i++) { > > file1 = fileList1[i]; > > file2 = fileList2[i]; > > open(file1); > > id1 = getImageID(); > > open(file2); > > id2 = getImageID(); > > imageCalculator("Subtract ", id1, id2); > > outName = File.getName(file1) + "-" + File.getName(file2); > > saveAs("Tiff", outputDir + "/" + outName); > > } > > // > > > > the opener returns this message: > > "File is not in a supported format, a reader plugin is not available or > it > > was not found." > > The thing is that when I try to open it from the file menu it opens just > > fine (these are simple tif files generated by imagej). Even more other > > macros that I use (like the batch folder process macro) also open the > files > > in these directories. I traced the problem to the following (although i > am > > not sure that this is the problem): When i use the File>Open command the > > Macro recorder shows the path to the file with double backslashes (D:\\My > > Documents\\Processing\\All-red\\2256_1.tif") > > When I used the print command it turned out that the getDirectory command > > writes the path with single backslashes. I do not know what to do. Please > > help I've got too many files to load and subtract separately. > > Thanks in advance! > > > > Stoyan > > -- > > Dr. Stoyan P. Pavlov, MD, PhD > > Departament of Anatomy, Histology and Embryology > > Medical University "Prof. Dr. Paraskev Stoyanov", Varna > > Prof. Marin Drinov Str.55 > > 9002 Varna > > Bulgaria > > Tel: +359 (0) 52 - 677 - 086 > > e-mail: [hidden email] > > > > -- > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- Dr. Stoyan P. Pavlov, MD, PhD Departament of Anatomy, Histology and Embryology Medical University "Prof. Dr. Paraskev Stoyanov", Varna Prof. Marin Drinov Str.55 9002 Varna Bulgaria Tel: +359 (0) 52 - 677 - 086 e-mail: [hidden email] -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Stoyan Pavlov
Hi!
I got the same problem while running a macro, but it doesn't look like this case. That's the beginning of the macro : if (list1.length != list2.length) { exit("Input directories must have same number of files."); } for (i = 0; i < list1.length; i++) { file1 = list1[i]; file2 = list2[i]; open(dir1+file1); run("Create Selection"); run("Make Inverse"); open(dir2+file2); run("Restore Selection"); run("Measure", "select = Area Mean Min Max" ); etc I did not copy the paths because they're fine. I also tried to write inputDir and so on so far, but it does not change anything, it still can't open any file (and the files are juste simple tif...) Thanks in advance! -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Nadi,
please specify your problem more clearly. Is "The same problem" the following error message (as discussed in this mailing list more than 5 years ago)? "File is not in a supported format, a reader plugin is not available or it was not found." Then please print the file paths to the log file before opening the files print(dir1+file1); print(dir2+file2); and see whether they are correct. If they are correct, try opening the files manually and see what error message you get. Michael ________________________________________________________________ On 07.02.19 11:22, Nadi wrote: > Hi! > > I got the same problem while running a macro, but it doesn't look like this > case. > That's the beginning of the macro : > > if (list1.length != list2.length) { > exit("Input directories must have same number of files."); > } > for (i = 0; i < list1.length; i++) { > file1 = list1[i]; > file2 = list2[i]; > open(dir1+file1); > run("Create Selection"); > run("Make Inverse"); > open(dir2+file2); > run("Restore Selection"); > run("Measure", "select = Area Mean Min Max" ); > etc > > > I did not copy the paths because they're fine. I also tried to write > inputDir and so on so far, but it does not change anything, it still can't > open any file (and the files are juste simple tif...) > > Thanks in advance! > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
hi Michael,
yes, the message I got was the same of the first user opening this topic, the macro couldn't open the tif files and gave me this error saying that a plugin was missing or wasn't found. Nevertheless, I followed your advices and I tried to print the paths and there was somehow a problem (i was getting symbols instead of letters). By creating two other folders and changing Dir1 and Dir2, it works again. So I guess that there was a problem with the two folders i was using before! thanks a lot! -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |