Trying to develop support for cameras using the DCAM specification

266 views
Skip to first unread message

Andrew Penn

unread,
Jan 5, 2016, 9:08:28 AM1/5/16
to ACQ4
Hi there,

I have a SciCam (http://www.dssimage.com/images/upload/Scicam_low_res.pdf) which I bought from Scientifica. I would prefer to control the camera and do the imaging in ACQ4 rather than the proprietary software which I have been provided by Scientifica. I don't do anything fancy with the camera, it's just for visually guided patching with IR-DIC and for identifying transfected cells expressing a fluorescent protein but I'd prefer not having several software running simultaneously during my data aquisition.

I read your post about adding a PCO Pixelfly camera, and think I git the gist that only Photometrics and QImaging cameras (that use PVCam or QCam drivers respectively) are currently supported in ACQ4

Here, the camera in question (SciCam) conforms to the DCAM 1.31 protocol. I found the following websites for an API and pythonic wrapper suitable for cameras that conform to the DCAM specification.
https://github.com/jordens/pydc1394/blob/master/README.rst

I noticed that quite a lot of cameras conform to this specification.

http://damien.douxchamps.net/ieee1394/cameras/#LIST

The software people at Scientifica reckon that the driver should work with the SciCam too (although it doesn't appear on the above list)

Would it be much work (and would you anticipate much interest) in using the API and python wrapper above to create an ACQ4 driver for cameras with the DCAM specification.

My Python is a bit amateur and I feel abit out of my depth.

Best

Andy



Michael Graupner

unread,
Jan 6, 2016, 3:24:41 AM1/6/16
to ac...@googlegroups.com
Hi Andy, 

that is right. I have a intern working on implementing our PCO Pixelfly camera in ACQ4. The camera is based on the SC2_Cam driver. 

A direct implementation of your camera in ACQ4 is definitively possible but it requires some work to channel the camera specifics into a driver and a device class. Each camera has its own way of arming the device, setting parameters, initializing memory for images and reading out the images.

An exciting development however is the implementation of cameras supported by the Mircomanager - and there are a lot - in ACQ4. This branch has just been merged into the develop branch and is ready to be tested : 
Check whether your camera is supported by Micromanager. If yes you can start testing it right away in ACQ4. 
I have not used the new extension myself and have no experience with it. 

Cheers,
Michael 

 

--
You received this message because you are subscribed to the Google Groups "ACQ4" group.
To unsubscribe from this group and stop receiving emails from it, send an email to acq4+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/acq4/78263ba8-dbba-4aa1-a73b-a186831a9a32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Penn

unread,
Jan 7, 2016, 10:16:19 AM1/7/16
to ACQ4
Hi,

As you suggested, my camera works fine in Micro-Manager. I did the following:

1) Downloaded and installed the 32-bit Windows version of MicroManager:
https://www.micro-manager.org/wiki/Download%20Micro-Manager_Latest%20Release

2) Downloaded the signed 1394 Camera Driver (v6.4.6):
http://www.cs.cmu.edu/~iwan/1394/downloads/index.html

3) I followed the installation instructions for the 1394 Camera Driver:
http://www.cs.cmu.edu/~iwan/1394/install.html

4) Using the Tools -> Hardware configuration wizard I created a new configuration using the dc1394 device drive

5) In Micro-Manager, I followed the installation instructions for the IIDC 1394-based Digital Camera Specification:
https://micro-manager.org/wiki/IIDC#How_to_configure

To get acq4 with MicroManager support, I downloaded the most recent version using git. I'm now just a bit stuck on what I add to the devices.cfg file. Would it be something along the lines of:

Camera:
    driver: 'MicroManagerCamera'
    mmAdaptorName: '???'
    mmDeviceName: '???'

Trouble is, I don't know what to answer to for mmAdaptorName and mmDeviceName configuration keys. Am I way off here?

Best

Andy

Luke Campagnola

unread,
Jan 7, 2016, 11:37:16 AM1/7/16
to acq4
On Thu, Jan 7, 2016 at 7:16 AM, Andrew Penn <andy....@gmail.com> wrote:
To get acq4 with MicroManager support, I downloaded the most recent version using git. I'm now just a bit stuck on what I add to the devices.cfg file. Would it be something along the lines of:

