We're Hiring!

Fiji: Jython scripts not saving output files

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

Fiji: Jython scripts not saving output files

Postby jswalker » Thu May 12, 2016 5:13 pm

Hi all,

I'm developing a series of Jython scripts intended to be run directly from Fiji's [ Plugins > Macros > Run ] command, to make them accessible to our student researchers - some of whom may have little to no programming experience. In all cases these are just Python versions of working IJ macros we use all the time.

Both of the scripts I've completed are not saving any output files to disk, and not throwing any errors, and I'm totally stumped. Help?

Here is the github repository for the short one - a ND2 to JPG batch conversion script.

The variables under process() return values like this, for example, as spit out by the IJ log during debugging:

currentDir is G:\img dir
saveDir is G:\img dir
fileName is B5.07 04b.nd2
path is G:\img dir\B5.07 04b.nd2

So the actual save command would evaluate to fs.saveAsJpeg(G:\Subdir testing\B5.07 04b.nd2), which I think should be correct, right? (Interesting: a transient .tmp file is created in the directory as the ND2 is processed, though no JPEG is created. What gives??)

The other script saves several different files and has the same problem as above:
IJ.saveAs(imp4, "Jpeg", os.path.join(saveDir, fileName))
rm = RoiManager.getInstance()
rm.runCommand("Save", fileName + ".zip")
ht = rm.getList()
ht.removeAll()
IJ.saveAs("Results", fileName+".csv")
IJ.run("Close")
IJ.selectWindow("Log")
IJ.saveAs("Text", fileName+".txt")
IJ.run("Close")
IJ.run("Clear Results")
imp4.close()
imp3.close()
imp2.close()
imp.close()

What I've tried:
-Moving everything to a local drive instead of accessing a network drive; no change
-Running Fiji in administrator mode; no change
-Checking the file permissions of both FIJI and the .py file I'm running (I made sure that it had full write/append/makedir functions for all users, but no change. I did this both using the properties menu and icacls on the Windows command line. ???)
-Running the script from the Script Editor in FIJI - no errors, but no output, either

So I'm out of ideas. Any suggestions would be much appreciated!

Thanks in advance.
jswalker
 
Posts: 2
Joined: Wed May 11, 2016 6:56 pm

Re: Fiji: Jython scripts not saving output files

Postby mlinkert » Thu May 12, 2016 5:41 pm

Hi,

Here is the github repository for the short one - a ND2 to JPG batch conversion script.

The variables under process() return values like this, for example, as spit out by the IJ log during debugging:

currentDir is G:\img dir
saveDir is G:\img dir
fileName is B5.07 04b.nd2
path is G:\img dir\B5.07 04b.nd2

So the actual save command would evaluate to fs.saveAsJpeg(G:\Subdir testing\B5.07 04b.nd2), which I think should be correct, right? (Interesting: a transient .tmp file is created in the directory as the ND2 is processed, though no JPEG is created. What gives??)


If I read correctly, the above output suggests that the input and output files would be the same, i.e. fs.saveAsJpeg("G:\img dir\B5.07 04b.nd2") would be called. Can you confirm that the file size and/or modification time of "G:\img dir\B5.07 04b.nd2" has not changed after running the script?

You may also wish to explicitly append the ".jpg" extension when calling "fs.saveAsJpeg(...)", to aid debugging and avoid confusion for anyone working with these files later on.

The other script saves several different files and has the same problem as above:
IJ.saveAs(imp4, "Jpeg", os.path.join(saveDir, fileName))


I'd assume a similar issue here - if "saveDir" is the same as the input directory, then the input and output files would be the same. Again, appending ".jpg" to "fileName" should help to narrow this down, and is good practice in any case.

Regards,
-Melissa
User avatar
mlinkert
Team Member
 
Posts: 353
Joined: Fri May 29, 2009 2:12 pm
Location: Southwest Wisconsin

Re: Fiji: Jython scripts not saving output files

Postby jswalker » Thu May 12, 2016 6:20 pm

Right you are - a few more tweaks and it works beautifully now. Thank you so much.
jswalker
 
Posts: 2
Joined: Wed May 11, 2016 6:56 pm


Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 0 guests