2

I want to write some code in Python that will be used for manipulating data in Fiji. I followed the instructions to install the library "imagej" so that I can access Fiji via Anaconda-Python. This is how the two lines look like:

import imagej
ij = imagej.init('C:\Program Files\Fiji\Fiji.app')

However, when I run these two lines the following error shows:

JavaException: JVM exception occurred: net/imagej/updater/UpdateService

Apparently Python is trying to access Fiji Updater but it cannot (that's what I understand...) How can I run Fiji correctly without such an error? Is there any way to disable this?

pedro_galher
  • 334
  • 8
  • 18

1 Answers1

0

I'm no expert, and actually have no experience with interfacing via Python, but my best guess is to try turning off "check for update on start" to see if that changes anything. It may be that Python is successfully getting FIJI to run, but the first thing FIJI needs is for you to tell it whether you want to update, etc.

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
ekiely
  • 92
  • 8
  • Sure! I was thinking about that too... Do you know where is this "check for update on start" button? Thanks :) – pedro_galher Sep 11 '19 at 09:09
  • Anyway, I eventually opted for writing the code directly in Fiji with its own language... – pedro_galher Sep 11 '19 at 09:10
  • Hey @pedro_galher, I am not sure. I was operating under the assumption that it would exist to begin with, but I may be incorrect. I did find a discussion on GitHub about this very topic though! You can find that here: https://github.com/imagej/imagej-updater/issues/7 Would you provide the macro code you wrote? I'd also like to see what you have managed to come up with in Python, and/or how you get it to talk to FIJI. I've been trying to do that myself but keep getting pulled back into writing macros because they're more accessible to my coworkers. – ekiely Sep 11 '19 at 17:24
  • Of course! Here is a simple macro I wrote in Fiji for analysing a stack of images generated by a CT-Scan: https://github.com/pedrogalvez/Analysis-Stack-of-images – pedro_galher Sep 12 '19 at 09:16
  • For writing a macro in Fiji "Language" you must do: Plugings > Macros > Startup Macros. Then you select "IJ1 Macro" in the Language bar within the Script window. I have opted by writing everything in Fiji Language, so I'm not using Python in the end. Hope it helps! – pedro_galher Sep 12 '19 at 09:18
  • Hi Pedro, I've had success writing directly in the macro language (i.e. IJ1), but am interested in your pursuit of interfacing Python and FIJI, and was hoping your macro code my give me some insight there. Regardless, how are you managing to integrate the two? I see the import, etc., but once open in Python, how're you actually programming it? Still using IJ1? Also, try using / rather than \ and see if that changes anything (noticing your directory and the exception use opposites) – ekiely Sep 12 '19 at 21:25
  • Ahh.. I didn't integrate the two in the end since I programmed everything in IJ1 and didn't use Python at all. Initially, I thought about programming in Python and running it in Fiji but I rejected this idea when I noticed that It wasnt as easy as I though... So I did everything in Fiji in the end... – pedro_galher Sep 13 '19 at 10:17
  • Yeah, that's sort of the conclusion I came to in poking around. By the way, in looking over your macro, I noticed it is written very rigidly (i.e. to use it for files stored elsewhere, etc. it would require editing of the macro itself) and without batch processing turned on (i.e. you see all the images and what's occurring to them in real time on screen). If you would like help in making it more flexible (via user input of specific variables that change between data sets), etc. I can probably work with you on making that happen – ekiely Sep 13 '19 at 14:33
  • That´s really useful! Actually, is t possible to not see the images while processing them?? I suppose that turning this off should speed the processing greatly – pedro_galher Sep 13 '19 at 19:49
  • Hi Pedro, it is absolutely possible! All you need to do is wrap your functions in setBatchMode(true); ...code... setBatchMode(false); It absolutely speeds up processing time. If you would like an example of a more flexible implementation of the macro language, you can check out my GitHub (github.com/evanjkiely/FIJIMacros). Also, would you like for me to modify the code you provided to be more flexible in this way? We can also find a way to collaborate, such that you can learn by doing and I can answer questions as the come up. If so, maybe we can email directly – ekiely Sep 15 '19 at 20:08
  • Thanks a lot! Sure, I completely agree regarding the collaboration.The codes I wrote in Fiji aren't optimized at all since I just use it occasionally and don't really like to spend much time over them since I normally use Python for my daily job. However I would find really useful to learn from your experience in case I have any question :) My email is: pedrogalher@gmail.com Thanks! – pedro_galher Sep 17 '19 at 07:59
  • I'll send you an email now! – ekiely Sep 17 '19 at 16:38