Beispiel #1
0
def camera_init(camera_name):
    """
    Initializing the camera
    :return: mmc: microscope device, can be controlled using micro manager methods (see HAMAMATSU_CAMERA_METHODS.txt)
    """
    mmc = MMCorePy.CMMCore()

    if camera_name == 'Hamamatsu':
        mmc.loadDevice('Camera', 'HamamatsuHam', 'HamamatsuHam_DCAM')
        flip = [True, 2]
        exposure = 60
    elif camera_name == 'Lumenera':
        mmc.loadDevice('Camera', 'Lumenera', 'LuCam')
        flip = [True, 1]
        exposure = 30
    else:
        raise SystemError('Unknown camera.')

    mmc.initializeDevice('Camera')
    mmc.setCameraDevice('Camera')
    mmc.setExposure(exposure)

    # To get the properties you can set on the camera:
    # print mmc.getDevicePropertyNames('Camera')

    return mmc, flip
Beispiel #2
0
    def __init__(self, name='COM1'):
        '''
        Parameters
        ----------
        name : port name
        '''
        Device.__init__(self)
        self.memory = dict()  # A dictionary of positions

        self.zero_position = 0
        self.step_distance = 0

        self.port_name = name
        mmc = MMCorePy.CMMCore()
        self.mmc = mmc
        mmc.loadDevice(name, 'SerialManager', name)
        mmc.setProperty(name, 'AnswerTimeout', 500.0)
        mmc.setProperty(name, 'BaudRate', 19200)
        mmc.setProperty(name, 'DelayBetweenCharsMs', 0.0)
        mmc.setProperty(name, 'Handshaking', 'Off')
        mmc.setProperty(name, 'Parity', 'None')
        mmc.setProperty(name, 'StopBits', 1)
        mmc.setProperty(name, 'Verbose', 1)
        mmc.loadDevice('Scope', 'LeicaDMI', 'Scope')
        mmc.loadDevice('FocusDrive', 'LeicaDMI', 'FocusDrive')
        mmc.setProperty('Scope', 'Port', name)
        mmc.initializeDevice(name)
        mmc.initializeDevice('Scope')
        mmc.initializeDevice('FocusDrive')
        mmc.setFocusDevice('FocusDrive')
Beispiel #3
0
def getMMCorePy(path=None):
    """Return a singleton MMCorePy instance that is shared by all devices for accessing micromanager.
    """
    global _mmc
    if _mmc is None:
        try:
            global MMCorePy
            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..
            if path is None:
                path = microManagerPath
            sys.path.append(path)
            os.environ['PATH'] = os.environ['PATH'] + ';' + path
            try:
                import MMCorePy
            finally:
                sys.path.pop()

        _mmc = MMCorePy.CMMCore()

    return _mmc
Beispiel #4
0
 def __init__(self, name='COM1'):
     '''
     Parameters
     ----------
     name : port name
     '''
     Microscope.__init__(self, None, None)
     self.port_name = name
     mmc = MMCorePy.CMMCore()
     self.mmc = mmc
     mmc.loadDevice(name, 'SerialManager', name)
     mmc.setProperty(name, 'AnswerTimeout', 500.0)
     mmc.setProperty(name, 'BaudRate', 19200)
     mmc.setProperty(name, 'DelayBetweenCharsMs', 0.0)
     mmc.setProperty(name, 'Handshaking', 'Off')
     mmc.setProperty(name, 'Parity', 'None')
     mmc.setProperty(name, 'StopBits', 1)
     mmc.setProperty(name, 'Verbose', 1)
     mmc.loadDevice('Scope', 'LeicaDMI', 'Scope')
     mmc.loadDevice('FocusDrive', 'LeicaDMI', 'FocusDrive')
     mmc.setProperty('Scope', 'Port', name)
     mmc.initializeDevice(name)
     mmc.initializeDevice('Scope')
     mmc.initializeDevice('FocusDrive')
     mmc.setFocusDevice('FocusDrive')
