跳转到主要内容

Leica LAS AF MatrixScreener的Python API

项目描述

已弃用

此软件已拆分为更小的模块

matrixscreener

这是一个用于与Leica LAS AF/X Matrix Screener接口的Python模块。它可以读取实验并通过网络与显微镜通信。

该模块可用于

  • 从使用LAS AF Data Exporter导出的实验中拼接孔

  • 批量无损压缩图像

  • 根据属性(如

    • 幻灯片(S)

    • 孔位置(U,V)

    • 字段位置(X,Y)

    • z堆栈位置(Z)

    • 通道(C)

  • 从OME-XML读取实验数据

该模块是在Mac OS X上开发的,但应也能在Linux和Windows上工作。如果您发现任何错误,请在github上提交问题。也欢迎Pull request。

功能

  • 将实验作为Python对象访问

  • 压缩到PNG文件,不丢失精度、元数据或颜色图

  • ImageJ拼接(Fiji通过fijibin安装)

  • 通过CAM TCP/IP套接字与显微镜通信

安装

pip install matrixscreener

示例

拼接实验

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/')

拼接特定孔

from matrixscreener import experiment

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

对所有图像执行操作

from matrixscreener import experiment

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

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

对特定孔/区域执行操作

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..

减去数据

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)

与显微镜通信

from matrixscreener.cam import CAM

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

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

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

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

批量无损压缩实验

import matrixscreener as ms

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

另请参阅 此笔记本

开发

git clone https://github.com/arve0/matrixscreener.git
cd matrixscreener
# hack
./setup.py install

测试

pip install tox
tox

特定测试,这里指压缩测试

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

具有额外输出的特定测试,出错时跳入pdb

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

API参考

所有命令应在numpy格式的docstrings中记录。

API参考可在网上找到,可以用pydoc或任何具有docstrings自动补全功能的编辑器/repl进行阅读。

在示例中

pydoc matrixscreener
pydoc matrixscreener.cam
pydoc matrixscreener.experiment
pydoc matrixscreener.imagej

发布程序

  • 如果缺失,请创建.pypirc

    [distutils]
    index-servers=
            pypi
            pypitest
    
    [pypitest]
    repository = https://testpypi.python.org/pypi
    username = username
    password = password
    
    [pypi]
    repository = https://pypi.python.org/pypi
    username = username
    password = password
  • 更新changelog.md

  • 更新__init__.pysetup.pydoc/conf.py中的版本

  • Git提交并标记版本

  • ./generate-rst.sh(需要pandoc)

  • 暂存发布:python setup.py sdist bdist_wheel upload -r pypitest

  • 发布:python setup.py sdist bdist_wheel upload

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

matrixscreener-0.6.1.tar.gz (11.0 kB 查看哈希值)

上传时间:

构建分布

matrixscreener-0.6.1-py3-none-any.whl (14.8 kB 查看哈希值)

上传时间: Python 3

支持者:

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面