I'm not sure if this is the right place for my problem, but maybe you can help me out.
I'm playing around with MicroManager (imageJ/C++ based microscope acquisition software, scriptable) at the moment and tried to start an image acquisition from a KNIME java snippet node for a start. This works fine the first time, but the second time, when I reset and rerun the node, I get the following warning:
'WARN JavaSnippetCellFactory Evaluation of java snippet failed for row "Row0". The exception is caused by line 28 of the snippet. Exception message:Native Library C:\Program Files\Micro-Manager-1.4\MMCoreJ_wrap.dll already loaded in another classloader'
Since I know very little Java and make my way as I go, I came to understand that at each run of the node, a different local instance of CMMCoreJ is generated, but since this is only possible once (as long as the dll is not unloaded) the second try fails.
Is it possible to load the dll globally at the start of the workflow or create a global object CMMCore which is then acessible to all subsequent nodes, or is there any other solution like using the same specific classloader each time?
I'm looking forward to any suggestions, thanks in advance!
I think you just reached the limits of the JavaSnippet Node. But maybe I can offer you an easy solution as a first workaround. What is the Snippet intended to do? As a Snippet works on Rowwise basis, can you explain whats the input and the output of the snippet?
thanks for your reply. The intent of the Snippet is to start an imaging sequence of the camera (later up to 10k images) and save them on the HD. I can do that already from the snippet and the images are written to the specified location just fine, but only the first time. Is it possible to create a Flowvariable of a custom Type (i.e. CMMCore), or a Snippet which performs the device initalization at the start of a workflow, for instance
and provides this 'core' object to all subsequent nodes? Subsequent nodes could then just do the imaging without having to create their own CMMCore (as is intended by MicroManager). I don't know if this can be done in KNIME.
In/Output: Since only one position at a time can be imaged, the input would be a set of imaging parameters (in one row or as Flowvariables) like exposure time, #frames, ROI coordinates / extend, path where to save the single images of the sequence (...).
Output should first be a note of sucess/caught errors or nothing. In a later step maybe also the acquired images for direct processing, but thats optional at the moment, since they are stored either way (and since it will later be thousands of images per sequence I don't want to keep them in the workflow just now).
I can give you acess to the PC running the snippet and an instance of MicroManager if you are interested in testing with the device connected :)
Your snippet is inside a loop? So you receive some information extracted from images, send the information to the microscope i.e. the command to take images, right?
I think this is not doable with a simple java snippet. What you could do is write your own Loop End Node which implements the functionality (as the output of the node doesn't seem to be very important anyway).
Sounds hard, but actually it is very easy to do that. If you like you can send me your code-snippet and I will send you a first version of this LoopEndNode. Are you heavily changing the code in the snippet? Then I would send you the sources and suggest that you install the KNIME SDK to develop.
Another nice solution would be to write a micromanager framework which allows you to share those connections via port-objects. Maybe this might be a nice project in the future (like with database connectors).
yes the Snippes is (intended to be) inside a loop. The loop should work on a position list (possibly, but not necessarily generated with KNIME) and at each position one image or a sequence should be snapped.
I've written my own small test-nodes with the KNIME SDK already, but don't know if I could manage something like this, guess I'll have to try ;) . So if you come around to create a first version, this would help me a lot, I could manipulate that.
Writing a micromanager framework and do the comunication via ports sounds great for a future project, though :)
I just set-up a small GitHub repository (https://github.com/dietzc/knip-micromanager). This repository contains a node skeleton for a "MicroManagerLoopEnd" Node. One assumption is, that you are able to shut den MicroManager Connection down, after you processed all your images?
Anyway, if you give me your github account I can add you as a contributor and you can also commit your code, then its easier for me to find potential bugs. Most important, you have to add the libraries to the project (put them into the lib folder) and then add them in the plugin.xml tab "Runtime" -> "Classpath" to your plugin classpath.
If you never used git or github before, its a good point to start. Its very easy to use (especially with the nice windows client for beginners) and you can really easily share code and work on a project in a team.