Camera:
    driver: 'MicroManagerCamera'
    mmAdaptorName: '???'
    mmDeviceName: '???'

Trouble is, I don't know what to answer to for mmAdaptorName and mmDeviceName configuration keys. Am I way off here?


You can start by entering anything into these fields. When ACQ4 starts up, you'll get an error message telling you the available options. 
(This is the sort of situation where a graphical configurator would be really nice)

I've only tested micromanager with a single type of camera, so we can probably expect some rough spots ahead..


Luke

Andrew Penn

unread,
Jan 7, 2016, 11:46:16 AM1/7/16
to ACQ4
Hi Luke,

Thanks for the quick reply. For that device configuration I mentioned above, I get the error message below but I don't see any options...

2016.01.07 16:42:24 Error configuring device Camera:

  1. KeyError: 'mmAdapterName'

KeyError: 'mmAdapterName'
  File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Program Files\acq4\acq4\__main__.py", line 44, in <module>
    man = Manager(argv=sys.argv[1:])
  File "acq4\Manager.py", line 218, in __init__
    self.readConfig(configFile)
  File "acq4\Manager.py", line 304, in readConfig
    self.configure(cfg)
  File "acq4\Manager.py", line 331, in configure
    printExc("Error configuring device %s:" % k)
  File "acq4\util\debug.py", line 19, in printExc
    acq4.Manager.logExc(msg=msg, msgType=msgType)
------- exception caught ---------->
  File "acq4\Manager.py", line 329, in configure
    self.loadDevice(driverName, conf, k)
  File "acq4\Manager.py", line 461, in loadDevice
    dev = devclass(self, conf, name)
  File "acq4\devices\MicroManagerCamera\mmcamera.py", line 43, in __init__
    Camera.__init__(self, manager, config, name)  ## superclass will call setupCamera when it is ready.
  File "acq4\devices\Camera\Camera.py", line 95, in __init__
    self.setupCamera()
  File "acq4\devices\MicroManagerCamera\mmcamera.py", line 50, in setupCamera
    adapterName = self._config['mmAdapterName']

Luke Campagnola

unread,
Jan 7, 2016, 2:01:00 PM1/7/16
to acq4
Looks like you (or I) misspelled 'mmAdapterName'.

--
You received this message because you are subscribed to the Google Groups "ACQ4" group.
To unsubscribe from this group and stop receiving emails from it, send an email to acq4+uns...@googlegroups.com.

Andrew Penn

unread,
Jan 11, 2016, 3:58:24 AM1/11/16
to ACQ4
Hi Luke,

Thanks. I should have spotted that spelling discrepancy.

So I tried adding the following lines to devices.cfg
Camera:
    driver: 'MicroManagerCamera'
    mmAdapterName: 'dc1394'
    mmDeviceName: 'dc1394_CAM'

This time I get a different error:
Error configuring device Camera:
  1. CMMError: Failed to load device adapter "dc1394" [ Failed to load module "C:\Program Files\Micro-Manager-1.4\mmgr_dal_dc1394.dll" [ The module, or a module it depends upon, could not be found (Windows error: The specified module could not be found.) ] ]

CMMError: Failed to load device adapter "dc1394" [ Failed to load module "C:\Program Files\Micro-Manager-1.4\mmgr_dal_dc1394.dll" [ The module, or a module it depends upon, could not be found (Windows error: The specified module could not be found.) ] ]

  File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Program Files\acq4\acq4\__main__.py", line 44, in <module>
    man = Manager(argv=sys.argv[1:])
  File "acq4\Manager.py", line 218, in __init__
    self.readConfig(configFile)
  File "acq4\Manager.py", line 304, in readConfig
    self.configure(cfg)
  File "acq4\Manager.py", line 331, in configure
    printExc("Error configuring device %s:" % k)
  File "acq4\util\debug.py", line 19, in printExc
    acq4.Manager.logExc(msg=msg, msgType=msgType)
------- exception caught ---------->
  File "acq4\Manager.py", line 329, in configure
    self.loadDevice(driverName, conf, k)
  File "acq4\Manager.py", line 461, in loadDevice
    dev = devclass(self, conf, name)
  File "acq4\devices\MicroManagerCamera\mmcamera.py", line 43, in __init__
    Camera.__init__(self, manager, config, name)  ## superclass will call setupCamera when it is ready.
  File "acq4\devices\Camera\Camera.py", line 95, in __init__
    self.setupCamera()

  File "acq4\devices\MicroManagerCamera\mmcamera.py", line 55, in setupCamera
    allDevices = self.mmc.getAvailableDevices(adapterName)
  File "C:\Program Files\Micro-Manager-1.4\MMCorePy.py", line 3406, in getAvailableDevices
    return _MMCorePy.CMMCore_getAvailableDevices(self, *args)


MicroManager is installed in the location C:\Program Files\Micro-Manager-1.4, and so are the relevant .dll files for dc1394 from the camera driver installation so I'm not sure why I'm getting this error.

Source code for the dc1394 Micro-Manager driver can be found here:
http://www.cs.cmu.edu/~iwan/1394/downloads/1394camera646_src.zip

Best

Andy

Luke Campagnola

unread,
Jan 11, 2016, 4:17:57 PM1/11/16
to acq4
This might be a question for the micromanager folks.. one possibility is that you have a mismatch between micromanager and python (like 32-bit python and 64-bit micromanager, or vice-versa?). If you can, try running just the few lines of python needed to access the camera, something like:

        sys.path.append('C:\\Program Files\\Micro-Manager-1.4')
        import MMCorePy
        mmc = MMCorePy.CMMCore()
        devs = mmc.getAvailableDevices(adapterName)

This will make it easier to try different configurations, and make it much easier for the micromanager folks to help you.


Luke


Andrew Penn

unread,
Jan 12, 2016, 2:01:31 PM1/12/16
to ACQ4

Hi Luke,

A response from the Micro-manager mailing list is below. As I can gather, although my acq4, python dependencies and Micromanager are all 32-bit (to support the multiclamp commander) the dc1394 driver and my Windows platform are 64-bit. This would all be a lot easier if I could keep everything 64-bit. Is it still really the case that multiclamp commander only works in 32-bit mode? Hasn't a driver been released that does? I'm using it to control my brand new multiclamp 700B. The support folk at molecular devices say the commander works on 64-bit systems so why the 32-bit mode?

Best

Andy


Is your copy of Windows 7 also 32-bit? Controlling 64-bit device drivers from 32-bit frequently is problematic. I know Python upstream support for Windows 64-bit is less than stellar, but Anaconda distribution does a good job.

If for hardware driver reasons you are limited to 32-bit you should consider 32-bit Windows (which comes on a separate Windows installation CD). Although I would first look into checking with the manufacturer for newer 64-bit drivers or ditching the offending device that requires 32-bit before going down the 32-bit Windows downgrading route. In the long run a few hundred £ costs less than you time, etc. 





Hi there, 

In Micro-Manager 1.4, I now successfully operate my Scietifica SciCam camera (which uses the DCAM 1.31 protocol: http://www.dssimage.com/images/upload/Scicam_low_res.pdf).

I installed Micro-Manager 1.4 and the dc1394 camera driver on my Windows 7 PC using the series of steps below.

1) Downloaded and installed the 32-bit Windows version of MicroManager (in the default installation directory):
https://www.micro-manager.org/wiki/Download%20Micro-Manager_Latest%20Release

2) Downloaded the signed 1394 Camera Driver (v6.4.6):
http://www.cs.cmu.edu/~iwan/1394/downloads/index.html

3) I followed the installation instructions for the 1394 Camera Driver:
http://www.cs.cmu.edu/~iwan/1394/install.html

4) Using the Tools -> Hardware configuration wizard I created a new configuration using the dc1394 device drive

5) In Micro-Manager, I followed the installation instructions for the IIDC 1394-based Digital Camera Specification:
https://micro-manager.org/wiki/IIDC#How_to_configure

So you might want to add the SciCam to your list of supported cameras.

