Get Projector Plugin Calibration

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

Get Projector Plugin Calibration

Bruno
Hi all!

I have a Mosaic3 device and I can calibrate it with the Projector plugin.
I was wondering if it is possible to download the calibration file, so the
mapping between camera and SLM device, so that I can use it for data
analysis or for MATLAB control.

Thanks!
Best!

Bruno.



--
Sent from: http://micro-manager.3463995.n2.nabble.com/

------------------------------------------------------------------------------
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
Reply | Threaded
Open this post in threaded view
|

Re: Get Projector Plugin Calibration

Nico Stuurman-2
Hi Bruno,

> I have a Mosaic3 device and I can calibrate it with the Projector plugin.
> I was wondering if it is possible to download the calibration file, so
> the
> mapping between camera and SLM device, so that I can use it for data
> analysis or for MATLAB control.

Calibration data are stored as a series of affine transforms (each one
local to a certain region of the image) in the Java layer. Exact storage
differs between MM 1.4, 2.0-beta, and 2.0-gamma, so to help you, we will
need to know which version you are using.

Best,

Nico

------------------------------------------------------------------------------
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
Reply | Threaded
Open this post in threaded view
|

Re: Get Projector Plugin Calibration

Bruno
Hi Nico

Thanks a lot for your reply. 
I'm on Micro Manager 1.4.23 

Thanks!
Bruno

On Tue, Jul 17, 2018, 19:14 Nico Stuurman <[hidden email]> wrote:
Hi Bruno,

> I have a Mosaic3 device and I can calibrate it with the Projector plugin.
> I was wondering if it is possible to download the calibration file, so
> the
> mapping between camera and SLM device, so that I can use it for data
> analysis or for MATLAB control.

Calibration data are stored as a series of affine transforms (each one
local to a certain region of the image) in the Java layer. Exact storage
differs between MM 1.4, 2.0-beta, and 2.0-gamma, so to help you, we will
need to know which version you are using.

Best,

Nico

------------------------------------------------------------------------------
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

------------------------------------------------------------------------------
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
Reply | Threaded
Open this post in threaded view
|

Re: Get Projector Plugin Calibration

Nico Stuurman-2
On 7/17/18 10:27 AM, Bruno Scocozza wrote:

>
> On Tue, Jul 17, 2018, 19:14 Nico Stuurman <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>
>     > I have a Mosaic3 device and I can calibrate it with the
>     Projector plugin.
>     > I was wondering if it is possible to download the calibration
>     file, so
>     > the
>     > mapping between camera and SLM device, so that I can use it for data
>     > analysis or for MATLAB control.
>
>     Calibration data are stored as a series of affine transforms (each
>     one
>     local to a certain region of the image) in the Java layer. Exact
>     storage
>     differs between MM 1.4, 2.0-beta, and 2.0-gamma, so to help you,
>     we will
>     need to know which version you are using.
>
>
> Thanks a lot for your reply.
> I'm on Micro Manager 1.4.23

The code that generates the calibration is in the plugin code
org.micromanager.ProjectorControlForm.  The mapping is a
HashMap<Polygon, AffineTransform>.  It is saved in the function
"saveMapping".  That function (on line 396) puts the calibration object
into the Java Preferences as an object with a key that includes the name
of the channel and camera.

Java Preferences are eventually stored on disk (in a directory that
depends on your operating system).  However, it would be easier to write
beanshell code to get to the actual affine transforms and their
locations.  It will not be very straight forward, and quite a bit of
work.  I also have no idea what form you need the affine transforms to
do anything useful in Matlab.

Things may be a bit easier in 2.0-gamma.  That code has a Mapping class
with static accessor functions that you can ask for the calibration
map.  You will  get it as a Java Map<Polygon, AffineTransform>, but you
should be able to write that to something you can work with Matlab using
a Beanshell script.

Best,

Nico




------------------------------------------------------------------------------
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
Reply | Threaded
Open this post in threaded view
|

Re: Get Projector Plugin Calibration

Bruno
Thanks a lot Nico.

So just like the registration plugin does in Fiji, where one can save the transformation matrix, I would just like to get the values of the transformation matrix.
Since I have made in MATLAB my own ROI selection tool, and I need to transform back and forth from the Camera to the Mosaic, then I would use in matlab affine2d.
So I guess all I need to extract are 4 numbers for the matrix. I am not familiar with Java so why do you say it will be not straight forward?

Thanks!
Bruno.


On Tue, Jul 17, 2018 at 7:59 PM Nico Stuurman <[hidden email]> wrote:
On 7/17/18 10:27 AM, Bruno Scocozza wrote:
>
> On Tue, Jul 17, 2018, 19:14 Nico Stuurman <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>
>     > I have a Mosaic3 device and I can calibrate it with the
>     Projector plugin.
>     > I was wondering if it is possible to download the calibration
>     file, so
>     > the
>     > mapping between camera and SLM device, so that I can use it for data
>     > analysis or for MATLAB control.
>
>     Calibration data are stored as a series of affine transforms (each
>     one
>     local to a certain region of the image) in the Java layer. Exact
>     storage
>     differs between MM 1.4, 2.0-beta, and 2.0-gamma, so to help you,
>     we will
>     need to know which version you are using.
>
>
> Thanks a lot for your reply.
> I'm on Micro Manager 1.4.23

The code that generates the calibration is in the plugin code
org.micromanager.ProjectorControlForm.  The mapping is a
HashMap<Polygon, AffineTransform>.  It is saved in the function
"saveMapping".  That function (on line 396) puts the calibration object
into the Java Preferences as an object with a key that includes the name
of the channel and camera.

