Call additional scripts from within a script

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Call additional scripts from within a script

Then,Patrick // Leibniz-IPHT
Hello,


I'm currently experimenting with scripting in Micro-Manager through use of the MMStartup.bsh script.

What I want to do is call MM from some external program and start an multi-dimensional acquisition.

This works so far by just putting everything directly into the startup script.

Ideally, however, I want to expand it a bit by splitting the script into several parts containing different actions to be performed, which I would previously manipulate externally, e.g. through a Python or Labview programm.

The problem is that even when I use the startup script to call a very simple script like the one below ( by 'run("..\\settings.bsh")';):


exposure=20;
mmc.setExposure(exposure);


I get an error

"Line 55: run-time error : Sourced file: ..\settings.bsh : Attempt to resolve method: setExposure() on undefined variable or class name: mmc"


Can somebody help me understand what's going wrong here?

If I run the script directly, it will do what I expect it to do - set the exposure to 20ms. Yet calling it from within another script will prevent it from recognizing the mmc class for some reason.

Do I need to import some class specifically? Or need to set some working directory?

Of course I could potentially just read settings from some external txt file, instead of splitting it into several scripts, if all else fails.


Also, I really appreciate the hard work behind MM and would like to thank the people involved with it, but are there any plans to expand/rework the documentation?

Especially advanced things like scripting and programming MM are documented poorly at times and rather disjointed.


Best regards,

Pat


_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Call additional scripts from within a script

tron
Then,Patrick // Leibniz-IPHT @ 30/03/2020 16:33 -0300 dixit:
> The problem is that even when I use the startup script to call a very simple script like the one below ( by 'run("..\\settings.bsh")';):

This is, I guess, because you are running the script without context
when you "run" it, and so there is no mmc there.

Try "sourcing" it (i.e. interpret it in th current context) by:

       
this.interpreter.source("..\\settings.bsh");

-Carlos

--
Carlos G Mendioroz  <[hidden email]>


_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
--
Carlos G Mendioroz
Reply | Threaded
Open this post in threaded view
|

Re: Call additional scripts from within a script

Nico Stuurman-2
In reply to this post by Then,Patrick // Leibniz-IPHT
Hi Pat,
> I'm currently experimenting with scripting in Micro-Manager through use of the MMStartup.bsh script.
>
> What I want to do is call MM from some external program and start an multi-dimensional acquisition.

If  you want to control MM from Python, please do have a look at the new
ZMQ server and Pygellan (https://github.com/henrypinkard/Pygellan).

> Also, I really appreciate the hard work behind MM and would like to thank the people involved with it, but are there any plans to expand/rework the documentation?
>
> Especially advanced things like scripting and programming MM are documented poorly at times and rather disjointed.

Yes, an overhaul of the website is planned. There is clearly a problem
with documentation lagging development, and having the documentation for
two different versions not clearly separated.  For Java 2.0
documentation, please look at:
https://micro-manager.org/wiki/Version_2.0, for C++/core documentation,
most of the material in
https://micro-manager.org/wiki/Micro-Manager_Programming_Guide is still
appropriate.

If there are specific omissions/things hard to understand/follow, please
let it be known, and/or update them yourself (request an account here:
https://micro-manager.org/wiki/Special:RequestAccount).


Best,


Nico




_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Call additional scripts from within a script

Then,Patrick // Leibniz-IPHT
Hi Nico,

I have taken a look at Pygellan and will start playing around with it a bit.
It definitely looks interesting!
Thank's for the info.

As for contributing to the documentation:
I'll gladly do so if I ever reach a level of experience with MM which allows me to do so.
As of now, any programming and scripting related to MM for me is made up of much guesswork.
Sometimes it works, more often not. It surely doesn't help that I have not much experience with Java and haven't used it in years.
What would help me (and maybe other newcomers) might be having very short code examples for the various different methods described in the API, or maybe some kind of basic guide of how to use them (e.g. there's the alert manager  - how do I actually get MM to signal an alert now?).
The exampe scripts help a lot, but only go so far, since they don't cover many things.

Best regards,
Patrick



________________________________________
Von: Nico Stuurman <[hidden email]>
Gesendet: Dienstag, 31. März 2020 00:00
An: Micro-Manager General
Betreff: Re: [micro-manager-general] Call additional scripts from within a script

Hi Pat,
> I'm currently experimenting with scripting in Micro-Manager through use of the MMStartup.bsh script.
>
> What I want to do is call MM from some external program and start an multi-dimensional acquisition.

If  you want to control MM from Python, please do have a look at the new
ZMQ server and Pygellan (https://github.com/henrypinkard/Pygellan).

> Also, I really appreciate the hard work behind MM and would like to thank the people involved with it, but are there any plans to expand/rework the documentation?
>
> Especially advanced things like scripting and programming MM are documented poorly at times and rather disjointed.

Yes, an overhaul of the website is planned. There is clearly a problem
with documentation lagging development, and having the documentation for
two different versions not clearly separated.  For Java 2.0
documentation, please look at:
https://micro-manager.org/wiki/Version_2.0, for C++/core documentation,
most of the material in
https://micro-manager.org/wiki/Micro-Manager_Programming_Guide is still
appropriate.

If there are specific omissions/things hard to understand/follow, please
let it be known, and/or update them yourself (request an account here:
https://micro-manager.org/wiki/Special:RequestAccount).


Best,


Nico




_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general


_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Call additional scripts from within a script

Nico Stuurman-2
Hi Patrick,

> As for contributing to the documentation:
> I'll gladly do so if I ever reach a level of experience with MM which allows me to do so.
> As of now, any programming and scripting related to MM for me is made up of much guesswork.

Very much understood.
> Sometimes it works, more often not. It surely doesn't help that I have not much experience with Java and haven't used it in years.
> What would help me (and maybe other newcomers) might be having very short code examples for the various different methods described in the API, or maybe some kind of basic guide of how to use them (e.g. there's the alert manager  - how do I actually get MM to signal an alert now?).
> The exampe scripts help a lot, but only go so far, since they don't cover many things.

Conversely, please keep a list of the things you are looking for or
things that do not work.  The more specific and defined, the better. 
You could keep that list in an issue on github, or post here on
occasion.  Posting questions here is also helpful (when the answers is
obvious, I and others tend to answer reasonably fast).

Best,

Nico




_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general