Last active
August 17, 2020 08:02
-
-
Save oeway/54c85eebb4f5c320a7aa0b2501e1b767 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import numpy as np | |
class ImJoyPlugin(): | |
async def setup(self): | |
bridge = Bridge() | |
self._core = bridge.get_core() | |
self._core.set_exposure(float(100)) | |
exposure = self._core.get_exposure() | |
api.showMessage('MMcore loaded, exposure: ' + str(exposure)) | |
def snapImage(self): | |
self._core.snap_image() | |
tagged_image = self._core.get_tagged_image() | |
image_array = np.reshape(tagged_image.pix, newshape=[tagged_image.tags['Height'], tagged_image.tags['Width']]) | |
image_array = (image_array/image_array.max()*255).astype('uint8') | |
return image_array | |
async def run(self, ctx): | |
viewer = await api.createWindow(src="https://kaibu.org/#/app") | |
image = np.random.randint(0, 255, [500, 500], dtype='uint8') | |
# view image | |
await viewer.view_image(self.snapImage(), type="itk-vtk", name="new image") | |
async def snap_image(): | |
await viewer.view_image(self.snapImage(), type="itk-vtk", name="new image") | |
await viewer.set_ui({"title": "Microscope Control", | |
"elements": [ | |
{"_rintf": True, | |
"type": "button", | |
"label": "Snap Image", | |
"callback": snap_image | |
} | |
] | |
}) | |
api.export(ImJoyPlugin(), {"name": "demo"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from imjoy_rpc import api | |
from pycromanager import Bridge | |
class ImJoyPlugin(): | |
async def setup(self): | |
bridge = Bridge() | |
self._core = bridge.get_core() | |
exp = await api.prompt('Exposure time') | |
self._core.set_exposure(float(exp)) | |
exposure = self._core.get_exposure() | |
api.showMessage('MMcore loaded, exposure: ' + str(exposure)) | |
def snapImage(self): | |
self._core.snap_image() | |
tagged_image = self._core.get_tagged_image() | |
image_array = np.reshape(tagged_image.pix, newshape=[tagged_image.tags['Height'], tagged_image.tags['Width']]) | |
image_array = (image_array/image_array.max()*255).astype('uint8') | |
return image_array | |
async def run(self, ctx): | |
viewer = await api.showDialog(type="itk-vtk-viewer", | |
src="https://oeway.github.io/itk-vtk-viewer/?imjoy=1") | |
api.showMessage('Acquiring 10 images') | |
for i in range(10): | |
await viewer.imshow(self.snapImage()) | |
api.showMessage('Done.') | |
api.export(ImJoyPlugin(), {"name": "demo"}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment