Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Python API for Leica LAS AF MatrixScreener

Project description


This software has been split up in smaller modules:

  • leicacam: Communicate with Leica microscopes over CAM TCP/IP socket.
  • leicaexperiment: Read Leica LAS Matrix Screener experiments (output from scans).
  • leicascanningtemplate: Read Leica matrix screener scanning templates (define wells etc).
  • leicaautomator: Attempt at fully automating a microscope scan.


This is a python module for interfacing with Leica LAS AF/X Matrix Screener. It can read experiments and communicate with the microscope over network.

The module can be used to:

  • stitch wells from an experiment exported with the LAS AF Data Exporter
  • batch compress images lossless
  • programmatically select slides/wells/fields/images given by attributes like
    • slide (S)
    • well position (U, V)
    • field position (X, Y)
    • z-stack position (Z)
    • channel (C)
  • read experiment data from OME-XML

The module is developed on Mac OS X, but should work on Linux and Windows too. If you find any bugs, please report them as an issue on github. Pull request are also welcome.


  • Access experiment as a python object
  • Compress to PNGs without loosing precision, metadata or colormap
  • ImageJ stitching (Fiji is installed via fijibin)
  • Communicate with microscope over CAM TCP/IP socket


pip install matrixscreener


stitch experiment

import matrixscreener
# create short hand
Experiment = matrixscreener.experiment.Experiment

# path should contain AditionalData and slide--S*
scan = Experiment('path/to/experiment')

print(matrixscreener.imagej._bin) # Fiji installed via package fijibin
matrixscreener.imagej._bin = '/path/to/imagej'

# if path is omitted, experiment path is used for output files
stitched_images = experiment.stitch('/path/to/output/files/')

stitch specific well

from matrixscreener import experiment

# path should contain AditionalData and slide--S*
stitched_images = experiment.stitch('/path/to/well')

do stuff on all images

from matrixscreener import experiment

scan = experiment.Experiment('path/to/experiment--')

for image in scan.images:
    do stuff...

do stuff on specific wells/fields

from matrixscreener import experiment

# select specific parts
selected_wells = [well for well in scan.wells if 'U00' in well]
for well in selected_wells:
    do stuff...

def condition(path):
    x_above = experiment.attribute(path, 'X') > 1
    x_below = experiment.attribute(path, 'X') < 5
    return x_above and x_below

selected_fields = [field for field in scan.fields if condition(field)]
for field in selected_fields:
    do stuff..

subtract data

from matrixscreener.experiment import attribute

# get all channels
channels = [attribute(image, 'C') for image in scan.images]
min_ch, max_ch = min(channels), max(channels)

communicate with microscope

from import CAM

cam = CAM()   # initiate and connect, default localhost:8895

# some commands are created as short hands
# start matrix scan
response = cam.start_scan()

# but you could also create your own command with a list of tuples
command = [('cmd', 'enableall'),
           ('value', 'true')]
response = cam.send(command)

# or even send it as a bytes string (note the b)
command = b'/cmd:enableall /value:true'
response = cam.send(command)

batch lossless compress of experiment

import matrixscreener as ms

e = ms.experiment.Experiment('/path/to/experiment')
pngs = ms.experiment.compress(e.images)

See also this notebook.


git clone
cd matrixscreener
# hack
./ install


pip install tox

specific test, here compression test

pip install pytest numpy
py.test -k compression tests/

specific test with extra output, jump into pdb upon error

DEBUG=matrixscreener py.test -k compression tests/ --pdb -s

API Reference

All commands should be documented in docstrings in numpy format.

API reference is available online, can be read with pydoc or any editor/repl that does autocomplete with docstrings.

In example:

pydoc matrixscreener
pydoc matrixscreener.experiment
pydoc matrixscreener.imagej

Release procedure

  • Create .pypirc if missing.

    repository =
    username = username
    password = password
    repository =
    username = username
    password = password
  • Update

  • Update version in, and doc/

  • Git commit and tag version

  • ./ (pandoc needed)

  • Stage release: python sdist bdist_wheel upload -r pypitest

  • Release: python sdist bdist_wheel upload

Project details

Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
matrixscreener-0.6.1-py3-none-any.whl (14.8 kB) Copy SHA256 hash SHA256 Wheel 3.5 May 25, 2016
matrixscreener-0.6.1.tar.gz (11.0 kB) Copy SHA256 hash SHA256 Source None May 25, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page