MMStartup.bsh in MM2

Hello, I’m upgrading a system from MM1.4 to MM2. I need to set the camera settings (in particular the ROI, which cannot be set within a “config preset”) automatically at initialisation. In MM1.4, I used this MMStartup.bsh script and it worked perfectly:

mmc.loadSystemConfiguration("C:/Users/max/ConfigurationFile.cfg");
mmc.setProperty("Grasshopper3 GS3-U3-91S6M", "Binning", "Mode1");
mmc.setExposure(3);
mmc.setROI(406,238,934,936);

I know the syntax changed in MM2. In particular, mmc is probably not correct. I tried core but without success. I read the documentation about scripting with MM2, but I cannot find the proper way to write this MMStartup.bsh file.
Thanks a lot for your help,
Max

Hi @MaxDeforet,

mmc is the name for the core in the Micro-Manager script panel. When you run this script from the Script Panel, what errors do you get?

It works when I run this script from the Script Panel, there is no error message. The exposure time and binning mode were changed in the main window.

(However, when I pressed “snap”, MM crashed and quit, but that’s a recurrent bug with Spinnaker device adapter for FLIR cameras, ROI setting is very unstable, even when it’s done manually by drawing a rectangle and clicking the ROI button: MM often crashed when “snap” is pressed.)

So, it works when you run it from the Script panel, but not when you run it as a startup script? I forgot about the timing of the startup script, especially if it is run before or after loading the hardware configuration file. If it is after, you would not need to load the configuration. If it is before, then your approach will not work in any case, since the hardware will be re-loaded and the changes in settings you made will be lost. What exactly goes wrong when you run this as the startup script?

When this code is run as a startup script, ImageJ starts, I select the configuration file, I see the message “Loading…” then it crashes entirely (ImageJ quits).
I had a look at the log: it first loads the configuration file, then runs MMstartup.bsh, unloads everything, and tries load the camera again. The last line of the log is:

Will load device Grasshopper3 GS3-U3-91S6M from SpinnakerCamera

Following your suggestion, I deleted the first line of the script (which loads the configuration file) and now it works: MM starts and binning mode/exposure are correctly set.
Unfortunately, MM still crashes when I press snap, but that’s related to an issue with ROI and Spinnaker. I’m going to start another thread for this specific question.