IMAQdx Cameras

Installation

Usage

Detailed Documentation

class labscript_devices.IMAQdxCamera.labscript_devices.IMAQdxCamera(name, parent_device, connection, serial_number, orientation=None, trigger_edge_type='rising', trigger_duration=None, minimum_recovery_time=0.0, camera_attributes=None, manual_mode_camera_attributes=None, stop_acquisition_timeout=5.0, exception_on_failed_shot=True, saved_attribute_visibility_level='intermediate', mock=False, **kwargs)[source]

Bases: labscript.labscript.TriggerableDevice

A camera to be controlled using NI IMAQdx and triggered with a digital edge.

Parameters
  • name (str) – device name

  • parent_device (IntermediateDevice) – Device with digital outputs to be used to trigger acquisition

  • connection (str) – Name of digital output port on parent device.

  • serial_number (str or int) – string or integer (integer allows entering a hex literal) of the camera’s serial number. This will be used to idenitfy the camera.

  • orientation (str, optional) – <name> Description of the camera’s location or orientation. This will be used to determine the location in the shot file where the images will be saved. If not given, the device name will be used instead.

  • trigger_edge_type (str) – 'rising' The direction of the desired edges to be generated on the parent devices’s digital output used for triggering. Must be ‘rising’ or ‘falling’. Note that this only determines the edges created on the parent device, it does not program the camera to expect this type of edge. If required, one must configure the camera separately via camera_attributes to ensure it expects the type of edge being generated. Default: 'rising'

  • trigger_duration (float or None) – None Duration of digital pulses to be generated by the parent device. This can also be specified as an argument to expose() - the value given here will be used only if nothing is passed to expose().

  • minimum_recovery_time (float) – 0 Minimum time between frames. This will be used for error checking during compilation.

  • camera_attributes (dict, optional) – Dictionary of camera attribute names and values to be programmed into the camera. The meaning of these attributes is model-specific. Attributes will be programmed in the order they appear in this dictionary. This can be important as some attributes may not be settable unless another attrbiute has been set first. After adding this device to your connection table, a dictionary of the camera’s default attributes can be obtained from the BLACS tab, appropriate for copying and pasting into your connection table to customise the ones you are interested in.

  • manual_mode_camera_attributes (dict, optional) – Dictionary of attributes that will be programmed into the camera during manual mode, that differ from their values in camera_attributes. This can be useful for example, to have software triggering during manual mode (allowing the acquisition of frames from the BLACS manual mode interface) but hardware triggering during buffered runs. Any attributes in this dictionary must also be present in camera_attributes.

  • stop_acquisition_timeout (float) – 5.0 How long, in seconds, to wait during transition_to_buffered for the acquisition of images to complete before giving up. Whilst all triggers should have been received, this can be used to allow for slow image download time.

  • exception_on_failed_shot (bool) – True. If acquisition does not complete within the given timeout after the end of a shot, whether to raise an exception. If False, instead prints a warning to stderr (visible in the terminal output pane in the BLACS tab), saves the images acquired so far, and continues. In the case of such a ‘failed shot’, the HDF5 attribute f[‘images’][orientation/name].attrs[‘failed_shot’] will be set to True (otherwise it is set to False). This attribute is acessible in the lyse dataframe as df[orientation/name, 'failed_shot'].

  • saved_attribute_visibility_level (str or None) – ‘intermediate’ The detail level of the camera attributes saved to the HDF5 file at the end of each shot. If None, no attributes will be saved. Must be one of 'simple', 'intermediate', 'advanced', or None. If None, no attributes will be saved.

  • mock (bool, optional) – False For testing purpses, simulate a camera with fake data instead of communicating with actual hardware.

  • **kwargs – Further keyword arguments to be passed to the __init__ method of the parent class (TriggerableDevice).

description = 'IMAQdx Camera'
expose(t, name, frametype='frame', trigger_duration=None)[source]

