ORCA-Flash4.0 V3 Issue while trying to perform more than one sequence acquisition.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

ORCA-Flash4.0 V3 Issue while trying to perform more than one sequence acquisition.

ricarvid1

Hello,

I am right now using the Micro-Manager python library to control a ORCA-Flash4.0 V3 Camera  with a script. Basically, I need to perform several sequence acquisitions. Everything goes fine for the first acquisition but when I try to get another one the script runs into an error and it seems like the camera disconnects (Error and code in the following lines). Right now the only solution I could find was unloading and reloading the camera again, which is a bit annoying because all my configurations are lost and I have to load them again. Thanks in advance for your help.


The Error I get:


CMMError: Error in device "Camera": Unknown error in the device (1)


Code:


sys.path.append("C:\\Program Files\\Micro-Manager-1.4")
    
    #loading camera
    mmc = MMCorePy.CMMCore()
    #mmc.loadDevice('Camera', 'DemoCamera', 'DCam')
    #Hamamatsu
    mmc.loadDevice('Camera', 'HamamatsuHam', 'HamamatsuHam_DCAM')    

    mmc.initializeAllDevices()
    mmc.setCameraDevice('Camera')
    
    
    #All figures are closed
    plt.close("all")
    
    #Sigle image snapshot
    mmc.snapImage()
    img = mmc.getImage() #this is numpy array, by the way
    
    #Region of Interest
    x = 0
    y = 0
    xSize = 512
    ySize = 512
    mmc.setROI(x,y,xSize,ySize)

    #Image sequence acquisition
    numImages = 5
    intervalMs = 1
    successfulAcquisition = False
    #mmc.clearCircularBuffer()
    start_time = time.time()
    mmc.prepareSequenceAcquisition('Camera')
    mmc.startSequenceAcquisition(numImages, intervalMs, True)
  
  # JUST READING THE IMAGES
    imList = []
    filename = "sequence.tiff"
    while True:
        if mmc.getRemainingImageCount() > 0:
            img = mmc.popNextImage()
            imList.append(Image.fromarray(img))
        elif not mmc.isSequenceRunning():
            if not successfulAcquisition:
                successfulAcquisition = True
                print("Acquisition finished after %s seconds" % (time.time() - start_time))
            if len(imList) == numImages:
                imList[0].save(filename, compression="None", save_all=True,
                               append_images=imList[1:])
                print("File saved after %s seconds" % (time.time() - start_time))
                break

    print("Remaining Images: %d" % mmc.getRemainingImageCount())
    mmc.waitForDevice('Camera')
      

    #SECOND ACQUISITION
    
    successfulAcquisition = False
    mmc.clearCircularBuffer()
    start_time = time.time()
    
    mmc.prepareSequenceAcquisition('Camera')
    #ERROR HAPPENS WHEN CQLLING THE ACQUISITION AGAIN
    mmc.startSequenceAcquisition(numImages, intervalMs, True)


    imList = []
    filename = "sequence2.tiff"
    while True:
        if mmc.getRemainingImageCount() > 0:
            img = mmc.popNextImage()
            imList.append(Image.fromarray(img))
        elif not mmc.isSequenceRunning():
            if not successfulAcquisition:
                successfulAcquisition = True
                print("Acquisition finished after %s seconds" % (time.time() - start_time))
            if len(imList) == numImages:
                imList[0].save(filename, compression="None", save_all=True,
                               append_images=imList[1:])
                print("File saved after %s seconds" % (time.time() - start_time))
                break




Sincerely,

DR 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general