Beispiel #5
0
    def __init__(self, DEVICE, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.mmc = MMCorePy.CMMCore()
        self.name = DEVICE[0]
        self.mmc.loadDevice(*DEVICE)
        self.mmc.initializeDevice(self.name)
        self.mmc.setCameraDevice(self.name)
        self.mmc.initializeCircularBuffer()

        self.mmc.setProperty(self.name, 'EXPOSURE FULL RANGE', 'ENABLE')
        #this should enable exposure values between

        self.initial_picture = cv2.imread('neuron.png', 0)
        self.image = self.initial_picture

        self.image_roi = self.initial_picture
        self.exp_time = 50
        self.height = self.mmc.getImageHeight()
        self.width = self.mmc.getImageWidth()

        self.frames = 0

        self.tot_ims = 10
        self.interval = 1  #Does not matter for orca flash 4!

        self.mode = "Continuous"

        self.done = False
Beispiel #6
0
    def CAMsetup(self):
        try:
            self.cap = MMCorePy.CMMCore()
            self.cap.loadDevice(self.cam, self.brand, self.val)
            self.cap.initializeAllDevices()
            self.cap.setCameraDevice(self.cam)
            if self.bins != "none":
                self.cap.setProperty(self.cam, "Binning", self.bins)
            self.cap.startContinuousSequenceAcquisition(1)
            self.timer = QTimer()
            self.timer.timeout.connect(self.streamtranslate)
            self.timer.start(30)
            self.startcap = 0
            self.endcap = 0
            self.calib = 0
            self.camerafound = True
            self.streamtranslate()  #stream video

        except:
            self.error_msg.setText(
                "Camera not detected yet, close window and try again")
            self.error_msg.exec_()
            self.camerafound = False
            self.image_analysis_window.setText(
                "CAMERA ERROR. Verify camera is detected in Device Manager, correct camera settings are applied, and restart program. \n Python error = \n"
                + str(sys.exc_info()[1]))
    def __init__(self, brand, name, exposure):
        super(uManagerCamera, self).__init__()

        self.lock = threading.RLock()
        self.cam = MMCorePy.CMMCore()
        self.cam.loadDevice('Camera', brand, name)
        self.cam.initializeDevice('Camera')
        self.cam.setCameraDevice('Camera')
        if self.cam.hasProperty(
                'Camera', 'Exposure') and not self.cam.isPropertyReadOnly(
                    'Camera', 'Exposure'):
            self.min_exposure = self.cam.getPropertyLowerLimit(
                'Camera', 'Exposure')
            self.max_exposure = self.cam.getPropertyUpperLimit(
                'Camera', 'Exposure')
            self.cam.setExposure(exposure)
            self.supports_exposure = True
        else:
            print('Camera does not support setting the exposure time')
            self.supports_exposure = False

        self.width, self.height = self.cam.getImageWidth(
        ), self.cam.getImageHeight()

        self.cam.startContinuousSequenceAcquisition(1)

        # Keep an old frame around to detect a frozen image
        self.comparison_time = None
        self.comparison_frame = None
Beispiel #8
0
    def __init__(self, cameraId=-1, mirrored=False, parent=None):
        super(CameraDevice, self).__init__(parent)
        self.mmc = MMCorePy.CMMCore()  # Instance micromanager core
        self.mmc.getVersionInfo()
        self.mmc.getAPIVersionInfo()
        self.mmc.loadDevice(*DEVICE)
        self.mmc.initializeAllDevices()
        self.mmc.setCameraDevice('Camera')
        print "Camera Exposure Property Modifiable: ", self.mmc.hasProperty(DEVICE[0], 'Exposure') 

        #self.mmc.setProperty(DEVICE[0], 'Exposure', int(10))
        self.mmc.startContinuousSequenceAcquisition(1)



        temp = self.mmc.getLastImage();
        self.framesize = (temp.shape[1], temp.shape[0])
        self.npFrame = None;
        self.rawFrame = None;
        #self.mmc.setExposure(50);

        self._timer = QTimer(self)
        self._timer.timeout.connect(self._queryFrame)
        self._timer.setInterval(1000/self.fps)

        self.equalizationOn = False

        self.paused = False

        self.brightness = 0
        self.contrast = 1

        self.BrightnessOffset = 0
Beispiel #9
0
    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
Beispiel #10
0
def main():
    """Looping in function should be faster then in global scope.
    """
    mmc = MMCorePy.CMMCore()
    filename = "C:\Users\Smithlab\Documents\ASI_LUM_RETIGA_CRISP.cfg"
    mmc.loadSystemConfiguration(filename)
    mmc.enableStderrLog(False)
    mmc.enableDebugLog(False)
    # mmc.setCircularBufferMemoryFootprint(100)
    cam = mmc.getCameraDevice()

    mmc.setConfig('Channels', 'DAPI')
    mmc.waitForConfig('Channels', 'DAPI')
    #self.mmc.setShutterOpen(False)

    #cv2.namedWindow('MM controls')
    #if mmc.hasProperty(cam, 'Gain'):
    #    cv2.createTrackbar(
    #        'Gain', 'MM controls',
    #        int(float(mmc.getProperty(cam, 'Gain'))),
    #        int(mmc.getPropertyUpperLimit(cam, 'Gain')),
    #        lambda value: mmc.setProperty(cam, 'Gain', value))
    #if mmc.hasProperty(cam, 'Exposure'):
    #    cv2.createTrackbar(
    #       'Exposure', 'MM controls',
    #      int(float(mmc.getProperty(cam, 'Exposure'))),
    #     100,  # int(mmc.getPropertyUpperLimit(DEVICE[0], 'Exposure')),
    #        lambda value: mmc.setProperty(cam, 'Exposure', int(value)))

    set_mmc_resolution(mmc, WIDTH, HEIGHT)
    mmc.setProperty(cam, 'Gain', 20)
    mmc.snapImage()  # Baumer workaround
    data = mmc.getImage()
    gray = data.view(dtype=np.uint8)
    fig = plt.figure(1)
    ax1 = fig.add_subplot(1, 1, 1)
    theimg = ax1.imshow(gray, cmap='gray')
    plt.ion()
    plt.show(False)
    # cv2.namedWindow('Video',flags=cv2.WINDOW_NORMAL )
    mmc.startContinuousSequenceAcquisition(1)
    while True:
        remcount = mmc.getRemainingImageCount()
        print('Images in circular buffer: %s') % remcount
        if remcount > 0:
            # rgb32 = mmc.popNextImage()
            rgb32 = mmc.getLastImage()
            gray = rgb32.view(dtype=np.uint8)
            gray = cv2.equalizeHist(gray)
            theimg.set_array(gray)
            plt.draw()
            #cv2.imshow('Video', gray)
        else:
            print('No frame')
        if cv2.waitKey(5) >= 0:
            break
    cv2.destroyAllWindows()
    mmc.stopSequenceAcquisition()
    mmc.reset()
Beispiel #11
0
def init_mmc(binning, exposure_time):
    mmc = MMCorePy.CMMCore()
    mmc.loadDevice('Camera', 'HamamatsuHam', 'HamamatsuHam_DCAM')
    mmc.initializeAllDevices()
    mmc.setCameraDevice('Camera')
    mmc.setProperty('Camera', 'Binning', binning)
    mmc.setProperty('Camera', 'Exposure', exposure_time)
    return mmc
Beispiel #12
0
    def __init__(self):
        self.mmc = MMCorePy.CMMCore()
        self.mmc.loadDevice('TIScope', 'NikonTI', 'TIScope')
        self.mmc.loadDevice('TIDiaShutter', 'NikonTI', 'TIDiaShutter')
        self.mmc.loadDevice('TIFilterBlock1', 'NikonTI', 'TIFilterBlock1')
        self.mmc.loadDevice('TITIRF', 'NikonTI', 'TITIRF')
        self.mmc.initializeAllDevices()

        self.tirf_scale = 1000.0
 def __init__(self,configpath,logpath,camera_name="BSI Prime",shutter_name="SpectraIII",xystage_name="XYStage",focus_name="ZDrive"):
     self.mmc = MMCorePy.CMMCore()
     self.mmc.loadSystemConfiguration(configpath)
     self.mmc.setPrimaryLogFile(logpath)
     self.mmc.setCameraDevice(camera_name)
     
     self.camera_name = camera_name
     self.shutter_name = shutter_name
     self.xystage_name = xystage_name
     self.focus_name = focus_name
Beispiel #14
0
def loadMicroManager(mm_directory, system_cfg_file):
    prev_dir = os.getcwd()
    os.chdir(mm_directory
             )  # MUST change to micro-manager directory for method to work
    import MMCorePy
    mmc = MMCorePy.CMMCore()
    mmc.loadSystemConfiguration(system_cfg_file)
    os.chdir(prev_dir)
    print("Micro-manager was loaded sucessfully!")
    return (mmc)
Beispiel #15
0
def mainLoading():
    configuration = Configuration()
    mmc = MMCorePy.CMMCore()
    mmc.loadSystemConfiguration(configuration.cfg)
    pixelSize = mmc.getPixelSizeUm()
    ## set properties to get 16 bit images and avoid tunneling
    mmc.setProperty('IDS uEye', 'Exposure', configuration.exposureBrightField)
    imageHeight = mmc.getImageHeight()
    imageWidth = mmc.getImageWidth()
    mmc.setROI(configuration.cropX, configuration.cropY, (imageWidth - configuration.cropX*2), (imageHeight - configuration.cropY*2))
    return mmc
Beispiel #16
0
def get_micromanager_instance():
    # TODO(arl): load a micromanager config from file?

    mmc = MMCorePy.CMMCore()  # get micromanager core instance
    mmc_version = mmc.getVersionInfo()

    logger.info("Imported MMCore v{}".format(mmc_version))

    # set up the camera and niji
    mmc.loadDevice('Grasshopper3', 'PointGrey', 'Grasshopper3 GS3-U3-91S6M_14103093')
    mmc.loadDevice('COM9', 'SerialManager', 'COM9')
    mmc.loadDevice('niji', 'BlueboxOptics_niji', 'niji')
    mmc.loadDevice('Fast Filter Wheel', 'ThorlabsAPTStage', 'BSC101')

    # set up serial port for niji
    mmc.setProperty('COM9', 'AnswerTimeout', '500.0000')
    mmc.setProperty('COM9', 'BaudRate', '115200')
    mmc.setProperty('COM9', 'DataBits', '8')
    mmc.setProperty('COM9', 'DelayBetweenCharsMs', '0.0000')
    mmc.setProperty('COM9', 'Fast USB to Serial', 'Disable')
    mmc.setProperty('COM9', 'Handshaking', 'Off')
    mmc.setProperty('COM9', 'Parity', 'None')
    mmc.setProperty('COM9', 'StopBits', '1')
    mmc.setProperty('COM9', 'Verbose', '1')
    mmc.setProperty('niji', 'Port', 'COM9')

    # set up the filter wheel
    mmc.setProperty('Fast Filter Wheel', 'Channel', '1')
    mmc.setProperty('Fast Filter Wheel', 'Position Lower Limit (um)','0.0000')
    mmc.setProperty('Fast Filter Wheel', 'Position Upper Limit (um)','360000.0000')
    mmc.setProperty('Fast Filter Wheel', 'Serial Number', '40876841')

    # initialize all of the devices
    mmc.initializeAllDevices()

    # make sure we use 2x2 binning on the camera as default
    mmc.setProperty('Grasshopper3', 'Use Advanced Mode?', 'Yes')
    mmc.setProperty('Grasshopper3', 'Format-7 Mode', 'Mode-1')
    mmc.setProperty('Grasshopper3', 'PixelType', '8-bit')

    # niji settings
    mmc.setProperty('niji', 'Channel3Intensity', '20')  # GFP
    mmc.setProperty('niji', 'Channel5Intensity', '20')  # RFP
    mmc.setProperty('niji', 'Channel6Intensity', '20')  # iRFP
    mmc.setProperty('niji', 'Channel3State', '0')
    mmc.setProperty('niji', 'Channel5State', '0')
    mmc.setProperty('niji', 'Channel6State', '0')
    mmc.setProperty('niji', 'TriggerSource', 'Internal')
    mmc.setProperty('niji', 'State', '0')

    # set the camera to be the grasshopper
    mmc.setCameraDevice('Grasshopper3')

    return mmc
Beispiel #17
0
def initial():
    mmc = MMCorePy.CMMCore()  # Get micro-manager controller object
    # Load system configuration (loads all devices)
    mmc.loadSystemConfiguration(system_cfg_file)
    os.chdir(prev_dir)
    mmc.loadDevice('Cam', 'DemoCamera', 'DCam')
    mmc.loadDevice('xy', 'DemoCamera', 'DXYStage')
    mmc.loadDevice('autofocus', 'DemoCamera', 'DAutoFocus')
    mmc.loadDevice('z', 'DemoCamera', 'DStage')
    mmc.initializeAllDevices()
    mmc.setCameraDevice('Cam')
    return mmc
Beispiel #18
0
    def __init__(self, parent):
        QtCore.QThread.__init__(self)
        self.parent = parent
        eng = mateng.start_matlab()
        self.eng = eng

        sh = MMCorePy.CMMCore()
        sh.loadDevice("cam", "IDS_uEye", "IDS uEye")
        sh.initializeDevice("cam")
        sh.setCameraDevice("cam")
        sh.setProperty("cam", "Pixel Clock", 30.)
        sh.setProperty("cam", "PixelType", '8bit mono')
        sh.setProperty("cam", "Exposure", 0.190)
        self.sh = sh
Beispiel #19
0
    def __init__(self, parent, sh_exp):
        QtCore.QThread.__init__(self)
        self.parent = parent
        eng = mateng.start_matlab()
        self.eng = eng

        sh = MMCorePy.CMMCore()
        sh.loadDevice("cam", "ThorlabsUSBCamera", "ThorCam")
        sh.initializeDevice("cam")
        sh.setCameraDevice("cam")
        #sh.setProperty("cam", "Pixel Clock", 30.)
        #sh.setProperty("cam", "PixelType", '8bit mono')
        sh.setProperty("cam", "Exposure", sh_exp)
        self.parent.sh = sh
Beispiel #20
0
    def __init__(self):

        self.camera_commands = {
            'snap': self.snap_image,
            'get_image': self.get_image,
            'start_continuous': self.start_continuous,
            'stop_continuous': self.stop_continuous,
            'get_last': self.get_last,
            'set_exposure': self.set_exposure,
            'get_exposure': self.get_exposure,
            'get_name': self.get_camera_name
        }

        self.stage_commands = {
            'get_position': self.get_xy_position,
            'rel_position': self.set_rel_xy_position,
            'set_position': self.set_xy_position,
            'set_origin': self.set_xy_origin
        }

        self.obj_commands = {
            'get_position': self.get_obj_position,
            'set_position': self.set_obj_position
        }

        self.core_commands = {
            'load': self.load_devices,
            'init': self.init_devices,
            'unload': self.unload_devices,
            'unload_device': self.unload_device,
            'init_device': self.init_device,
            'load_config': self.load_config,
            'get_xy_name': self.get_xy_name,
            'get_filterwheel_name': self.get_filterwheel_name,
            'get_shutter_name': self.get_shutter_name
        }

        self.filter_commands = {
            'set': self.set_filter_channel,
            'get': self.get_filter_channel
        }

        self.shutter_commands = {
            'get': self.get_shutter,
            'open': self.open_shutter,
            'close': self.close_shutter
        }

        self.mmc = MMCorePy.CMMCore()
Beispiel #21
0
def set_up_cameras():
    """two cameras were used for shack-hartmann sensing and one for interferometry
    they had different pixel clocks, and could be differentiated by that
    returns 2 MMCorePy camera objects"""
    cam1 = MMCorePy.CMMCore()
    cam1.loadDevice("cam", "IDS_uEye", "IDS uEye")
    cam1.initializeDevice("cam")
    cam1.setCameraDevice("cam")
    pixel_clock = cam1.getPropertyUpperLimit("cam", "Pixel Clock")
    if pixel_clock == 150.0:
        cam1.setProperty("cam", "Pixel Clock", 150)
        cam1.setProperty("cam", "PixelType", '8bit mono')
        cam1.setProperty("cam", "Exposure", 0.097)
        sh = cam1

        cam2 = MMCorePy.CMMCore()
        cam2.loadDevice("cam", "IDS_uEye", "IDS uEye")
        cam2.initializeDevice("cam")
        cam2.setCameraDevice("cam")
        cam2.setProperty("cam", "Pixel Clock", 43)
        cam2.setProperty("cam", "Exposure", 13.226)
        int_cam = cam2
    else:
        cam1.setProperty("cam", "Pixel Clock", 43)
        cam1.setProperty("cam", "Exposure", 13.226)
        int_cam = cam1

        cam2 = MMCorePy.CMMCore()
        cam2.loadDevice("cam", "IDS_uEye", "IDS uEye")
        cam2.initializeDevice("cam")
        cam2.setCameraDevice("cam")
        cam2.setProperty("cam", "Pixel Clock", 150)
        cam2.setProperty("cam", "PixelType", '8bit mono')
        cam2.setProperty("cam", "Exposure", 0.097)
        sh = cam2
    return sh, int_cam
def main():
    """Looping in function should be faster then in global scope.
    """
    mmc = MMCorePy.CMMCore()
    mmc.enableStderrLog(False)
    mmc.enableDebugLog(False)
    # mmc.setCircularBufferMemoryFootprint(100)
    mmc.loadDevice(*DEVICE)
    mmc.initializeDevice(DEVICE[0])
    mmc.setCameraDevice(DEVICE[0])
    mmc.setProperty(DEVICE[0], 'PixelType', '32bitRGB')

    cv2.namedWindow('MM controls')
    if mmc.hasProperty(DEVICE[0], 'Gain'):
        cv2.createTrackbar(
            'Gain', 'MM controls',
            int(float(mmc.getProperty(DEVICE[0], 'Gain'))),
            int(mmc.getPropertyUpperLimit(DEVICE[0], 'Gain')),
            lambda value: mmc.setProperty(DEVICE[0], 'Gain', value))
    if mmc.hasProperty(DEVICE[0], 'Exposure'):
        cv2.createTrackbar(
            'Exposure',
            'MM controls',
            int(float(mmc.getProperty(DEVICE[0], 'Exposure'))),
            100,  # int(mmc.getPropertyUpperLimit(DEVICE[0], 'Exposure')),
            lambda value: mmc.setProperty(DEVICE[0], 'Exposure', int(value)))

    set_mmc_resolution(mmc, WIDTH, HEIGHT)
    cv2.namedWindow('Video')
    mmc.startContinuousSequenceAcquisition(1)
    while True:
        remcount = mmc.getRemainingImageCount()
        print('Images in circular buffer: %s') % remcount
        if remcount > 0:
            # rgb32 = mmc.popNextImage()
            rgb32 = mmc.getLastImage()
            bgr = rgb32.view(dtype=np.uint8).reshape(rgb32.shape[0],
                                                     rgb32.shape[1],
                                                     4)[..., :3]
            cv2.imshow('Video', bgr)
        else:
            print('No frame')
        if cv2.waitKey(5) >= 0:
            break
    cv2.destroyAllWindows()
    mmc.stopSequenceAcquisition()
    mmc.reset()
Beispiel #23
0
def run_acquisition(params_string):

    # create mmc object
    mmc = MMCorePy.CMMCore()

    # load json and set params
    params = json.loads(params_string)
    load_acquisition_params(params)

    # start stage moving
    control_stage(mmc, params)

    # start acq
    vol_quantifiers = acquire_image_sequence(mmc, params)

    # save
    save_image_sequence(vol_quantifiers, params)
    def __init__(self):
        super(MainWindow, self).__init__()

        mmc = MMCorePy.CMMCore()
        mmc.enableDebugLog(False)
        mmc.enableStderrLog(False)
        # mmc.setCircularBufferMemoryFootprint(100)
        mmc.loadDevice(*DEVICE)
        mmc.initializeDevice(DEVICE[0])
        mmc.setCameraDevice(DEVICE[0])
        mmc.setProperty(DEVICE[0], 'PixelType', '32bitRGB')
        # mmc.setROI(0, 0, 640, 480)

        self.VProcessor = VideoProcessor(mmc)
        self.VProcessor.start()
        self.setGeometry(100, 100, mmc.getImageWidth(), mmc.getImageHeight())
        self.widget = GLFrame(mmc.getImageWidth(), mmc.getImageHeight())
        self.setCentralWidget(self.widget)

        self.connect(self.VProcessor, QtCore.SIGNAL('NewFrame()'),
                     self.redraw_any)
    def __init__(self, saving_directory=DEFAULT_SAVING_DIRECTORY):

        self.set_saving_directory(saving_directory)

        self.mmc = MMCorePy.CMMCore()
        self.mmc.loadDevice('Camera', 'HamamatsuHam', 'HamamatsuHam_DCAM')
        self.mmc.initializeAllDevices()
        self.mmc.setCameraDevice('Camera')

        self.settings = {'binning': '1x1'}

        self.mmc.prepareSequenceAcquisition('Camera')
        #self.mmc.setCircularBufferMemoryFootprint(4000)
        self.live_queue = False

        self.shower = ImageShower()

        # Description file string
        self.description_string = ''

        self.save_stack = False
 def __init__(self):
     
     try : COM = 'COM1'; self.olympus = OlympusIX81(COM); print('Olympus loaded')
     except : print('no config olympus!')
         
     try : 
         self.mmc = MMCorePy.CMMCore() #micromanager
         self.mmc.loadDevice('Camera','AndorSDK3','Andor sCMOS Camera')
         self.mmc.initializeDevice('Camera')
         self.mmc.setCameraDevice('Camera')
         
         self.cam = self.mmc.getCameraDevice()
         A = self.mmc.getAllowedPropertyValues(self.cam,'Sensitivity/DynamicRange')
         self.mmc.setProperty(self.cam,'Sensitivity/DynamicRange',A[2])  #camera en 16bits
         print('Camera with micromanager loaded')
     except : print('no Cam!')
         
     try : COM = 'COM4'; self.xcite = XCite(COM); print('Xcite loaded')
     except : print('no Fluo!')
     
     try : COM = 'COM5'; self.lstep = LStep(COM); print('LStep loaded')
     except : print('no Lstep!')
Beispiel #27
0
    def initializeMicroManager(self):
        """Instantiates a MMCore instance

		Args:
			None

		Returns:
			None
		"""

        logging.info('Trying to Establish Microscope Control...')
        sys.path.insert(0, HardwareInterface.mm_version
                        )  # make it so python can find MMCorePy
        import MMCorePy
        HardwareInterface.core = MMCorePy.CMMCore()
        HardwareInterface.core.loadSystemConfiguration(
            str(HardwareInterface.mmcfg))
        HardwareInterface.core.setTimeoutMs(HardwareInterface.coreTimeout)
        logging.info('Microscope Control Established')

        defaults = self.config['mm']['defaults']
        self.setScopeConfig(exposure=defaults['exposure'],
                            binning=defaults['binning'])
Beispiel #28
0
    def readFramesFromBuffer(self, img_bg=None):
        sys.path.append(mm_directory)
        import MMCorePy
        md = MMCorePy.Metadata()
        elapsed_frame_time = []

        frame_list = np.zeros(
            (self.getBufferSizeFrames(), self.getImageHeight(),
             self.getImageWidth()),
            dtype=np.uint16)
        for img_idx in range(frame_list.shape[0]):
            if img_bg is not None:
                frame_list[img_idx, :, :] = np.max(
                    self.mmc.popNextImageMD(md).copy().astype(np.int) -
                    img_bg).astype(np.uint16)
            else:
                frame_list[img_idx, :, :] = self.mmc.popNextImageMD(md).copy()
            elapsed_frame_time.append(
                float(md.GetSingleTag("ElapsedTime-ms").GetValue()))

        elapsed_frame_time = np.asarray(elapsed_frame_time)
        elapsed_frame_time = elapsed_frame_time - np.min(elapsed_frame_time)

        return (frame_list, elapsed_frame_time.tolist())
    def __init__(self,
                 configFile,
                 channelGroupName='Channels',
                 use_focus_plane=False,
                 focus_points=None,
                 transpose_xy=False):
        #NEED TO IMPLEMENT IF NOT MICROMANAGER

        self.configFile = configFile
        self.mmc = MMCorePy.CMMCore()
        self.mmc.enableStderrLog(False)
        self.mmc.enableDebugLog(True)
        self.mmc.setPrimaryLogFile('CoreLogProcessSpeed_newfirm.txt')
        self.mmc.loadSystemConfiguration(self.configFile)

        self.channelGroupName = channelGroupName
        self.transpose_xy = transpose_xy
        auto_dev = self.mmc.getAutoFocusDevice()
        assert (auto_dev is not None)

        dev_name = self.mmc.getDeviceName(auto_dev)
        print "dev_name", dev_name

        if 'SimpleAutofocus' == dev_name:
            self.has_continuous_focus = False
        else:
            self.has_continuous_focus = True

        print "has_continuous_focus", self.has_continuous_focus

        self.focus_points = focus_points
        self.plane_tuple = None
        self.use_focus_plane = use_focus_plane
        if use_focus_plane:
            assert (focus_points is not None)
            self.define_focal_plane(points)
Beispiel #30
0
start_wave = 800
# grating 1 = 1800 grooves/mm Blz = 500nm, grating 2 = 300grooves/mm Blz = 750nm
start_grating = 2

dynamic = 0  #keep capturing images if 1, or 1 image at a time if 0
exposure = 100  #in ms
gain = 1
# 1.) Always Closed 2.) Always Open 3.) Normal 4.) Open Before Trigger
shutter = 3
shutterdelay = 0
n_image = 1
line_cam = 0  #Which line to view, average the whole image if zero

import MMCorePy
mmc = MMCorePy.CMMCore()
mmc.loadSystemConfiguration('MMConfig.cfg')

######################################################################
#Beginning of control parameters for SP2300i
######################################################################

ser = serial.Serial(baudrate=9600, port=SERIAL_PORT, timeout=20)

if start_grating == 1:
    grating_num = 1800
else:
    grating_num = 300

print 'Changing the grating to: %d' % grating_num
print 'Changing the wavelength to: %d' % start_wave