In [1]:
from leicaautomator.automator import find_spots
from leicaautomator.utils import save_regions, flatten
from leicaexperiment import Experiment
from leicascanningtemplate import ScanningTemplate
from leicacam import CAM

In [7]:
cam = CAM()
cam.welcome_msg


Out[7]:
b'Welcome client : 6\n'

In [5]:
tmpl_path = r"C:\Users\TCS-User\AppData\Roaming\Leica Microsystems\LAS X\MatrixScreener\ScanningTemplates\ ".strip()
tmpl_path


Out[5]:
'C:\\Users\\TCS-User\\AppData\\Roaming\\Leica Microsystems\\LAS X\\MatrixScreener\\ScanningTemplates\\'

In [42]:
tmpl_name = '{ScanningTemplate}leicaautomator-overview.xml'
tmpl = ScanningTemplate(tmpl_path + tmpl_name)

In [43]:
tmpl.properties.attrib


Out[43]:
{'TotalAssignedJobs': '228', 'TotalCountOfFields': '228', 'Version': 'Version: 1.0.4.661 -- Build 29.09.2014', 'UniqueJobCounter': '1', 'TotalCountOfWells': '1'}

In [44]:
tmpl.properties.CountOfScanFieldsX = 20
tmpl.properties.CountOfScanFieldsY = 12

In [45]:
tmpl.add_well(1, 2, 55225e-6, 29525e-6)

In [46]:
tmpl.remove_well(1,1)

In [58]:
tmpl.well_array.ScanWellData.attrib['WellY'] = '1'
for f in tmpl.fields:
    f.attrib['WellY'] = '1'

In [60]:
tmpl.write()

In [67]:
cam.load_template('{ScanningTemplate}leicaautomator0') # fake load


Out[67]:
[]

In [68]:
cam.load_template(tmpl.filename)


Out[68]:
[]

In [8]:
cam.start_scan()


Out[8]:
[]

In [37]:
from time import sleep
scanfinished = False
while not scanfinished:
    msg = cam.receive()
    for cmd in msg:
        try:
            if cmd['inf'] == 'scanfinished':
                scanfinished = True
                break
        except KeyError:
            continue
    sleep(10e-3)

NOTE

  • hour off by one
  • seconds not allways correct in GUI

In [38]:
exp_path = r"D:\MatrixScreenerImages\3.3.0_9757\ ".strip()
exp_path


Out[38]:
'D:\\MatrixScreenerImages\\3.3.0_9757\\'

In [39]:
whole = 'experiment--2015_03_21_15_02_11'
experiment = Experiment(exp_path + whole)
!dir $experiment.path


 Volume in drive D is DATADRIVE1
 Volume Serial Number is F805-2E08

 Directory of D:\MatrixScreenerImages\3.3.0_9757\experiment--2015_03_21_15_02_11

03/21/2015  04:02 PM    <DIR>          .
03/21/2015  04:02 PM    <DIR>          ..
03/21/2015  04:02 PM    <DIR>          AdditionalData
03/21/2015  04:02 PM    <DIR>          slide--S00
               0 File(s)              0 bytes
               4 Dir(s)  1,700,173,557,760 bytes free

In [40]:
compressed = experiment.compress(delete_tif=True)

In [41]:
len(experiment.images), len(compressed)


Out[41]:
(240, 240)

In [42]:
from PIL import Image
for img in experiment.images:
    i = Image.open(img)
    i = i.rotate(270)
    i.save(img)

In [43]:
stitched = experiment.stitch()[0]
from IPython import display
display.Image(stitched)


Out[43]:

In [44]:
regions = find_spots(experiment)


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
C:\Miniconda3\lib\site-packages\skimage\viewer\plugins\base.py in _update_original_image(self, image)
    183         self.arguments[0] = image
    184         self._on_new_image(image)
--> 185         self.filter_image()
    186 
    187     def _on_new_image(self, image):

c:\users\tcs-user\downloads\leicaautomator\leicaautomator\viewer.py in filter_image(self, **kwargs)
     89         "Filter if plugin enabled and we have image."
     90         if self.enabled and len(self.arguments):
---> 91             super(EnablePlugin, self).filter_image(**kwargs)
     92         elif len(self.arguments):
     93             self.display_filtered_image(self.arguments[0])

C:\Miniconda3\lib\site-packages\skimage\viewer\plugins\base.py in filter_image(self, *widget_arg)
    167         kwargs = dict([(name, self._get_value(a))
    168                        for name, a in self.keyword_arguments.items()])
--> 169         filtered = self.image_filter(*arguments, **kwargs)
    170 
    171         self.display_filtered_image(filtered)

c:\users\tcs-user\downloads\leicaautomator\leicaautomator\viewer.py in image_filter(self, img)
    247             # draw circle around regions of interest
    248             rr, cc = draw.circle(*region.centroid + (r,))
--> 249             self.circles[rr, cc] = region.label
    250             # creat .x and .y property for easy access
    251             region.y, region.x, region.y_end, region.x_end = region.bbox

IndexError: index 4115 is out of bounds for axis 1 with size 4115
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
C:\Miniconda3\lib\site-packages\skimage\viewer\widgets\core.py in _value_changed(self, value)
     41 
     42     def _value_changed(self, value):
---> 43         self.callback(self.name, value)
     44 
     45 