Java Preferences are eventually stored on disk (in a directory that
depends on your operating system).  However, it would be easier to write
beanshell code to get to the actual affine transforms and their
locations.  It will not be very straight forward, and quite a bit of
work.  I also have no idea what form you need the affine transforms to
do anything useful in Matlab.

Things may be a bit easier in 2.0-gamma.  That code has a Mapping class
with static accessor functions that you can ask for the calibration
map.  You will  get it as a Java Map<Polygon, AffineTransform>, but you
should be able to write that to something you can work with Matlab using
a Beanshell script.

Best,

Nico




------------------------------------------------------------------------------
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

------------------------------------------------------------------------------
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
Reply | Threaded
Open this post in threaded view
|

Re: Get Projector Plugin Calibration

Bruno
Hi Nico,

Toghether with a colleague we have tried the following  code, but looks like there are no keys in the HashMap since the print(keys.size()); yields 0.
Maybe we are doing something wrong?

Thanks in advance!
Bruno.

__________________________________________
import org.micromanager.utils.JavaUtils;
import org.micromanager.projector.ProjectorPlugin;
import java.util.prefs.Preferences;
import java.awt.Polygon;
import java.awt.geom.AffineTransform;
import java.util.HashMap;

Preferences prefs = Preferences.userNodeForPackage(ProjectorPlugin.class);
String[] childs = prefs.childrenNames();
for (int i = 0; i < childs.length; i++)
print(childs[i]);
HashMap mapping = (Map) JavaUtils.getObjectFromPrefs(prefs,"calibration",new HashMap());
Set keys = mapping.keySet();
print(keys.size());
__________________________________________  


On Wed, Jul 18, 2018 at 12:05 PM Bruno Scocozza <[hidden email]> wrote:
Thanks a lot Nico.

So just like the registration plugin does in Fiji, where one can save the transformation matrix, I would just like to get the values of the transformation matrix.
Since I have made in MATLAB my own ROI selection tool, and I need to transform back and forth from the Camera to the Mosaic, then I would use in matlab affine2d.
So I guess all I need to extract are 4 numbers for the matrix. I am not familiar with Java so why do you say it will be not straight forward?

Thanks!
Bruno.


On Tue, Jul 17, 2018 at 7:59 PM Nico Stuurman <[hidden email]> wrote:
On 7/17/18 10:27 AM, Bruno Scocozza wrote:
>
> On Tue, Jul 17, 2018, 19:14 Nico Stuurman <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>
>     > I have a Mosaic3 device and I can calibrate it with the
>     Projector plugin.
>     > I was wondering if it is possible to download the calibration
>     file, so
>     > the
>     > mapping between camera and SLM device, so that I can use it for data
>     > analysis or for MATLAB control.
>
>     Calibration data are stored as a series of affine transforms (each
>     one
>     local to a certain region of the image) in the Java layer. Exact
>     storage
>     differs between MM 1.4, 2.0-beta, and 2.0-gamma, so to help you,
>     we will
>     need to know which version you are using.
>
>
> Thanks a lot for your reply.
> I'm on Micro Manager 1.4.23

The code that generates the calibration is in the plugin code
org.micromanager.ProjectorControlForm.  The mapping is a
HashMap<Polygon, AffineTransform>.  It is saved in the function
"saveMapping".  That function (on line 396) puts the calibration object
into the Java Preferences as an object with a key that includes the name
of the channel and camera.

Java Preferences are eventually stored on disk (in a directory that
depends on your operating system).  However, it would be easier to write
beanshell code to get to the actual affine transforms and their
locations.  It will not be very straight forward, and quite a bit of
work.  I also have no idea what form you need the affine transforms to
do anything useful in Matlab.

Things may be a bit easier in 2.0-gamma.  That code has a Mapping class
with static accessor functions that you can ask for the calibration
map.  You will  get it as a Java Map<Polygon, AffineTransform>, but you
should be able to write that to something you can work with Matlab using
a Beanshell script.

Best,

Nico




------------------------------------------------------------------------------
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

------------------------------------------------------------------------------
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
Reply | Threaded
Open this post in threaded view
|

Re: Get Projector Plugin Calibration

Nico Stuurman-2
Hi Bruno,

>
> Toghether with a colleague we have tried the following code, but looks
> like there are no keys in the HashMap since the print(keys.size());
> yields 0.
> Maybe we are doing something wrong?
>
> Thanks in advance!
> Bruno.
>
> __________________________________________
> import org.micromanager.utils.JavaUtils;
> import org.micromanager.projector.ProjectorPlugin;
> import java.util.prefs.Preferences;
> import java.awt.Polygon;
> import java.awt.geom.AffineTransform;
> import java.util.HashMap;
>
> Preferences prefs = Preferences.userNodeForPackage(ProjectorPlugin.class);
> String[] childs = prefs.childrenNames();
> for (int i = 0; i < childs.length; i++)
> print(childs[i]);
> HashMap mapping = (Map)
> JavaUtils.getObjectFromPrefs(prefs,"calibration",new HashMap());
> Set keys = mapping.keySet();
> print(keys.size());
> __________________________________________
>

In MM 1.4, the calibration gets stored on line 397 of
ProjectorControlForm.java as follows: "
       JavaUtils.putObjectInPrefs(getCalibrationNode(), dev_.getName(),
mapping);"
where:
- getCalibrationNode() looks like:
         return Preferences.userNodeForPackage(ProjectorPlugin.class)
                     .node("calibration")
                     .node(dev_.getChannel())
                     .node(core_.getCameraDevice());
dev_.getName() is the name of your DMD device.

It would be easiest if you can get your hands on the instance of
ProjectorControlForm, and then use the (private) loadMapping function.

Again, things are easier in Micro-Manager 2.0-gamma, since there are
static accessor functions.


Best,


Nico



------------------------------------------------------------------------------
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