Request an exposure at the given time. A trigger will be produced by the parent trigger object, with duration trigger_duration, or if not specified, of self.trigger_duration. The frame should have a name, and optionally a `frametype, both strings. These determine where the image will be stored in the hdf5 file. name should be a description of the image being taken, such as “insitu_absorption” or “fluorescence” or similar. frametype is optional and is the type of frame being acquired, for imaging methods that involve multiple frames. For example an absorption image of atoms might have three frames: ‘probe’, ‘atoms’ and ‘background’. For this one might call expose three times with the same name, but three different frametypes.

generate_code(hdf5_file)[source]
class labscript_devices.IMAQdxCamera.blacs_tabs.IMAQdxCameraTab(notebook, settings, restart=False)[source]

Bases: blacs.device_base_class.DeviceTab

get_save_data()[source]
initialise_GUI()[source]
initialise_workers()[source]
on_attr_visibility_level_changed(value)[source]
on_attributes_clicked(button)[source]
on_continuous_clicked(button)[source]
on_copy_clicked(button)[source]
on_max_rate_changed(max_fps)[source]
on_reset_rate_clicked()[source]
on_snap_clicked(*args, **kwargs)
on_stop_clicked(button)[source]
restart(*args, **kwargs)[source]
restore_save_data(save_data)[source]
start_continuous(*args, **kwargs)
stop_continuous(*args, **kwargs)
update_attributes(*args, **kwargs)
use_smart_programming = True
worker_class = 'labscript_devices.IMAQdxCamera.blacs_workers.IMAQdxCameraWorker'
class labscript_devices.IMAQdxCamera.blacs_tabs.ImageReceiver(image_view, label_fps)[source]

Bases: labscript_utils.ls_zprocess.ZMQServer

ZMQServer that receives images on a zmq.REP socket, replies ‘ok’, and updates the image widget and fps indicator

handler(data)[source]

To be overridden by subclasses. This is an example implementation

labscript_devices.IMAQdxCamera.blacs_tabs.exp_av(av_old, data_new, dt, tau)[source]

Compute the new value of an exponential moving average based on the previous average av_old, a new value data_new, a time interval dt and an averaging timescale tau. Returns data_new if dt > tau

class labscript_devices.IMAQdxCamera.blacs_workers.IMAQdxCameraWorker(*args, **kwargs)[source]

Bases: blacs.tab_base_classes.Worker

_send_image_to_parent(image)[source]

Send the image to the GUI to display. This will block if the parent process is lagging behind in displaying frames, in order to avoid a backlog.

abort()[source]
abort_buffered()[source]
abort_transition_to_buffered()[source]
continuous_loop(dt)[source]

Acquire continuously in a loop, with minimum repetition interval dt

get_attributes_as_dict(visibility_level)[source]

Return a dict of the attributes of the camera for the given visibility level

get_attributes_as_text(visibility_level)[source]

Return a string representation of the attributes of the camera for the given visibility level

get_camera()[source]

Return an instance of the camera interface class. Subclasses may override this method to pass required arguments to their class if they require more than just the serial number.

init()[source]
interface_class

alias of labscript_devices.IMAQdxCamera.blacs_workers.IMAQdx_Camera

program_manual(values)[source]
set_attributes_smart(attributes)[source]

Call self.camera.set_attributes() to set the given attributes, only setting those that differ from their value in, or are absent from self.smart_cache. Update self.smart_cache with the newly-set values

shutdown()[source]
snap()[source]

Acquire one frame in manual mode. Send it to the parent via self.image_socket. Wait for a response from the parent.

start_continuous(dt)[source]

Begin continuous acquisition in a thread with minimum repetition interval dt

stop_continuous(pause=False)[source]

Stop the continuous acquisition thread

transition_to_buffered(device_name, h5_filepath, initial_values, fresh)[source]
transition_to_manual()[source]
class labscript_devices.IMAQdxCamera.blacs_workers.IMAQdx_Camera(serial_number)[source]

Bases: object

_decode_image_data(img)[source]
abort_acquisition()[source]
close()[source]
configure_acquisition(continuous=True, bufferCount=5)[source]
get_attribute(name)[source]

Return current value of attribute of the given name

get_attribute_names(visibility_level, writeable_only=True)[source]

Return a list of all attribute names of readable attributes, for the given visibility level. Optionally return only writeable attributes

grab(waitForNextBuffer=True)[source]
grab_multiple(n_images, images, waitForNextBuffer=True)[source]
set_attribute(name, value)[source]

Set the value of the attribute of the given name to the given value

set_attributes(attr_dict)[source]
snap()[source]

Acquire a single image and return it

stop_acquisition()[source]
class labscript_devices.IMAQdxCamera.blacs_workers.MockCamera[source]

Bases: object

Mock camera class that returns fake image data.

abort_acquisition()[source]
close()[source]
configure_acquisition(continuous=False, bufferCount=5)[source]
get_attribute(name)[source]
get_attribute_names(visibility_level=None)[source]
grab()[source]
grab_multiple(n_images, images, waitForNextBuffer=True)[source]
set_attributes(attributes)[source]
snap()[source]
stop_acquisition()[source]
labscript_devices.IMAQdxCamera.blacs_workers._monkeypatch_imaqdispose()[source]

Monkeypatch a fix to a memory leak bug in pynivision. The pynivision project is no longer active, so we can’t contribute this fix upstream. In the long run, hopefully someone (perhaps us) forks it so that bugs can be addressed in the normal way