c:\users\tcs-user\downloads\leicaautomator\leicaautomator\viewer.py in update_plugin(self, name, val)
     84     def update_plugin(self, name, val):
     85         super(EnablePlugin, self).update_plugin(name,val)
---> 86         self.filter_image()
     87 
     88     def filter_image(self, **kwargs):

c:\users\tcs-user\downloads\leicaautomator\leicaautomator\viewer.py in filter_image(self, **kwargs)
     89         "Filter if plugin enabled and we have image."
     90         if self.enabled and len(self.arguments):
---> 91             super(EnablePlugin, self).filter_image(**kwargs)
     92         elif len(self.arguments):
     93             self.display_filtered_image(self.arguments[0])

C:\Miniconda3\lib\site-packages\skimage\viewer\plugins\base.py in filter_image(self, *widget_arg)
    167         kwargs = dict([(name, self._get_value(a))
    168                        for name, a in self.keyword_arguments.items()])
--> 169         filtered = self.image_filter(*arguments, **kwargs)
    170 
    171         self.display_filtered_image(filtered)

c:\users\tcs-user\downloads\leicaautomator\leicaautomator\viewer.py in image_filter(self, img)
    247             # draw circle around regions of interest
    248             rr, cc = draw.circle(*region.centroid + (r,))
--> 249             self.circles[rr, cc] = region.label
    250             # creat .x and .y property for easy access
    251             region.y, region.x, region.y_end, region.x_end = region.bbox

IndexError: index 4115 is out of bounds for axis 1 with size 4115
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
C:\Miniconda3\lib\site-packages\skimage\viewer\widgets\core.py in _value_changed(self, value)
     41 
     42     def _value_changed(self, value):
---> 43         self.callback(self.name, value)
     44 
     45 

c:\users\tcs-user\downloads\leicaautomator\leicaautomator\viewer.py in update_plugin(self, name, val)
     84     def update_plugin(self, name, val):
     85         super(EnablePlugin, self).update_plugin(name,val)
---> 86         self.filter_image()
     87 
     88     def filter_image(self, **kwargs):

c:\users\tcs-user\downloads\leicaautomator\leicaautomator\viewer.py in filter_image(self, **kwargs)
     89         "Filter if plugin enabled and we have image."
     90         if self.enabled and len(self.arguments):
---> 91             super(EnablePlugin, self).filter_image(**kwargs)
     92         elif len(self.arguments):
     93             self.display_filtered_image(self.arguments[0])

C:\Miniconda3\lib\site-packages\skimage\viewer\plugins\base.py in filter_image(self, *widget_arg)
    167         kwargs = dict([(name, self._get_value(a))
    168                        for name, a in self.keyword_arguments.items()])
--> 169         filtered = self.image_filter(*arguments, **kwargs)
    170 
    171         self.display_filtered_image(filtered)

c:\users\tcs-user\downloads\leicaautomator\leicaautomator\viewer.py in image_filter(self, img)
    247             # draw circle around regions of interest
    248             rr, cc = draw.circle(*region.centroid + (r,))
--> 249             self.circles[rr, cc] = region.label
    250             # creat .x and .y property for easy access
    251             region.y, region.x, region.y_end, region.x_end = region.bbox

IndexError: index 4115 is out of bounds for axis 1 with size 4115
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
C:\Miniconda3\lib\site-packages\skimage\viewer\widgets\core.py in _value_changed(self, value)
     41 
     42     def _value_changed(self, value):
---> 43         self.callback(self.name, value)
     44 
     45 

c:\users\tcs-user\downloads\leicaautomator\leicaautomator\viewer.py in update_plugin(self, name, val)
     84     def update_plugin(self, name, val):
     85         super(EnablePlugin, self).update_plugin(name,val)
---> 86         self.filter_image()
     87 
     88     def filter_image(self, **kwargs):

c:\users\tcs-user\downloads\leicaautomator\leicaautomator\viewer.py in filter_image(self, **kwargs)
     89         "Filter if plugin enabled and we have image."
     90         if self.enabled and len(self.arguments):
---> 91             super(EnablePlugin, self).filter_image(**kwargs)
     92         elif len(self.arguments):
     93             self.display_filtered_image(self.arguments[0])

C:\Miniconda3\lib\site-packages\skimage\viewer\plugins\base.py in filter_image(self, *widget_arg)
    167         kwargs = dict([(name, self._get_value(a))
    168                        for name, a in self.keyword_arguments.items()])
--> 169         filtered = self.image_filter(*arguments, **kwargs)
    170 
    171         self.display_filtered_image(filtered)

c:\users\tcs-user\downloads\leicaautomator\leicaautomator\viewer.py in image_filter(self, img)
    247             # draw circle around regions of interest
    248             rr, cc = draw.circle(*region.centroid + (r,))
--> 249             self.circles[rr, cc] = region.label
    250             # creat .x and .y property for easy access
    251             region.y, region.x, region.y_end, region.x_end = region.bbox

IndexError: index 4115 is out of bounds for axis 1 with size 4115
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-44-fffc7cd810f3> in <module>()
----> 1 regions = find_spots(experiment)

c:\users\tcs-user\downloads\leicaautomator\leicaautomator\automator.py in find_spots(experiment)
    113 
    114     for region in regions:
--> 115         region.real_x = real_x_start + region.x*x_px_size
    116         region.real_y = real_y_start + region.y*y_px_size
    117 

AttributeError: '_RegionProperties' object has no attribute 'x'