Open schluta opened 3 years ago
Hi @schluta ,
To initialize the plugin with a local Fiji installation subscribed to the Neuroanatomy update site through pyimagej:
import imagej
ij = imagej.init(fiji_path, headless=False) # set True if headless
ij.ui().showUI() # comment out if headless
from scyjava import jimport
SNTUtils = jimport('sc.fiji.snt.SNTUtils')
print("We are running SNT %s" % SNTUtils.VERSION)
SNTService = jimport('sc.fiji.snt.SNTService')
# Retrieve the SNTService instance associated with the main application context
sntService = ij.get(SNTService.class_)
# Initialize the plugin
plugin = sntService.initialize("./test.tif", True) # Start UI, set False if headless
On the first error, it is due to the second argument to SNT()
, which expects either a PathAndFillManager
instance or ImagePlus
instance, instead of a file path String
snt_inst = SNT(context, "./test.tif")
On the second error, the SNTService
created via snt = SNTService()
does not have a SciJava Context
associated with it, so it is not very useful in that state. We can get the context-aware service instance using sntService = ij.get(SNTService.class_)
For the third error, my guess is you tried to call SNT.initialize()
on the SNT
class itself, instead of an instance.
snt_inst.initialize(imp)
In any case, it is preferred to start the plugin via one of the SNTService.initialize()
flavors as these perform some internal initialization and checks which would have to be re-scripted if constructing an SNT
instance manually.
You may also find the discussion https://github.com/morphonets/SNT/issues/60 interesting
Feature Request: It seems all of the example scripts for using the SNT plugin from python through pyimagej are using the MouseLightLoader to load a remote dataset. I am trying to instantiate the service and use it locally (potentially in a headless manner). I have tried both the SNT class initialize and SNTService initialize functions but neither have worked for me. It would really help to see an example of instantiating the plugin from python. I need to use other python packages so using the scripting interface from within Fiji will not work for me.
Output
If I do not try to run the SNT constructor then I get the following Output:
If I try and run the SNT.initialize method I get either the following based on which one I try: