camacq.plugins.leica package

Leica microscope API specific modules.

class camacq.plugins.leica.LeicaApi(center, config, client)

Bases: Api

Represent the Leica API.

property name

Return the name of the API.

async receive(replies)

Receive replies from CAM server and fire an event per reply.

Parameters:

replies (list) – A list of replies from the CAM server.

async send(command, **kwargs)

Send a command to the Leica API.

Parameters:

command (list of tuples or string) – The command to send.

async send_many(commands, **kwargs)

Send multiple commands to the microscope API.

Parameters:

commands (list) – A list of commands to send.

async start_imaging()

Send a command to the microscope to start the imaging.

async start_listen()

Receive from the microscope socket.

async stop_imaging()

Send a command to the microscope to stop the imaging.

class camacq.plugins.leica.LeicaCommandEvent(data=None)

Bases: CommandEvent

Leica CommandEvent class.

property command

Return the command string.

data
event_type = 'leica_command_event'
class camacq.plugins.leica.LeicaImageEvent(data=None)

Bases: ImageEvent

Leica ImageEvent class.

property channel_id

Return channel id of the image.

Type:

int

data
event_type = 'leica_image_event'
property field_x

Return x coordinate of the well of the image.

Type:

int

property field_y

Return y coordinate of the well of the image.

Type:

int

property job_id

Return job id of the image.

Type:

int

property path

Return absolute path to the image.

Type:

str

property plate_name

Return plate name of the image.

Type:

str

property well_x

Return x coordinate of the well of the image.

Type:

int

property well_y

Return y coordinate of the well of the image.

Type:

int

property z_slice_id

Return z index of the image.

Type:

int

class camacq.plugins.leica.LeicaStartCommandEvent(data=None)

Bases: StartCommandEvent, LeicaCommandEvent

Leica StartCommandEvent class.

property command

Return the command string.

data
event_type = 'leica_start_command_event'
class camacq.plugins.leica.LeicaStopCommandEvent(data=None)

Bases: StopCommandEvent, LeicaCommandEvent

Leica StopCommandEvent class.

property command

Return the command string.

data
event_type = 'leica_stop_command_event'
async camacq.plugins.leica.setup_module(center, config)

Set up Leica api package.

Parameters:
  • center (Center instance) – The Center instance.

  • config (dict) – The config dict.

Submodules

camacq.plugins.leica.command module

Handle commands.

camacq.plugins.leica.command.cam_com(exp, wellu, wellv, fieldx, fieldy, dxcoord, dycoord)

Add a field to the cam list.

Return a list with parts for the cam command.

camacq.plugins.leica.command.camstart_com(afjob=None, afrange=None, afsteps=None)

Start the cam scan with selected AF job and AF settings.

Return a list with parts for the cam command.

camacq.plugins.leica.command.camstop_com()

Stop the cam scan.

Return a list with parts for the cam command.

camacq.plugins.leica.command.del_com()

Delete the cam list.

Return a list with parts for the cam command.

camacq.plugins.leica.command.enable_com(wellu, wellv, fieldx, fieldy, enable)

Enable a field in a well.

Return a list with parts for the cam command.

camacq.plugins.leica.command.gain_com(exp, num, value)

Change the pmt gain in a job.

Return a list with parts for the cam command.

camacq.plugins.leica.command.start()

Start the scan.

Return a list with parts for the cam command.

camacq.plugins.leica.command.stop()

Stop the scan.

Return a list with parts for the cam command.

camacq.plugins.leica.helper module

Helper functions for Leica api.

camacq.plugins.leica.helper.find_image_path(relpath, root)

Parse the relpath from the server to find file path from root.

Convert from windows path to posix path.

Parameters:
  • relpath (str) – A relative path to the image.

  • root (str) – Path to directory where path should start.

Returns:

Return path to image.

Return type:

str

camacq.plugins.leica.helper.get_field(path)

Get path to field from image path.

Parameters:

path (string) – Path to image.

Returns:

Return path to field directory of image.

Return type:

str

camacq.plugins.leica.helper.get_imgs(path, img_type='tif', search='')

Get all images below path.

Parameters:
  • path (string) – Path to directory where to search for images.

  • img_type (string) – A string representing the image file type extension.

  • path – A glob pattern string to use in the search.

Returns:

Return paths of all images found.

Return type:

list

camacq.plugins.leica.helper.get_well(path)

Get path to well from image path.

Parameters:

path (string) – Path to image.

Returns:

Return path to well directory of image.

Return type:

str

camacq.plugins.leica.sample module

Provide sample implementation for leica microscope.

class camacq.plugins.leica.sample.Channel(images, channel_id, **kwargs)

Bases: Well, ImageContainer

A channel with attributes.

Parameters:
  • images (dict) – All the images of the sample.

  • channel_id (int) – ID of the channel.

  • well_x (int) – x coordinate of the well, minimum 0.

  • well_y (int) – y coordinate of the well, minimum 0.

  • plate_name (str) – The name of the plate.

  • values (dict) – Optional dict of values.

channel_id

Return channel_id of the channel.

Type:

int

property change_event

Return an event class to fire on container change.

Type:

Event

property images

Return a dict with all images for the channel.

Type:

dict

property name

Return an identifying name for the container.

Type:

str

property values

Return a dict with the values set for the container.

Type:

dict

class camacq.plugins.leica.sample.ChannelEvent(data=None)

Bases: WellEvent

An event produced by a sample channel change event.

property channel_id

Return the channel id of the event.

Type:

int

property channel_name

Return the channel name of the event.

Type:

str

property container

Return the container instance of the event.

Type:

ImageContainer instance

property container_name

Return the container name of the event.

Type:

str

data
event_type = 'channel_event'
property images

Return the container images of the event.

Type:

dict

property plate_name

Return the name of the plate.

Type:

str

property values

Return the container values of the event.

Type:

dict

property well_img_ok

Return if the well has all images acquired ok.

Type:

bool

property well_x

Return the well x coordinate of the event.

Type:

int

property well_y

Return the well y coordinate of the event.

Type:

int

class camacq.plugins.leica.sample.Field(images, field_x, field_y, **kwargs)

Bases: Well, ImageContainer

A field within a well.

Parameters:
  • images (dict) – All the images of the sample.

  • field_x (int) – Coordinate of field in x.

  • field_y (int) – Coordinate of field in y.

  • well_x (int) – x coordinate of the well, minimum 0.

  • well_y (int) – y coordinate of the well, minimum 0.

  • plate_name (str) – The name of the plate.

  • values (dict) – Optional dict of values.

field_x

Number showing the x coordinate of the field, from 0.

Type:

int

field_y

Number showing the y coordinate of the field, from 0.

Type:

int

property change_event

Return an event class to fire on container change.

Type:

Event

property images

Return a dict with all images for the field.

Type:

dict

property name

Return an identifying name for the container.

Type:

str

property values

Return a dict with the values set for the container.

Type:

dict

class camacq.plugins.leica.sample.FieldEvent(data=None)

Bases: WellEvent

An event produced by a sample field change event.

property container

Return the container instance of the event.

Type:

ImageContainer instance

property container_name

Return the container name of the event.

Type:

str

data
event_type = 'field_event'
property field_img_ok

Return if the field has all images acquired ok.

Type:

bool

property field_x

Return the field x coordinate of the event.

Type:

int

property field_y

Return the field y coordinate of the event.

Type:

int

property images

Return the container images of the event.

Type:

dict

property plate_name

Return the name of the plate.

Type:

str

property values

Return the container values of the event.

Type:

dict

property well_img_ok

Return if the well has all images acquired ok.

Type:

bool

property well_x

Return the well x coordinate of the event.

Type:

int

property well_y

Return the well y coordinate of the event.

Type:

int

class camacq.plugins.leica.sample.LeicaSample(images=None, values=None)

Bases: Sample

Representation of the state of the sample.

The sample can have plates, wells, fields, channels and images.

Parameters:
  • images (dict) – A dict of images of the sample.

  • values (dict) – Optional dict of values.

center = None
property change_event

Return an event class to fire on container change.

Type:

Event

data = None
get_sample(name, **kwargs)

Get an image container of the sample.

Parameters:
  • name (str) – The name of the container type.

  • **kwargs – Arbitrary keyword arguments. These will be used to create the id string of the container.

Returns:

Return the found ImageContainer instance.

Return type:

ImageContainer instance

property image_event_type

Return the image event type to listen to for the sample.

Type:

str

property images

Return a dict with all images for the container.

Type:

dict

property name

Return the name of the sample.

Type:

str

async on_image(center, event)

Handle image event for this sample.

async set_sample(name, values=None, **kwargs)

Set an image container of the sample.

Parameters:
  • name (str) – The name of the container type.

  • values (dict) – The optional values to set on the container.

  • **kwargs – Arbitrary keyword arguments. These will be used to create the id string of the container.

Returns:

Return the ImageContainer instance that was updated.

Return type:

ImageContainer instance

property set_sample_schema

Return the validation schema of the set_sample method.

property values

Return a dict with the values set for the container.

Type:

dict

class camacq.plugins.leica.sample.LeicaSampleEvent(data=None)

Bases: SampleEvent

An event produced by a sample change event.

property container

Return the container instance of the event.

Type:

ImageContainer instance

property container_name

Return the container name of the event.

Type:

str

data
event_type = 'leica_sample_event'
property images

Return the container images of the event.

Type:

dict

property values

Return the container values of the event.

Type:

dict

class camacq.plugins.leica.sample.Plate(images, plate_name, **kwargs)

Bases: ImageContainer

A container for wells.

Parameters:
  • images (dict) – All the images of the sample.

  • plate_name (str) – The name of the plate.

  • values (dict) – Optional dict of values.

plate_name

The name of the plate.

Type:

str

property change_event

Return an event class to fire on container change.

Type:

Event

property images

Return a dict with all images for the plate.

Type:

dict

property name

Return an identifying name for the container.

Type:

str

property values

Return a dict with the values set for the container.

Type:

dict

class camacq.plugins.leica.sample.PlateEvent(data=None)

Bases: LeicaSampleEvent

An event produced by a sample plate change event.

property container

Return the container instance of the event.

Type:

ImageContainer instance

property container_name

Return the container name of the event.

Type:

str

data
event_type = 'plate_event'
property images

Return the container images of the event.

Type:

dict

property plate_name

Return the name of the plate.

Type:

str

property values

Return the container values of the event.

Type:

dict

class camacq.plugins.leica.sample.Well(images, well_x, well_y, **kwargs)

Bases: Plate, ImageContainer

A well within a plate with fields and channels.

Parameters:
  • images (dict) – All the images of the sample.

  • well_x (int) – x coordinate of the well, minimum 0.

  • well_y (int) – y coordinate of the well, minimum 0.

  • plate_name (str) – The name of the plate.

  • values (dict) – Optional dict of values.

well_x

Number showing the x coordinate of the well, from 0.

Type:

int

well_y

Number showing the y coordinate of the well, from 0.

Type:

int

property change_event

Return an event class to fire on container change.

Type:

Event

property images

Return a dict with all images for the well.

Type:

dict

property name

Return an identifying name for the container.

Type:

str

property values

Return a dict with the values set for the container.

Type:

dict

class camacq.plugins.leica.sample.WellEvent(data=None)

Bases: PlateEvent

An event produced by a sample well change event.

property container

Return the container instance of the event.

Type:

ImageContainer instance

property container_name

Return the container name of the event.

Type:

str

data
event_type = 'well_event'
property images

Return the container images of the event.

Type:

dict

property plate_name

Return the name of the plate.

Type:

str

property values

Return the container values of the event.

Type:

dict

property well_img_ok

Return if the well has all images acquired ok.

Type:

bool

property well_x

Return the well x coordinate of the event.

Type:

int

property well_y

Return the well y coordinate of the event.

Type:

int

class camacq.plugins.leica.sample.ZSlice(images, z_slice_id, **kwargs)

Bases: Well, ImageContainer

A channel with attributes.

Parameters:
  • images (dict) – All the images of the sample.

  • z_slice_id (int) – ID of the slice.

  • well_x (int) – x coordinate of the well, minimum 0.

  • well_y (int) – y coordinate of the well, minimum 0.

  • plate_name (str) – The name of the plate.

  • values (dict) – Optional dict of values.

z_slice_id

Return z_slice_id of the channel.

Type:

int

property change_event

Return an event class to fire on container change.

Type:

Event

property images

Return a dict with all images for the channel.

Type:

dict

property name

Return an identifying name for the container.

Type:

str

property values

Return a dict with the values set for the container.

Type:

dict

class camacq.plugins.leica.sample.ZSliceEvent(data=None)

Bases: WellEvent

An event produced by a sample z slice change event.

property container

Return the container instance of the event.

Type:

ImageContainer instance

property container_name

Return the container name of the event.

Type:

str

data
event_type = 'z_slice_event'
property images

Return the container images of the event.

Type:

dict

property plate_name

Return the name of the plate.

Type:

str

property values

Return the container values of the event.

Type:

dict

property well_img_ok

Return if the well has all images acquired ok.

Type:

bool

property well_x

Return the well x coordinate of the event.

Type:

int

property well_y

Return the well y coordinate of the event.

Type:

int

property z_slice_id

Return the z_slice id of the event.

Type:

int

camacq.plugins.leica.sample.next_well_xy(sample, plate_name, x_wells=None, y_wells=None)

Return the next not done well for the given plate x, y format.

async camacq.plugins.leica.sample.setup_module(center, config)

Set up sample module.

Parameters:
  • center (Center instance) – The Center instance.

  • config (dict) – The config dict.