コード例 #1
0
ファイル: mmcamera.py プロジェクト: travis-open/acq4
    def __init__(self, manager, config, name):
        try:
            import MMCorePy
        except ImportError:
            if sys.platform != 'win32':
                raise
            # MM does not install itself to standard path. User should take care of this,
            # but we can make a guess..
            path = config.get('path', 'C:\\Program Files\\Micro-Manager-1.4')
            sys.path.append(path)
            os.environ['PATH'] = os.environ['PATH'] + ';' + path
            try:
                import MMCorePy
            finally:
                sys.path.pop()

        self.camName = str(name)  # we will use this name as the handle to the MM camera
        self.mmc = MMCorePy.CMMCore()

        self._triggerProp = None  # the name of the property for setting trigger mode
        self._triggerModes = ({}, {})  # forward and reverse mappings for the names of trigger modes
        self._binningMode = None  # 'x' or 'xy' for binning strings like '1' and '1x1', respectively
        self.camLock = Mutex(Mutex.Recursive)  ## Lock to protect access to camera
        self._config = config
        Camera.__init__(self, manager, config, name)  ## superclass will call setupCamera when it is ready.
        self.acqBuffer = None
        self.frameId = 0
        self.lastFrameTime = None
コード例 #2
0
 def __init__(self, *args, **kargs):
     self.camLock = Mutex(Mutex.Recursive)  ## Lock to protect access to camera
     self.ringSize = 50
     Camera.__init__(self, *args, **kargs)  ## superclass will call setupCamera when it is ready.
     self.acqBuffer = None
     self.frameId = 0
     self.lastIndex = None
     self.lastFrameTime = None
     self.stopOk = False
コード例 #3
0
ファイル: PVCam.py プロジェクト: ablot/acq4
 def __init__(self, *args, **kargs):
     self.camLock = Mutex(Mutex.Recursive)  ## Lock to protect access to camera
     self.ringSize = 100
     Camera.__init__(self, *args, **kargs)  ## superclass will call setupCamera when it is ready.
     self.acqBuffer = None
     self.frameId = 0
     self.lastIndex = None
     self.lastFrameTime = None
     self.stopOk = False
コード例 #4
0
    def __init__(self, manager, config, name):
        self.camName = str(
            name)  # we will use this name as the handle to the MM camera
        mmpath = config.get('path')
        self.mmc = micromanager.getMMCorePy(mmpath)

        self._triggerProp = None  # the name of the property for setting trigger mode
        self._triggerModes = (
            {}, {}
        )  # forward and reverse mappings for the names of trigger modes
        self._binningMode = None  # 'x' or 'xy' for binning strings like '1' and '1x1', respectively
        self.camLock = Mutex(
            Mutex.Recursive)  ## Lock to protect access to camera
        self._config = config
        Camera.__init__(
            self, manager, config,
            name)  ## superclass will call setupCamera when it is ready.
        self.acqBuffer = None
        self.frameId = 0
        self.lastFrameTime = None
コード例 #5
0
 def start(self, block=True):
     #print "PVCam: start"
     if not self.isRunning():
         self.lastIndex = None
         #print "  not running already; start camera"
         Camera.start(self, block)  ## Start the acquisition thread
         self.startTime = ptime.time()
         
     ## pvcams can take a long time 
     if block:
         tm = self.getParam('triggerMode')
         if tm != 'Normal':
             #print "  waiting for trigger to arm"
             waitTime = 0.3  ## trigger needs about 300ms to prepare (?)
         else:
             waitTime = 0
         
         sleepTime = (self.startTime + waitTime) - ptime.time()
         if sleepTime > 0:
             #print "  sleep for", sleepTime
             time.sleep(sleepTime)
コード例 #6
0
ファイル: PVCam.py プロジェクト: ablot/acq4
 def start(self, block=True):
     #print "PVCam: start"
     if not self.isRunning():
         self.lastIndex = None
         #print "  not running already; start camera"
         Camera.start(self, block)  ## Start the acquisition thread
         self.startTime = ptime.time()
         
     ## pvcams can take a long time 
     if block:
         tm = self.getParam('triggerMode')
         if tm != 'Normal':
             #print "  waiting for trigger to arm"
             waitTime = 0.3  ## trigger needs about 300ms to prepare (?)
         else:
             waitTime = 0
         
         sleepTime = (self.startTime + waitTime) - ptime.time()
         if sleepTime > 0:
             #print "  sleep for", sleepTime
             time.sleep(sleepTime)
