Welcome to TSICam’s documentation!

General Instructions

This software provides ARTIQ support for the Thorlabs Scientific Imaging cameras.

Note

The software is intended for use with Thorlabs’ Scientific Imaging and Compact Scientific Imaging cameras only.

Installation

Install the TSICam package to your environment using pip with git:

$ python -m pip install git+https://github.com/ARTIQ-Controllers/TSICam

Install Revision G of the Scientific Camera Interface from Thorlabs . The file is located under Programming Interfaces -> Windows SDK and Doc. for Scientific Cameras.

After installation, move the unzipped folder (called Scientific_Camera_Interfaces-Rev_G) to the appropriate path (C:\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support for Windows).

Then use pip to install the SDK to your environment:

$ python -m pip install "C:\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific_Camera_Interfaces-Rev_G\Scientific Camera Interfaces\SDK\Python Compact Scientific Camera Toolkit\thorlabs_tsi_camera_python_sdk_package.zip"

Finally, the user must specify the Scientific Camera DLL folder path within TSICam\tsi_library.py.

For Windows, the folder path is usually C:\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific_Camera_Interfaces-Rev_G\Scientific Camera Interfaces\SDK\Native Compact Camera Toolkit\dlls. The software automatically selects the Native_32_lib or Native_64_lib folder, depending on your system.

TSICam Controller Usage Example

First, run the TSICam controller:

$ aqctl_TSICam --bind ::1 -p 3252 -d 09423 -e 0.02

Note

Arguments -d and -e are optional.

The camera’s serial number can be given in the -d argument. If nothing is given, the sofware will automatically connect to the first available TSI camera.

The exposure time in seconds can be given in the -e argument. If nothing is given, the expsoure will be set to the camera’s minimum value.

Then, send commands via the sipyco_rpctool utility:

$ sipyco_rpctool ::1 3252 list-targets
Target(s):   camera
$ sipyco_rpctool ::1 3252 call acq_single() # will acquire and return a single image
$ sipyco_rpctool ::1 3252 call set_exposure(0.01) # will set the exposure to 10ms
$ sipyco_rpctool ::1 3252 call get_exposure() # will return the current exposure time in seconds
$ sipyco_rpctool ::1 3252 call close() # will close connection to the camera

API

class TSICam.driver.TSICam(sn=None, framebuffer_len=100)

Class for interfacing with a single Thorlabs Scientific Imaging (TSI) camera.

A TSICam instance can be initialized using the desired serial number. If no serial number is specified, it connects to first listed camera.

The get_image function returns images from a frame buffer; in order to to have images in the buffer, either start_acquisition (which acquires images continuously) or single_acquisition must be called.

Callbacks can be registered such that for every new frame acquired, the function is called, with the numpy array forming the image as the sole argument.

Parameters:
  • sn – camera serial number
  • framebuffer_len – length of frame buffer
Sn type:

str

Framebuffer_len type:
 

int

acquire_and_get_single_image()

Triggers a single image acquisition and returns image.

Returns:image
Return type:numpy array
close()

Disconnects from camera and cleans up library.

deregister_callback(f)

Deregister a function to be called from the acquisition thread.

Parameters:f – function to deregister
F type:func
get_all_images()

Returns all of the images in the buffer as an array of numpy arrays, or None if no new images.

Returns:array of images
Return type:numpy array, or None
get_exposure_params()

Return current exposure, minimum, maximum and increment values.

Returns:(exposure, exposure min, exposure max, exposure inc)
Return type:tuple
get_frame_rate_params()

Return current frame rate, minimum, maximum and increment values. Only works if frame rate control is enabled.

Returns:(frame rate, frame rate min, frame rate max, frame rate inc)
Return type:tuple
get_image()

Returns the oldest image in the buffer as a numpy array, or None if no new images.

Returns:image
Return type:numpy array, or None
get_pixel_width()

Returns pixel width in microns.

Returns:pixel width in microns
Return type:float
get_serial_no()

Return camera serial number.

Returns:camera serial number
Return type:str
handle_auto_exposure(image)

Reads the most recent image and updates exposure

Parameters:image – most recent image
Image type:numpy array
register_callback(f)

Register a function to be called from the acquisition thread for each new image.

Parameters:f – function to register
F type:func
set_auto_exposure(auto_exposure)

Enable/disable auto exposure.

Parameters:auto_exposure – True to enable auto exposure, False to disable
Auto_exposure type:
 bool
set_exposure_ms(exposure_time)

Set the camera exposure time in ms.

Parameters:exposure_time – New exposure time in ms.
Exposure_time type:
 float
set_exposure_time(exposure_time)

Set the CCD exposure time in seconds.

Parameters:exposure_time – New exposure time in seconds.
Exposure_time type:
 float
set_image_region(hStart, hEnd, vStart, vEnd, **kwargs)

Set the CCD region to read out. The region is 0 indexed and inclusive, so the valid ranges for hStart is 0 … self.ccd_width - 1 etc.

Parameters:
  • hStart – starting point for horizontal axis
  • hEnd – ending point for horizontal axis
  • vStart – starting point for vertical axis
  • vEnd – ending point for vertical axis
HStart type:

float

HEnd type:

float

VStart type:

float

VEnd type:

float

single_acquisition()

Single acquisition. Turns on auto acquire, and then turns it off after one acquisition.

start_acquisition(single=False)

Turn on auto acquire

stop_acquisition()

Turn off auto acquire

ARTIQ Controller

Thorlabs Camera controller.

Use this controller to drive Thorlabs Scientific Imaging cameras.

usage: aqctl_TSICam [-h] [--bind BIND] [--no-localhost-bind] [-p PORT]
                    [-d DEVICE] [-e EXPOSURE] [-v] [-q]

Named Arguments

-d, --device Camera serial number. Connects to first available camera if not used.
-e, --exposure Exposure time in seconds. Defaults to minimum if not used.

network server

--bind

additional hostname or IP address to bind to; use ‘*’ to bind to all interfaces (default: [])

Default: []

--no-localhost-bind
 

do not implicitly also bind to localhost addresses

Default: False

-p, --port

TCP port to listen on (default: 3252)

Default: 3252

verbosity

-v, --verbose

increase logging level

Default: 0

-q, --quiet

decrease logging level

Default: 0

Acknowledgements

The driver file was largely adapted from: https://github.com/OxfordIonTrapGroup/mjolnir .

Indices and tables