Python API for Leica LAS AF MatrixScreener
Project description
This is an python module for interfacing with Leica LAS AF MatrixScreener. It can read experiments and communicate with microscope over network.
The module can be used to stitch wells from an experiment exported with the LAS AF Data Exporter, as well as programmatically selecting slides/wells/fields/images given by position attributes (U, V, X, Y, z-stack), channel, etc.
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.
Features
Access experiment as python object
ImageJ stitching
Communicate with microscope over CAM TCP/IP socket
Install
pip install matrixscreener
Examples
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) # default is for fiji on mac os x
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 images
from matrixscreener import experiment
scan = experiment.Experiment('path/to/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_as_int(path, 'X') > 1
x_below = experiment.attribute_as_int(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_as_int
# get all channels
channels = [attribute_as_int(image, 'C') for image in scan.images]
min_ch, max_ch = min(channels), max(channels)
speak with microscope
from matrixscreener.cam import CAM
cam = CAM() # initiate
cam.connect() # default localhost:8895
# command as tuples in list with keys and values
command = [('cmd', 'enableall'),
('value', 'true')]
response = cam.send(command)
# command as bytes string
command = b"/cmd:enableall /value:true"
bytes_sent = cam.socket.send(command)
response = cam.socket.recv(cam.buffer_size)
Dependencies
ImageJ with Grid stitching plugin (fiji is recommended)
Develop
git clone https://github.com/arve0/matrixscreener.git cd matrixscreener # hack ./setup.py install
Testing
pip install tox tox
API Reference
Use pydoc matrixscreener, pydoc matrixscreener.cam, pydoc matrixscreener.experiment, pydoc matrixscreener.imagej or read it online.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file matrixscreener-0.3.0.tar.gz
.
File metadata
- Download URL: matrixscreener-0.3.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50cac735c4a2900f483b93094aa9ba390f4cbed083113949bbeb827a933a71f5 |
|
MD5 | e55c89a05379c62d9d11d2fd53533fef |
|
BLAKE2b-256 | cefd7997fd11032c3c781a338c8e8953f0bd1b14db24f0d09fd72cdf5f106dea |