OPS>SOFTWARE>DOCUMENTATION>PYTHON CONFIGURATION

Python Configuration

Controlling LC Device via Micro-Manager from your Python environment

Reference: https://micro-manager.org/wiki/Using_the_Micro-Manager_python_library

The following was tested using MM of version 1.4.5 with Python 2.7. Micro-Manager has a python wrapper (MMCorePy) that allows you to control microscope hardware from python interactive session or script and support Windows, Mac and Linux. Please refer to the above guide for setting up the environment.


Start by creating a configuration file. For this tutorial we use the GenericLC (demo) device adapter which is included in the OpenPolScope software installer. Any Python script developed using the GenericLC device adapter is applicable to actual device adapters. Please note some LC hardware may only work under centain OS supported by their device driver.

Matlab_Config

Matlab_Config

Save this configuration file to 'C:\Micro-Manager1.4\MM_GenericLC_demo.cfg' and exit Micro-Manager



The following Python script provides an example of controlling (setting & reading) properties available via the device adapter interface.

# Python 2.7 script for Micro-Manager & LC device control
import MMCorePy import numpy as np mmc = MMCorePy.CMMCore() # Instance micromanager core print mmc.getVersionInfo() print mmc.getAPIVersionInfo() mmc.loadSystemConfiguration ('C:\Micro-Manager-1.4\MM_GenericLC_demo.cfg'); # Define Device Label that was used in the Micro-Manager Hardware Config. Wizard # Define Properties to be used - refer image below for examples (greyed out properties are read only) STR_KEY_DeviceLabel = 'GenericLC'; STR_KEY_VLC_PropertyRetardanceLC_A = 'Retardance LC-A [in waves]'; STR_KEY_VLC_PropertyRetardanceLC_B = 'Retardance LC-B [in waves]'; STR_KEY_VLC_PropertyRetardanceLC_A_nm = 'Retardance LC-A [in nm.]'; STR_KEY_VLC_PropertyRetardanceLC_B_nm = 'Retardance LC-B [in nm.]'; STR_KEY_VLC_PropertyStringSendTo = 'String send to -'; STR_KEY_VLC_PropertyStringFrom = 'String from -'; V1 = mmc.getProperty(STR_KEY_DeviceLabel, STR_KEY_VLC_PropertyRetardanceLC_A_nm); V2 = mmc.getProperty(STR_KEY_DeviceLabel, STR_KEY_VLC_PropertyRetardanceLC_B_nm); print 'Values LC-A (nm) : ' + V1; print 'Values LC-B (nm) : ' + V2; print ('Setting LC values using Property'); mmc.setProperty(STR_KEY_DeviceLabel, STR_KEY_VLC_PropertyRetardanceLC_A,'0.33'); mmc.setProperty(STR_KEY_DeviceLabel, STR_KEY_VLC_PropertyRetardanceLC_B,'0.55'); print ('Retrieved LC values using Property'); V1 = mmc.getProperty(STR_KEY_DeviceLabel, STR_KEY_VLC_PropertyRetardanceLC_A_nm); V2 = mmc.getProperty(STR_KEY_DeviceLabel, STR_KEY_VLC_PropertyRetardanceLC_B_nm); print 'Values LC-A (nm) : ' + V1; print 'Values LC-B (nm) : ' + V2; print ('Setting LC values using command'); mmc.setProperty(STR_KEY_DeviceLabel, STR_KEY_VLC_PropertyStringSendTo, 'L 0.21 0.42'); # command 'L 0.21 0.42' sets retardance value of LC A & B to 0.21 & 0.42 respectively # (refer device manual for command operations) print ('Retrieved command query response'); ret = mmc.getProperty(STR_KEY_DeviceLabel, STR_KEY_VLC_PropertyStringFrom); print 'Command response : ' + ret; print ('Retrieved LC values using Property'); V1 = mmc.getProperty(STR_KEY_DeviceLabel, STR_KEY_VLC_PropertyRetardanceLC_A); V2 = mmc.getProperty(STR_KEY_DeviceLabel, STR_KEY_VLC_PropertyRetardanceLC_B); print 'Values LC-A (waves) : ' + V1; print 'Values LC-B (waves) : ' + V2;

The other properties that are available can be viewed by opening Micro-Manager's Property Browser interface. Please note that while all the core properties are available for different LC device adapters, some are specifc (eg. Temp., TNE) to each device manufacturer.

Matlab_Config


© OpenPolScope | All Rights Reserved | Contact
Last Page Update on April 13 2015 13:09