My trouble is that, I'm trying to control the camera from python-based software (acq4:http://www.acq4.org/), which now can operate Micro-Manager-supported cameras via MMCorePy. 
However, when it tries to do this and lookfor the dc1394 driver adapter it up with an error. 
This is most simply demonstrated using the following series of commands in Python (Python 2.7.10 [MSC v.1500 32 bit (Intel)] on win32). 
 
>>> import sys
>>> sys.path.append('C:\\Program Files\\Micro-Manager-1.4')
>>> import MMCorePy
>>> mmc = MMCorePy.CMMCore()
>>> devs = mmc.getAvailableDevices(adapterName)

Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    devs=mmc.getAvailableDevices("dc1394")
  File "C:\Program Files\Micro-Manager-1.4\MMCorePy.py", line 3406, in getAvailableDevices
    return _MMCorePy.CMMCore_getAvailableDevices(self, *args)
CMMError: Failed to load device adapter "dc1394" [ Failed to load module "C:\Program Files\Micro-Manager-1.4\mmgr_dal_dc1394.dll" [ The module, or a module it depends upon, could not be found (Windows error: The specified module could not be found.) ] ]

Do you know what's going wrong here and how it could be fixed?

The acq4 mailing list problem solving discussion pointed me to you friendly Micro-Manager folk:https://groups.google.com/forum/?fromgroups#!topic/acq4/uDkudmYW1kQ

Thank you 

Best

Andy

Luke Campagnola

unread,
Jan 12, 2016, 9:08:19 PM1/12/16
to acq4
It's not necessary to use 32-bit python anymore. As you mentioned, MD has finally released a 64-bit version of their commander software. I have not had a chance to try this yet, but it should be simple to get working (IIRC, the API has not changed, but there may be some file name differences).

Alternatively, you can use the workaround that we provided a while back:
This allows you to run ACQ4 in 64-bit mode with a separate 32-bit python process just for communicating with the multiclamp.


Luke


--
You received this message because you are subscribed to the Google Groups "ACQ4" group.
To unsubscribe from this group and stop receiving emails from it, send an email to acq4+uns...@googlegroups.com.

Andrew Penn

unread,
Jan 13, 2016, 12:31:28 PM1/13/16
to ACQ4
Hi Luke,
OK that seems to look better. I have 32-bit and 64-bit python + dependencies and a acq4 setup with the 64-bit python. To get the Multiclamp commander working with 64-bit acq4 I still have to use your 32-bit work-around you mention and that works fine (without it, I get your error saying that only 32 bit is supported for multiclamp commander). I should point out that I had trouble at first with the command window hanging when tringing to initialise the multiclamp but this dissappeared when I removed the PythonPath environmental variable (which I had created in windows).

Anyway, the good news is that the error I was getting for the deviceAdapter is gone. I do however have a different error and this looks more like an issue in acq4:

2016.01.13 17:11:47 Error configuring device Camera:
IndexError: list index out of range
IndexError: list index out of range

  File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Program Files\acq4\acq4\__main__.py", line 44, in <module>
    man = Manager(argv=sys.argv[1:])
  File "acq4\Manager.py", line 218, in __init__
    self.readConfig(configFile)
  File "acq4\Manager.py", line 304, in readConfig
    self.configure(cfg)
  File "acq4\Manager.py", line 331, in configure
    printExc("Error configuring device %s:" % k)
  File "acq4\util\debug.py", line 19, in printExc
    acq4.Manager.logExc(msg=msg, msgType=msgType)
------- exception caught ---------->
  File "acq4\Manager.py", line 329, in configure
    self.loadDevice(driverName, conf, k)
  File "acq4\Manager.py", line 461, in loadDevice
    dev = devclass(self, conf, name)
  File "acq4\devices\MicroManagerCamera\mmcamera.py", line 43, in __init__
    Camera.__init__(self, manager, config, name)  ## superclass will call setupCamera when it is ready.
  File "acq4\devices\Camera\Camera.py", line 95, in __init__
    self.setupCamera()
  File "acq4\devices\MicroManagerCamera\mmcamera.py", line 62, in setupCamera
    self._readAllParams()
  File "acq4\devices\MicroManagerCamera\mmcamera.py", line 148, in _readAllParams
    params['binningY'] = ([int(v[1]) for v in vals], not readonly, True, [])

Thanks for your patience Luke