コード例 #7
0
    def __init__(self, manager, config, name):
        self.camLock = Mutex(
            Mutex.Recursive)  ## Lock to protect access to camera
        self.ringSize = 100
        self.frameId = 0
        self.noise = np.random.normal(
            size=10000000, loc=100,
            scale=10)  ## pre-generate noise for use in images

        if 'images' in config:
            self.bgData = {}
            self.bgInfo = {}
            for obj, filename in config['images'].items():
                file = manager.fileHandle(filename)
                ma = file.read()
                self.bgData[obj] = ma.asarray()
                self.bgInfo[obj] = file.info().deepcopy()
                self.bgInfo[obj]['depths'] = ma.xvals(0)
        else:
            self.bgData = mandelbrot(w=4000, maxIter=60).astype(np.float32)
            self.bgInfo = None

        self.background = None

        self.params = OrderedDict([
            ('triggerMode', 'Normal'),
            ('exposure', 0.001),
            #('binning',         (1,1)),
            #('region',          (0, 0, 512, 512)),
            ('binningX', 1),
            ('binningY', 1),
            ('regionX', 0),
            ('regionY', 0),
            ('regionW', 512),
            ('regionH', 512),
            ('gain', 1.0),
            ('sensorSize', (512, 512)),
            ('bitDepth', 16),
        ])

        self.paramRanges = OrderedDict([
            ('triggerMode', (['Normal', 'TriggerStart'], True, True, [])),
            ('exposure', ((0.001, 10.), True, True, [])),
            #('binning',         ([range(1,10), range(1,10)], True, True, [])),
            #('region',          ([(0, 511), (0, 511), (1, 512), (1, 512)], True, True, [])),
            ('binningX', (range(1, 10), True, True, [])),
            ('binningY', (range(1, 10), True, True, [])),
            ('regionX', ((0, 511), True, True, ['regionW'])),
            ('regionY', ((0, 511), True, True, ['regionH'])),
            ('regionW', ((1, 512), True, True, ['regionX'])),
            ('regionH', ((1, 512), True, True, ['regionY'])),
            ('gain', ((0.1, 10.0), True, True, [])),
            ('sensorSize', (None, False, True, [])),
            ('bitDepth', (None, False, True, [])),
        ])

        self.groupParams = {
            'binning': ('binningX', 'binningY'),
            'region': ('regionX', 'regionY', 'regionW', 'regionH')
        }

        sig = np.random.normal(size=(512, 512), loc=1.0, scale=0.3)
        sig = scipy.ndimage.gaussian_filter(sig, (3, 3))
        sig[20:40, 20:40] += 1
        sig[sig < 0] = 0
        self.signal = sig

        Camera.__init__(
            self, manager, config,
            name)  ## superclass will call setupCamera when it is ready.
        self.acqBuffer = None
        self.frameId = 0
        self.lastIndex = None
        self.lastFrameTime = None
        self.stopOk = False

        self.sigGlobalTransformChanged.connect(self.globalTransformChanged)

        ## generate list of mock cells
        cells = np.zeros(20,
                         dtype=[('x', float), ('y', float), ('size', float),
                                ('value', float), ('rate', float),
                                ('intensity', float), ('decayTau', float)])
        cells['x'] = np.random.normal(size=cells.shape,
                                      scale=100e-6,
                                      loc=-1.5e-3)
        cells['y'] = np.random.normal(size=cells.shape,
                                      scale=100e-6,
                                      loc=4.4e-3)
        cells['size'] = np.random.normal(size=cells.shape,
                                         scale=2e-6,
                                         loc=10e-6)
        cells['rate'] = np.random.lognormal(size=cells.shape, mean=0,
                                            sigma=1) * 1.0
        cells['intensity'] = np.random.uniform(size=cells.shape,
                                               low=1000,
                                               high=10000)
        cells['decayTau'] = np.random.uniform(size=cells.shape,
                                              low=15e-3,
                                              high=500e-3)
        self.cells = cells
コード例 #8
0
ファイル: QCam.py プロジェクト: ablot/acq4
 def quit(self):
     #print "quit() called from QCamDevice."
     Camera.quit(self)
     self.qcd.quit()
コード例 #9
0
ファイル: QCam.py プロジェクト: ablot/acq4
 def __init__(self, *args, **kargs):
     self.camLock = Mutex(Mutex.Recursive)  ## Lock to protect access to camera
     Camera.__init__(self, *args, **kargs)  ## superclass will call setupCamera when it is ready.
コード例 #10
0
 def quit(self):
     Camera.quit(self)
     time.sleep(2)
     self.cam.close()
コード例 #11
0
 def quit(self):
     #print "quit() called from QCamDevice."
     Camera.quit(self)
     self.qcd.quit()
コード例 #12
0
 def __init__(self, *args, **kargs):
     self.camLock = Mutex(
         Mutex.Recursive)  ## Lock to protect access to camera
     Camera.__init__(
         self, *args,
         **kargs)  ## superclass will call setupCamera when it is ready.
コード例 #13
0
ファイル: MockCamera.py プロジェクト: ablot/acq4
 def __init__(self, *args, **kargs):
     self.camLock = Mutex(Mutex.Recursive)  ## Lock to protect access to camera
     self.ringSize = 100
     self.frameId = 0
     self.noise = np.random.normal(size=10000000, loc=100, scale=50)  ## pre-generate noise for use in images
     self.bgData = mandelbrot(w=1000, maxIter=60).astype(np.float32)
     self.background = None
     
     self.params = OrderedDict([
         ('triggerMode',     'Normal'),
         ('exposure',        0.001),
         #('binning',         (1,1)),
         #('region',          (0, 0, 512, 512)), 
         ('binningX',        1),
         ('binningY',        1),
         ('regionX',         0),
         ('regionY',         0),
         ('regionW',         512),
         ('regionH',         512),
         ('gain',            1.0),
         ('sensorSize',      (512, 512)),
         ('bitDepth',        16),
     ])
         
     self.paramRanges = OrderedDict([
         ('triggerMode',     (['Normal'], True, True, [])),
         ('exposure',        ((0.001, 10.), True, True, [])),
         #('binning',         ([range(1,10), range(1,10)], True, True, [])),
         #('region',          ([(0, 511), (0, 511), (1, 512), (1, 512)], True, True, [])),
         ('binningX',        (range(1,10), True, True, [])),
         ('binningY',        (range(1,10), True, True, [])),
         ('regionX',         ((0, 511), True, True, ['regionW'])),
         ('regionY',         ((0, 511), True, True, ['regionH'])),
         ('regionW',         ((1, 512), True, True, ['regionX'])),
         ('regionH',         ((1, 512), True, True, ['regionY'])),
         ('gain',            ((0.1, 10.0), True, True, [])),
         ('sensorSize',      (None, False, True, [])),
         ('bitDepth',        (None, False, True, [])),
     ])
     
     self.groupParams = {
         'binning':         ('binningX', 'binningY'),
         'region':          ('regionX', 'regionY', 'regionW', 'regionH')
     }
     
     sig = np.random.normal(size=(512, 512), loc=1.0, scale=0.3)
     sig = scipy.ndimage.gaussian_filter(sig, (3, 3))
     sig[20:40, 20:40] += 1
     sig[sig<0] = 0
     self.signal = sig
     
     Camera.__init__(self, *args, **kargs)  ## superclass will call setupCamera when it is ready.
     self.acqBuffer = None
     self.frameId = 0
     self.lastIndex = None
     self.lastFrameTime = None
     self.stopOk = False
     
     self.sigGlobalTransformChanged.connect(self.globalTransformChanged)
     
     ## generate list of mock cells
     cells = np.zeros(20, dtype=[('x', float), ('y', float), ('size', float), ('value', float), ('rate', float), ('intensity', float), ('decayTau', float)])
     cells['x'] = np.random.normal(size=cells.shape, scale=100e-6, loc=100e-6)
     cells['y'] = np.random.normal(size=cells.shape, scale=100e-6)
     cells['size'] = np.random.normal(size=cells.shape, scale=2e-6, loc=10e-6)
     cells['rate'] = np.random.lognormal(size=cells.shape, mean=0, sigma=1) * .3
     cells['intensity'] = np.random.uniform(size=cells.shape, low=1000, high=10000)
     cells['decayTau'] = np.random.uniform(size=cells.shape, low=15e-3, high=500e-3)
     self.cells = cells
コード例 #14
0
ファイル: PVCam.py プロジェクト: ablot/acq4
 def quit(self):
     Camera.quit(self)
     self.pvc.quit()