ImSwitch / ImSwitch

ImSwitch is a software solution in Python that aims at generalizing microscope control by providing a solution for flexible control of multiple microscope modalities.
https://imswitch.readthedocs.io/
GNU General Public License v3.0
70 stars 53 forks source link

'MockHamamatsu' object has no attribute 'sensor_size' #77

Closed jdmanton closed 3 years ago

jdmanton commented 3 years ago

Bug description My problems are actually two-fold, in that I can't get my Photometrics camera to work with ImSwitch, but that's secondary to this issue. ImSwitch starts and loads my configuration (below), fails to load the Photometrics camera and then falls back to the Hamamatsu mocker. Unfortunately, this also fails as MockHamamatsu has no sensor_size attribute.

How to reproduce Load ImSwitch with a hardware configuration that does not contain a camera that works, e.g.

{
    "detectors": {
        "Main": {
            "analogChannel": null,
            "digitalLine": null,
            "managerName": "PhotometricsManager",
            "managerProperties": {
                "cameraListIndex": 0
            },
            "forAcquisition": true
        }
    },
    "availableWidgets": [
        "Settings",
        "View",
        "Recording",
        "Image",
        "Scan"
    ]
}

Expected behavior ImSwitch should probably either complain that there's no camera, or successfully load a mock camera.

Screenshots Error log:

2021-09-20 17:14:39 INFO [main] Starting ImSwitch 1.2.1
visa.py:13: FutureWarning: The visa module provided by PyVISA is being deprecated. You can replace `import visa` by `import pyvisa as visa` to achieve the same effect.

The reason for the deprecation is the possible conflict with the visa package provided by the https://github.com/visa-sdk/visa-python which can result in hard to debug situations.
2021-09-20 17:14:43 DEBUG [ImConMainController] Initializing
2021-09-20 17:14:43 WARNING [PhotometricsManager -> Main] Failed to initialize Photometrics camera 0, loading mocker
2021-09-20 17:14:43 INFO [PhotometricsManager -> Main] Initialized camera, model:
2021-09-20 17:14:43 DEBUG [ImConMainController] Shutting down
2021-09-20 17:14:43 ERROR [ExceptionHandler] Traceback (most recent call last):
  File "imswitch\imcontrol\__init__.py", line 52, in getMainViewAndController
  File "imswitch\imcontrol\controller\ImConMainController.py", line 35, in __init__
  File "imswitch\imcontrol\controller\MasterController.py", line 28, in __init__
  File "imswitch\imcontrol\model\managers\DetectorsManager.py", line 21, in __init__
  File "imswitch\imcontrol\model\managers\MultiManager.py", line 22, in __init__
  File "imswitch\imcontrol\model\managers\detectors\PhotometricsManager.py", line 24, in __init__
AttributeError: 'MockHamamatsu' object has no attribute 'sensor_size'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "imswitch\imcontrol\controller\ImConMainController.py", line 135, in closeEvent
AttributeError: 'ImConMainController' object has no attribute '_ImConMainController__factory'

2021-09-20 17:14:43 ERROR [main] Failed to initialize module imcontrol
2021-09-20 17:14:43 ERROR [main] Traceback (most recent call last):
  File "imswitch\__main__.py", line 50, in main
  File "imswitch\imcontrol\__init__.py", line 55, in getMainViewAndController
  File "imswitch\imcontrol\__init__.py", line 52, in getMainViewAndController
  File "imswitch\imcontrol\controller\ImConMainController.py", line 35, in __init__
  File "imswitch\imcontrol\controller\MasterController.py", line 28, in __init__
  File "imswitch\imcontrol\model\managers\DetectorsManager.py", line 21, in __init__
  File "imswitch\imcontrol\model\managers\MultiManager.py", line 22, in __init__
  File "imswitch\imcontrol\model\managers\detectors\PhotometricsManager.py", line 24, in __init__
AttributeError: 'MockHamamatsu' object has no attribute 'sensor_size'

Environment

Additional context Add any other context about the problem here, if applicable.

xcasas commented 3 years ago

Hey @jdmanton, thank you for reporting the bug and trying the software out.

I think the problem here is that we don't have a MockPhotometrics, as MockHamamatsu is for Hamamatsu cameras when the camera initialization fails. The reason is that I don't own a Photometrics camera and we got a demo for one week, so I didn't have time to understand what parameters a mocker would require. I would suggest you can either change the manager to HamamatsuManager (in the configuration file) when you don't want to use the camera, or add the sensor_size parameter to the mocker. Then you can check if it works or it still needs other parameters and we can make then a PhotometricsMocker eventually.

But anyway, could you give more feedback in why the camera didn't work? Maybe I can help you in that since I also found some issues. Most likely is because I had to change the PyVCAM package (I forked it to my github user and created a new branch (https://github.com/kasasxav/PyVCAM/commits/threading-and-buffering) because I found some issues (https://github.com/Photometrics/PyVCAM/issues/18), especially when synchronizing the camera through an external trigger with other devices via the Nidaq, but maybe if you want to use it for simpler setups we can also find a way around with the original library.

xcasas commented 3 years ago

Hi @jdmanton, I confirm the issue is that the only manager that can be used without the camera is Hamamatsu because it's the only mocker we have implemented. If you want to talk more about why the Photometrics didn't work let me know but I will close this issue, for now, we will consider doing a mocker for Photometrics later on.

Focus2Focus commented 2 months ago

I have this same problem with ImSwitch, I need to work with a Photometrics Prime BSI camera. when I choose my configuration for the ImSwitch I get this AttributeError message !

xcasas commented 2 months ago

@Focus2Focus can you open a new issue and develop more about your problem? Copying the error message, is the camera on while you get the error, etc?