Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nikon

This Python package provides control of the Nikon Ti2-E microscope with support for all major platforms. It does not rely on the Nikon SDK but instead uses the reverse-engineered USB protocol of the microscope directly through PyUSB.

Installation

$ pip install nikon

Limitations

  • On Windows, the driver for the Nikon Ti2-E must be set to WinUSB or another driver supported by libusb, if you are using libusb as a backend for PyUSB. After changing the driver, NIS Elements won't be able to connect to the microscope until the driver is uninstalled and the default driver is re-installed. The driver installation procedure can be automated with libwdi.
  • On macOS (and Linux?), a firmware bug causes get_event() and other status-related functions to return with a minimal delay of 4.096 seconds between calls. Furthermore, the returned data may not be up-to-date as events are queued by the firmware.

Example usage

import asyncio
from nikon import MicroscopeDevice

async def main():
  devices = MicroscopeDevice.list()
  device = next(devices)

  await device.set_x(-31790)
  await device.set_y(28120)

  await device.set_condenser(3)
  await device.set_light(True)

  async for event in device:
    match event:
      case StatusEvent():
        event.condenser
        event.dia
        event.filter
        event.light
        event.objective
        event.optical_path
        event.x
        event.y
        event.z


asyncio.run(main())

Every command first tries to acquire a lock common to the device, therefore starting two commands at the same time will still cause them to run sequentially.

If you do not wish to use functions asynchronously, you can wrap all calls with asyncio.run().

asyncio.run(device.set_x(-31790))
asyncio.run(device.set_light(True))

About

Python package that provides control of the Nikon Ti2-E microscope, through its USB protocol reverse-engineered

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages