Skip to content

Instantly share code, notes, and snippets.

@mkitti
Last active December 28, 2020 19:31
Show Gist options
  • Save mkitti/2f7c5fc3d3f8b0d15dd13f6d67b0e73d to your computer and use it in GitHub Desktop.
Save mkitti/2f7c5fc3d3f8b0d15dd13f6d67b0e73d to your computer and use it in GitHub Desktop.
Invoking Napari from Julia Language 1.3.1
"""
napari.jl
Test using PyCall.jl to invoke Napari ( http://github.com/napari ) from
the Julia language ( https://julialang.org/ ) 1.3.1
Mark Kittisopikul
January 29th, 2020
"""
using PyCall
pygui_start(:qt5)
# needed to kickstart Qt5 for some reason
qapp_obj = pyimport("qtpy.QtWidgets").QApplication([""])
napari = pyimport("napari")
skimagedata = pyimport("skimage.data")
astronaut = skimagedata.astronaut();
# Modified 2020/09/14 to add name keyword argument
# https://github.com/napari/napari/issues/1630
napari.view_image(astronaut, name="astronaut")
using Images, TestImages
hela = testimage("hela-cells.tif");
hela = imadjustintensity(hela);
hela = channelview(hela);
hela = PermutedDimsArray(hela,(2,3,1));
#napari cannot handle UInt16 ?? Maybe QT issue
#hela = reinterpret(UInt16,hela);
napari.view_image(collect(Float32.(hela)))
mandrill = testimage("mandrill.tif");
mandrill = channelview(mandrill);
mandrill = reinterpret(UInt8,mandrill);
mandrill = PermutedDimsArray(mandrill,(2,3,1));
napari.view_image(collect(mandrill));
if !isinteractive()
qapp_obj.exec()
end
@mkitti
Copy link
Author

mkitti commented Dec 8, 2020

I haven't forgotten about this. Just a bit busy at the moment.

@mkitti
Copy link
Author

mkitti commented Dec 28, 2020

If you are interested in a full blown Julia package, check out the early preview of Napari.jl: https://github.com/mkitti/Napari.jl

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