Extending Cockpit for local setups¶

In general it is hoped that the functionality implemented in Cockpit will be sufficient for most setups, however it is also rather easy to extend Cockpit with local customisation’s that extend the functionality for specific use cases.

Most dynamic actions within Cockpit result in the emission of specific events. Examples of this are the arrival of a new camera image, the change in state of an input line, or the movement of the stage. These events can be subscribed to in order to trigger specific actions on the firing of a specific event. The following code will subscribe to the input signal change and take a snap image when that occurs.

This code could be directly run in the Python shell window. This first imports some essential libraries then defines a function that will be triggered on the DIO_INPUT event and checks to see if line 3 has become True. If so, it snaps an image with the currently active cameras.

from cockpit import events
import wx

def trigger_event(line, state):
    if line == 3 and state is True:

events.subscribe(events.DIO_INPUT, trigger_event)

This is a simple example, and a more involved setup which identifies nuclei in snapped images and then adds their position to a marked point list for later followup is contained in the Microscope-Cockpit paper.