Skip to content

Instantly share code, notes, and snippets.

@ctrueden
Last active January 13, 2020 09:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctrueden/c26b1eb592db2897ab1061031e726620 to your computer and use it in GitHub Desktop.
Save ctrueden/c26b1eb592db2897ab1061031e726620 to your computer and use it in GitHub Desktop.
Add Bio-Formats to a SciJava Jupyter notebook
#@ImageJ ij
// -- Functions --
registerAndCreatePlugin = { pluginClass, pluginType ->
info = new org.scijava.plugin.PluginInfo(pluginClass, pluginType)
ij.plugin().addPlugin(info)
ij.plugin().createInstance(info)
}
registerService = { serviceClass ->
service = registerAndCreatePlugin(serviceClass, org.scijava.service.Service.class)
ij.context().getServiceIndex().add(service)
}
// -- Add Bio-Formats support --
#@repository("https://maven.imagej.net/content/groups/public")
#@dependency(group = "io.scif", module = "scifio-bf-compat", version = "2.0.3")
#@dependency(group = "ome", module = "formats-gpl", version = "5.5.2")
registerService(io.scif.ome.services.DefaultOMEXMLService.class)
bff = registerAndCreatePlugin(io.scif.bf.BioFormatsFormat.class, io.scif.Format.class)
ij.scifio().format().addFormat(bff)
// -- Load something! --
myAwesomeData = ij.io().open("/path/to/myAwesomeImageThatOnlyBioFormatsCanRead")
@ctrueden
Copy link
Author

ctrueden commented Jun 22, 2017

The above snippet should work for SciJava Jupyter Kernel version 0.4.0.

Future versions of the kernel will improve matters. If you are reading this and the date stamp above is old, please be aware that this gist has probably become obsolete. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment