Title Text
from bokeh.plotting import figure, curdoc
from bokeh.driving import linear
from bokeh.plotting import figure, ColumnDataSource
from bokeh.layouts import gridplot
import random
import pandas as pd
import sys
def getdata(filename, replacenan=0):
# read the actual data and store them into pandas data frame
df = pd.read_csv(filename, sep='\t', header=0)
# do some stats and normalization on the data
df['area_t_norm'] = df['area_t'] / df['area_t'].max()
df['area_p_norm'] = df['area_p'] / df['area_p'].max() * 100
# read first value of area_p_norm to be used a reference
area_p_ref = df['area_p_norm'][0]
# calculate the difference relative to the 1st data point last data point
df['area_p_delta'] = df['area_p_norm'] - area_p_ref
# calculate the difference relative to the previous data point
df['area_p_delta_diff'] = df['area_p_delta'].diff()
# fill NaN for plotting with bokeh
df = df.fillna(replacenan)
return df
...
Title Text
# OAD-ExperimentRegionTest
# description: Adding experiment regions to acquisition block
# clear output console
Zen.Application.MacroEditor.ClearMessages()
print 'Start Test Script OAD-ExperimentRegionTest'
image = Zen.Application.LoadImage(r'c:\Testimages_Folder\3x3_SNAP.czi')
Zen.Application.Documents.Add(image)
# ste the scaling based pon the image
ZenExperimentExtensions.SetNewScalingInfo(image)
# define and load experiment
exp = ZenExperiment()
exp.Load('OAD_Automatic_Regions.czexp', ZenSettingDirectory.User)
# clear all existing experiment regions of acquisition block 0
ZenExperimentExtensions.ClearExperimentRegionsAndPositions(exp, 0)
# add a rectangle experiment region to acquisition block 0
ZenExperimentExtensions.AddRectangleExperimentRegion(exp, 0, 5500.0, 4000.0, 1500.0, 1000.0,Colors.Red, True, False, False)
# add a circle experiment region to acquisition block 0
ZenExperimentExtensions.AddEllipseExperimentRegion(exp, 0, 7340, 2550, 500, 500, Colors.BlueViolet, True, False, True)
# add a ellipse experiment region to acquisition block 0
ZenExperimentExtensions.AddEllipseExperimentRegion(exp, 0, 1597, 5767, 300, 150, Colors.Goldenrod, False, False, True)
# add a marker (point) experiment region to acquisition block 0
ZenExperimentExtensions.AddExperimentMarkerPosition(exp, 0, 1244, 2829, Colors.Coral, True)
print '\nTest script finished'
Title Text
##############################
### SetAutofocusParameters ###
##############################
# Method 1. Call SetAutofocusParameters and directly modify whatever you want to modify. ##
# Does not work via COM. ##
# By default, all acquisition blocks are modified.
exp.SetAutofocusParameters(sampling = ZenSoftwareAutofocusSampling.Fine)
exp.SetAutofocusParameters(searchStrategy = "Smart", fixedRangeLowerLimit = -100, fixedRangeUpperLimit = 100)
# Pass the 'block' argument to modify only one block.
# Block indices start at zero (0).
exp.SetAutofocusParameters(block = 0, sampling = ZenSoftwareAutofocusSampling.Coarse)
# You can also use static method syntax to call SetAutofocusParameters.
ZenSoftwareAutofocusExperimentExtensions.SetAutofocusParameters(exp,
sampling = ZenSoftwareAutofocusSampling.Fine)
ZenSoftwareAutofocusExperimentExtensions.SetAutofocusParameters(exp,
searchStrategy = "Smart",
fixedRangeLowerLimit = -100,
fixedRangeUpperLimit = 100)
ZenSoftwareAutofocusExperimentExtensions.SetAutofocusParameters(exp,
block = 0,
sampling = ZenSoftwareAutofocusSampling.Coarse)
Title Text
# Method 2. Create a new ZenSoftwareAutofocusSetting
# and set whatever you want to set. Then call SetAutofocusParameters. Works in COM. ##
s = ZenSoftwareAutofocusSetting()
s.Sampling = ZenSoftwareAutofocusSampling.Fine
s.SearchStrategy = "Smart"
s.SetSearchRangeFixed(-100, 100)
# This can be persisted as XML.
print(s.XML)
s.SaveToXmlFile("bla.xml")
s = ZenSoftwareAutofocusSetting()
s.LoadFromXmlFile("bla.xml")
print(s.XML)
# SetAutofocusParameters:
exp.SetAutofocusParameters(s)
# With explicit block
exp.SetAutofocusParameters(s, block = 0)
# Static method syntax.
ZenSoftwareAutofocusExperimentExtensions.SetAutofocusParameters(exp, s)
ZenSoftwareAutofocusExperimentExtensions.SetAutofocusParameters(exp, s, block = 0)
# Method 3. Get the ZenSoftwareAutofocusSetting from the experiment. ##
# Works in COM. ##
# By default, get the parameters from the current experiment block.
s = exp.GetAutofocusParameters()
# Or specify block explicitly.
s = exp.GetAutofocusParameters(0)
s.Sampling = ZenSoftwareAutofocusSampling.Medium
print(s.XML)
Title Text
def main():
app = QtGui.QApplication(sys.argv)
window = MyGUI()
window.on_start()
window.exec_()
if __name__ == "__main__":
# setup commandline parameters
parser = argparse.ArgumentParser(description='Read Filename and Parameters.')
parser.add_argument('-f', action="store", dest='filename')
parser.add_argument('-p', action="store", dest='plotoption')
parser.add_argument('-fq', action="store", dest='frequency')
# get the arguments
args = parser.parse_args()
print('Datalog Filename: ', args.filename)
savename = args.filename[:-4] + '.png'
print('Savename: ', savename)
frequency = np.float(args.frequency)
print('Update Frequency [s]: ', frequency)
# this actually starts the application
main()
Title Text
Title Text
# Method 3. Get the ZenSoftwareAutofocusSetting from the experiment. ##
# Works in COM. ##
# By default, get the parameters from the current experiment block.
s = exp.GetAutofocusParameters()
# Or specify block explicitly.
s = exp.GetAutofocusParameters(0)
s.Sampling = ZenSoftwareAutofocusSampling.Medium
print(s.XML)
exp.SetAutofocusParameters(s)
Title Text
...
############################ MAIN SCRIPT ##############################
filename = sys.argv[1]
print('Filename: ', filename)
p1 = figure(plot_width=800, plot_height=400, title='Wound Healing Assay - Scratch Area [%]', )
p2 = figure(plot_width=800, plot_height=400, title='Wound Healing Assay - Scratch Relative Delta [%]')
r1 = p1.line([], [], color="firebrick", line_width=10)
r2 = p2.line([], [], color="green", line_width=10)
ds1 = r1.data_source
ds2 = r2.data_source
grid = gridplot([[p1], [p2]])
@linear()
def update(step):
df_all = getdata(filename)
step = df_all['frame'].iloc[-1]
p1_value = df_all['area_p_delta'].iloc[-1]
p2_value = df_all['area_p_delta_diff'].iloc[-1]
ds1.data['x'].append(step)
ds1.data['y'].append(p1_value)
ds2.data['x'].append(step)
ds2.data['y'].append(p2_value)
ds1.trigger('data', ds1.data, ds1.data)
ds2.trigger('data', ds2.data, ds2.data)
#curdoc().add_root(p)
curdoc().add_root(grid)
# Add a periodic callback to be run every 500 milliseconds
curdoc().add_periodic_callback(update, 500)
Title Text
# define and load experiment
expname = r'MyTileExperiment.czexp'
exp = ZenExperiment()
exp.Load(expname, ZenSettingDirectory.User)
# add ellipse as TileRegion
ZenExperimentExtensions.AddEllipseTileRegion(exp, 0, centerX, centerY, width, height, zvalue)
# add polygon TileRegion using points from Image Analysis regions
ZenExperimentExtensions.AddPolygonTileRegion(exp, 0, points, zvalue)
# add rectangulat TileRegion
ZenExperimentExtensions.AddRectangleTileRegion(exp, 0, centerX, cneterY, width, height, zvalue)
# add single position
ZenExperimentExtensions.AddSinglePosition(exp, 0, x, y, z)
# clear all TileRegions and Positions
ZenExperimentExtensions.ClearTileRegionsAndPositions(exp, 0)
# get information for single position
singlepositioninfo = ZenExperimentExtensions.GetSinglePositionInfos(exp, 0)
# get TileRegions information
tileregioninfo 0 ZenExperimentExtensions.GetTileRegionInfos(exp, 0)
# modify TileRegion size
ZenExperimentExtensions.ModifyTileRegionsSize(exp, 0 newiwdth, newheight)
# modify TileRegion Z-Position
ZenExperimentExtensions.ModifyTileRegionsZ(exp, 0, newZ)
# modify TileRegion by offset in xyz
ZenExperimentExtensions.ModifyTileRegionsWithXYZOffset(exp, 0, offsetX, offsetY, offsetZ)
Title Text
"""
Author: Sebastian Rhode
Date: 2016_09_05
File: CD7_Configuration.czmac
Version: 0.1
"""
# clear messages
Zen.Application.MacroEditor.ClearMessages()
print('CD7 configuration script test\n')
config = ZenLiveScan.GetConfiguration()
# print current configuration
print(config.ToString())
# set the desired values
config.SampleCarrierTypeTemplate = 'Multiwell 6.czhst'
config.SampleCarrierDetection = True
config.MeasureBottomThickness = True
config.DetermineBottonMaterial = True
config.CreateCarrierOverview = True
config.ReadBarcodes = True
config.UseLeftBarcode = False
config.UseRightBarcode = True
config.AutomaticSampleCarrierCalibration = True
# update the current configuration
ZenLiveScan.SetConfiguration(config)
# get the updated configuration and print it
config = ZenLiveScan.GetConfiguration()
print(config.ToString())
print('CD7 configuration test script finished')
Title Text
"""
New Actions for Experiment Feedback to facilitate XYZ-Tracking !!!
Just moving the stage in XYZ is not sufficient, when running multiposition experiments.
The next time point would simply overwrite the new XYZ positions
with the values from the list inside the experiment (Settings Rule !!!).
Therefore the TileRegions, Position lists or Z-stacks must be updated!
"""
# move specific TileRegion in X and Y
ZenService.Actions.MoveTileRegion(int regionIndex, double x, double y)
# move specific TileRegion in X, Y and Z
ZenService.Actions.MoveTileRegion(int regionIndex, double x, double y, double z)
# move specific TileRegion by offset in X, Y and Z
ZenService.Actions.MoveTileRegionByOffset(int regionIndex, double offsetX, double offsetY, double offsetZ)
# move center of Z-stack
ZenService.Actions.UpdateZStackCenterPosition(double centerPosition)
# move center of T-stack by offset
ZenService.Actions.UpdateZStackCenterPositionByOffset(double centerPositionOffset)
deck
By Sebastian Rhode
deck
- 1,083