Best

Andy

Andrew Penn

unread,
Jan 17, 2016, 8:25:40 AM1/17/16
to ACQ4
Hmmm... actually, I think this error maybe occurring because my basic camera doesn't have on-chip binning feature, which according to mmcamera.py is a parameter that is expected for all camera's. When I'm back on the setup I could test adding a try/except statement around lines 147-148 and after have the 'except' values of binningX and binningY set to 1 (for 1X binning). I'll see if that fixes it. You probably have better workarounds to this in mind though.

Best

Andy

Luke Campagnola

unread,
Jan 17, 2016, 6:28:48 PM1/17/16
to acq4
I think you're right--for some cameras, binning values look like "1x1" and for others it looks like just "1", so we need to be more careful about checking for the latter case. At setup time (lines 147-148) we are just reading the possible binning values, so it should work to do something like:

    params['binningX'] = ([int(v[0 % len(v)]) for v in vals], not readonly, True, [])

(The modulo here takes care of both cases)
However, we will run into trouble again wherever binning is used. For example. on lines 161 and 242, is it ok to request a binning of "1x1", or will this generate an error? Likewise, lines 292-297 will need a little tweaking, something like:

    if param.startswith('binning'):
        val = [int(b) for b in val.split('x')]
        if len(val) == 1:
            val = val*2
        if param == 'binningY':
            return val[1]
        . . .

Do you think you can open a PR for this? If not, I can probably spend some time on it during the week.


Luke





Andrew Penn

unread,
Jan 17, 2016, 6:59:09 PM1/17/16
to ACQ4
Thanks for the reply. I can try out your suggestions tomorrow and Tuesday morning but will be on paternity leave the rest of the week. Silly question... regarding your last sentence what is a PR?

Luke Campagnola

unread,
Jan 18, 2016, 12:16:45 AM1/18/16
to acq4
PR == Pull Request: https://help.github.com/articles/creating-a-pull-request/
If you're not familiar with git, then you can just send me an updated code file (but I highly recommend getting comfy with git).

Andrew Penn

unread,
Jan 18, 2016, 4:29:27 AM1/18/16
to ACQ4
That seemed to work. For the time being I attach the file but I will have a look at making pull-requests on future acq4 threads.
Be warned that I modified the lines 161 and 242 for the '1' instead of the '1x1' format so you'll need to add some if/elif statement to accomodate your '1x1' binning format. I wasn't sure exactly so I leave this to you.
But before celebrating though I've run into a seperate issue. I'm a bit clueless about this one but it seems to me there is a problem loading up the camera gui.


2016.01.18 09:13:37 Error while creating dock for device 'Camera':

  1. UnboundLocalError: local variable 'mx' referenced before assignment

UnboundLocalError: local variable 'mx' referenced before assignment

  File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Program Files\acq4\acq4\__main__.py", line 44, in <module>
    man = Manager(argv=sys.argv[1:])

  File "acq4\Manager.py", line 236, in __init__
    self.showGUI()
  File "acq4\Manager.py", line 671, in showGUI
    self.gui = self.loadModule('Manager', 'Manager', {})
  File "acq4\Manager.py", line 512, in loadModule
    mod = modclass(self, name, config)
  File "acq4\modules\Manager\Manager.py", line 41, in __init__
    printExc("Error while creating dock for device '%s':" % d)


  File "acq4\util\debug.py", line 19, in printExc
    acq4.Manager.logExc(msg=msg, msgType=msgType)
------- exception caught ---------->

  File "acq4\modules\Manager\Manager.py", line 23, in __init__
    dw = self.manager.getDevice(d).deviceInterface(self)
  File "acq4\devices\Camera\Camera.py", line 299, in deviceInterface
    return CameraDeviceGui(self, win)
  File "acq4\devices\Camera\deviceGUI.py", line 46, in __init__
    if type(mx) in [int, long] and type(mn) in [int, long]:

mmcamera.py

Luke Campagnola

unread,
Mar 16, 2016, 1:51:20 AM3/16/16
to acq4
Thanks! 
This should all be fixed in the latest on github. Let me know if you come across cameras that still give you trouble.

Reply all
Reply to author
Forward
0 new messages