Steps to get a functional plugin, lesson n+1

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

Steps to get a functional plugin, lesson n+1

tron
I'm modifying the example plugin, and as I need to get hold of a display
(to determine a ROI set) I decided to try:


   @Subscribe
   public void onNewDisplay(NewDisplayEvent event) {
           title.setText("We have an image to work with!");
   }

after making "title" a class variable much like the example's
exposureTimeLabel_.

As far as I understand the documentation, I should be getting an event
(and title should change) when a display window is created by, e.g., a
new snap.

But it does not work.

Nico ? Anybody ?

--
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: Steps to get a functional plugin, lesson n+1

Sunil
Hi Carlos,

Have you done this:

Studio.events().registerForEvents(this);

in the class where you have the @Subscribe?

Regards,
Sunil

-----Original Message-----
From: Carlos G Mendioroz [mailto:[hidden email]]
Sent: 06 April 2020 21:16
To: Micro-Manager General <[hidden email]>
Subject: [micro-manager-general] Steps to get a functional plugin, lesson n+1


*******************
This email originates from outside Imperial. Do not click on links and attachments unless you recognise the sender.
If you trust the sender, add them to your safe senders list https://spam.ic.ac.uk/SpamConsole/Senders.aspx to disable email stamping for this address.
*******************
I'm modifying the example plugin, and as I need to get hold of a display (to determine a ROI set) I decided to try:


   @Subscribe
   public void onNewDisplay(NewDisplayEvent event) {
           title.setText("We have an image to work with!");
   }

after making "title" a class variable much like the example's exposureTimeLabel_.

As far as I understand the documentation, I should be getting an event (and title should change) when a display window is created by, e.g., a new snap.

But it does not work.

Nico ? Anybody ?

--
Carlos G Mendioroz  <[hidden email]>


_______________________________________________
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: Steps to get a functional plugin, lesson n+1

Nico Stuurman-2
In reply to this post by tron
Hi Carlos,

On 4/6/2020 1:15 PM, Carlos G Mendioroz wrote:

> I'm modifying the example plugin, and as I need to get hold of a display
> (to determine a ROI set) I decided to try:
>
>
>     @Subscribe
>     public void onNewDisplay(NewDisplayEvent event) {
>   title.setText("We have an image to work with!");
>     }
>
> after making "title" a class variable much like the example's
> exposureTimeLabel_.
>
> As far as I understand the documentation, I should be getting an event
> (and title should change) when a display window is created by, e.g., a
> new snap.
>
> But it does not work.

Looking into this, it turns out that the NewDisplayEvent is not
implemented, and is never generated.  It either was never implemented,
or was lost in refactoring.  I asked the architect (Mark) for directions.

Looked around for alternatives, but nothing pops up.  Certainly looks
like we need to fix this!

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: Steps to get a functional plugin, lesson n+1

tron
Yes, I did a whole workspace search on uM and there is no
NewDisplayEvent implementation :(

It is proving difficult to start when an API example is not implemented :)

I did not see an easy way to get a new MDA step done event either... so
I guess I will have to implement the whole acquisition control logic ?
Or ask for a new event be created...

-Carlos


Nico Stuurman @ 06/04/2020 21:11 -0300 dixit:

> Hi Carlos,
>
> On 4/6/2020 1:15 PM, Carlos G Mendioroz wrote:
>> I'm modifying the example plugin, and as I need to get hold of a display
>> (to determine a ROI set) I decided to try:
>>
>>
>>     @Subscribe
>>     public void onNewDisplay(NewDisplayEvent event) {
>>        title.setText("We have an image to work with!");
>>     }
>>
>> after making "title" a class variable much like the example's
>> exposureTimeLabel_.
>>
>> As far as I understand the documentation, I should be getting an event
>> (and title should change) when a display window is created by, e.g., a
>> new snap.
>>
>> But it does not work.
>
> Looking into this, it turns out that the NewDisplayEvent is not
> implemented, and is never generated.  It either was never implemented,
> or was lost in refactoring.  I asked the architect (Mark) for directions.
>
> Looked around for alternatives, but nothing pops up.  Certainly looks
> like we need to fix this!
>
> Best,
>
> Nico
>
>
>
>
> _______________________________________________
> micro-manager-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/micro-manager-general

--
Carlos G Mendioroz  <[hidden email]>  LW7 EQI  Argentina

--
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: Steps to get a functional plugin, lesson n+1

Nico Stuurman-2
In reply to this post by Nico Stuurman-2
Hi Carlos,

On 4/6/2020 5:18 PM, Carlos G Mendioroz wrote:
> It is proving difficult to start when an API example is not implemented :)

Agreed!

I don't want to rush through this implementation, as I want to get
Mark's thoughts on what this should look like.

In the mean time, you could add a button that gets the active DataViewer:

studio_.displays().getActiveDataViewer();

and take it from there.

Best,

Nico

>
> I did not see an easy way to get a new MDA step done event either... so
> I guess I will have to implement the whole acquisition control logic ?
> Or ask for a new event be created...
>
> -Carlos
>
>
> Nico Stuurman @ 06/04/2020 21:11 -0300 dixit:
>> Hi Carlos,
>>
>> On 4/6/2020 1:15 PM, Carlos G Mendioroz wrote:
>>> I'm modifying the example plugin, and as I need to get hold of a display
>>> (to determine a ROI set) I decided to try:
>>>
>>>
>>>      @Subscribe
>>>      public void onNewDisplay(NewDisplayEvent event) {
>>>         title.setText("We have an image to work with!");
>>>      }
>>>
>>> after making "title" a class variable much like the example's
>>> exposureTimeLabel_.
>>>
>>> As far as I understand the documentation, I should be getting an event
>>> (and title should change) when a display window is created by, e.g., a
>>> new snap.
>>>
>>> But it does not work.
>> Looking into this, it turns out that the NewDisplayEvent is not
>> implemented, and is never generated.  It either was never implemented,
>> or was lost in refactoring.  I asked the architect (Mark) for directions.
>>
>> Looked around for alternatives, but nothing pops up.  Certainly looks
>> like we need to fix this!
>>
>> Best,
>>
>> Nico
>>
>>
>>
>>
>> _______________________________________________
>> micro-manager-general mailing list
>> [hidden email]
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.sourceforge.net_lists_listinfo_micro-2Dmanager-2Dgeneral&d=DwIDaQ&c=iORugZls2LlYyCAZRB3XLg&r=UwP8SWqih8VHO1LwZpgcx83I4o21yLj6V6QD-25Dt4I&m=6GuJnANG_0c-Re6WVZcB5mQAT6viGaBB6gXR84rbx-8&s=_ZOh7WeTxp32ZcB_H_wonRqQz26Kq9DEkj0twobn7Bs&e=



_______________________________________________
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: Steps to get a functional plugin, lesson n+1

tron
Nico,

Nico Stuurman @ 07/04/2020 00:36 -0300 dixit:
> In the mean time, you could add a button that gets the active DataViewer:
>
> studio_.displays().getActiveDataViewer();
>
> and take it from there.

Ok, I've defined my plan for the time being:
1- get hold of a field image
        do a snap, get its image.
        Working!

2- get hold of a ROI set
        via mm.displays().getCurrentWindow().getImagePlus().getRoi()
        Also working! (I even check that the ROI is actually defined)

3- get intensities of acquisition images and plot them

Here, I was hoping to be informed using DataProviderHasNewImageEvent.
But my first try did not work.

I'm doing:

      // Run an acquisition using the current MDA parameters.
      acquireButton_ = new JButton("Run Acquisition");
      acquireButton_.addActionListener(new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
            // All GUI event handlers are invoked on the EDT (Event Dispatch
            // Thread). Acquisitions are not allowed to be started from the
            // EDT. Therefore we must make a new thread to run this.
            Thread acqThread = new Thread(new Runnable() {
               @Override
               public void run() {
                  ds_ = studio_.acquisitions().runAcquisition();
                  ds_.registerForEvents(me);
               }
            });
            acqThread.start();
         }
      });

where "me" is a reference to the Frame instance, and there:

   @Subscribe
   public void onNewImage(DataProviderHasNewImageEvent event) {
           imagesReceived_++;
           title.setText("We have an image to work with!");
   }

I'm not getting along this bus thing.
Help ?



>> I did not see an easy way to get a new MDA step done event either... so
>> I guess I will have to implement the whole acquisition control logic ?
>> Or ask for a new event be created...
>>
>> -Carlos
>>
>>
>> Nico Stuurman @ 06/04/2020 21:11 -0300 dixit:
>>> Hi Carlos,
>>>
>>> On 4/6/2020 1:15 PM, Carlos G Mendioroz wrote:
>>>> I'm modifying the example plugin, and as I need to get hold of a
>>>> display
>>>> (to determine a ROI set) I decided to try:
>>>>
>>>>
>>>>      @Subscribe
>>>>      public void onNewDisplay(NewDisplayEvent event) {
>>>>         title.setText("We have an image to work with!");
>>>>      }
>>>>
>>>> after making "title" a class variable much like the example's
>>>> exposureTimeLabel_.
>>>>
>>>> As far as I understand the documentation, I should be getting an event
>>>> (and title should change) when a display window is created by, e.g., a
>>>> new snap.
>>>>
>>>> But it does not work.
>>> Looking into this, it turns out that the NewDisplayEvent is not
>>> implemented, and is never generated.  It either was never implemented,
>>> or was lost in refactoring.  I asked the architect (Mark) for
>>> directions.
>>>
>>> Looked around for alternatives, but nothing pops up.  Certainly looks
>>> like we need to fix this!
>>>
>>> Best,
>>>
>>> Nico
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> micro-manager-general mailing list
>>> [hidden email]
>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.sourceforge.net_lists_listinfo_micro-2Dmanager-2Dgeneral&d=DwIDaQ&c=iORugZls2LlYyCAZRB3XLg&r=UwP8SWqih8VHO1LwZpgcx83I4o21yLj6V6QD-25Dt4I&m=6GuJnANG_0c-Re6WVZcB5mQAT6viGaBB6gXR84rbx-8&s=_ZOh7WeTxp32ZcB_H_wonRqQz26Kq9DEkj0twobn7Bs&e=
>>>
>
>
>
> _______________________________________________
> micro-manager-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/micro-manager-general

--
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: Steps to get a functional plugin, lesson n+1

Nico Stuurman-2
Hi Carlos,

On 4/7/2020 3:00 PM, Carlos G Mendioroz wrote:

> Here, I was hoping to be informed using DataProviderHasNewImageEvent.
> But my first try did not work.
>
> I'm doing:
>
>        // Run an acquisition using the current MDA parameters.
>        acquireButton_ = new JButton("Run Acquisition");
>        acquireButton_.addActionListener(new ActionListener() {
>           @Override
>           public void actionPerformed(ActionEvent e) {
>              // All GUI event handlers are invoked on the EDT (Event Dispatch
>              // Thread). Acquisitions are not allowed to be started from the
>              // EDT. Therefore we must make a new thread to run this.
>              Thread acqThread = new Thread(new Runnable() {
>                 @Override
>                 public void run() {
>                    ds_ = studio_.acquisitions().runAcquisition();
>                    ds_.registerForEvents(me);
>                 }
>              });
>              acqThread.start();
>           }
>        });
>
> where "me" is a reference to the Frame instance, and there:
>
>     @Subscribe
>     public void onNewImage(DataProviderHasNewImageEvent event) {
>   imagesReceived_++;
>   title.setText("We have an image to work with!");
>     }
>
> I'm not getting along this bus thing.
> Help ?


Change:

ds_ = studio_.acquisitions().runAcquisition();

to:

ds_ = studio_.acquisitions().runAcquisitionNonBlocking();

Your current code registers the datastore to the Eventbus only after the
acquisition finished, hence your code never received a
DataProvierHasNewImageEvent.

Thanks for exercising the API!


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: Spam (12.588):Re: Steps to get a functional plugin, lesson n+1

tron
Nico Stuurman @ 08/04/2020 17:27 -0300 dixit:

> Change:
>
> ds_ = studio_.acquisitions().runAcquisition();
>
> to:
>
> ds_ = studio_.acquisitions().runAcquisitionNonBlocking();
>
> Your current code registers the datastore to the Eventbus only after the
> acquisition finished, hence your code never received a
> DataProvierHasNewImageEvent.
>

Ah, right, never thought of that! I'm trying not to run Micro-Manager in
my work desktop, but that is proving to be a problem for debugging.

> Thanks for exercising the API!

You are very welcome. Thank you for your time.

>
> Best,
>
> Nico
>

--
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: Spam (12.588):Re: Steps to get a functional plugin, lesson n+1

tron
In reply to this post by Nico Stuurman-2
Allmost there.
I've have steps 1, 2 & 3 working, but for a minor thing: intensity
values are not right.

I was hoping to use ImageJ stuff to do the calculations (so it is easy
to update, upgrade, whatever) but as noted in another message, the
liaison is complicated...

My point drawing code now looks like:

  @Subscribe
  public void onNewImage(DataProviderHasNewImageEvent event) {
    imagesReceived_++;
    if (skip_ != 0 && imagesReceived_ % (skip_+1) != 1)
      return; // 1Hz max
    double v;
    title.setText("You should be seeing data on the plot.");
    image_ = studio_.displays().getAllImageWindows().get(0).getImagePlus();
    for (int i = 0; i < ROIs_-1; i++) {
      image_.getProcessor().setRoi(roi_[i]);
      v = image_.getProcessor().getStats().mean;
      data[i].add((double)imagesReceived_, v, false);
    }
    image_.getProcessor().setRoi(roi_[ROIs_ - 1]);
    v = image_.getProcessor().getStats().mean;
    data[ROIs_ - 1].add((double)imagesReceived_, v, true);
   }
 }

data[] are the JFreeChart data series corresponding to preset ROIs.
skip_ is use to control refresh rate, not to create 100 pps (points per
second) :)

But the problem is that imagej processor is returning the same value
always. I'm refreshing the reference at each NewImage event and still.
Even different ROIs return the same value for mean, which clearly should
not be.

Should I forget about ImageJ ? That does not sound right though.

Nico ? Mark ?

--
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: Spam (12.588):Re: Steps to get a functional plugin, lesson n+1

Nico Stuurman-2
Hi Carlos,

Allmost there.
I've have steps 1, 2 & 3 working, but for a minor thing: intensity
values are not right.

That sounds like real progress!

I was hoping to use ImageJ stuff to do the calculations (so it is easy
to update, upgrade, whatever) but as noted in another message, the
liaison is complicated...

My point drawing code now looks like:

  @Subscribe
  public void onNewImage(DataProviderHasNewImageEvent event) {
    imagesReceived_++;
    if (skip_ != 0 && imagesReceived_ % (skip_+1) != 1)
      return; // 1Hz max
    double v;
    title.setText("You should be seeing data on the plot.");
    image_ = studio_.displays().getAllImageWindows().get(0).getImagePlus();
    for (int i = 0; i < ROIs_-1; i++) {
      image_.getProcessor().setRoi(roi_[i]);
      v = image_.getProcessor().getStats().mean;
      data[i].add((double)imagesReceived_, v, false);
    }
    image_.getProcessor().setRoi(roi_[ROIs_ - 1]);
    v = image_.getProcessor().getStats().mean;
    data[ROIs_ - 1].add((double)imagesReceived_, v, true);
   }
 }

data[] are the JFreeChart data series corresponding to preset ROIs.
skip_ is use to control refresh rate, not to create 100 pps (points per
second) :)

Haven't looked at this directly, but it seems safer to use the event directly to get the image:

image = event.getImage();

You can then

studio_.ij().createProcessor(image)

to get the ImageJ ImageProcessor, and get the stats from there.

At the surface, looks similar to what you have, but avoids calling the deprecated DisplayWindow.getImagePlus(), which has the scary looking javadoc:

 @deprecated Directly accessing the {@code ImagePlus} of an MMStudio
 * display window will generally result in very fragile code. Consider
 * accessing image data through {@link #getDataProvider}. For drawing
 * overlay graphics, see {@link #addOverlay}.
 */
@Deprecated
public ImagePlus getImagePlus();


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: Spam (8.588):Re: Spam (12.588):Re: Steps to get a functional plugin, lesson n+1

tron
Nico Stuurman @ 09/04/2020 18:23 -0300 dixit:

> Haven't looked at this directly, but it seems safer to use the event
> directly to get the image:
>
> image = event.getImage();
>
> You can then
>
> studio_.ij().createProcessor(image)
>
> to get the ImageJ ImageProcessor, and get the stats from there.
>
> At the surface, looks similar to what you have, but avoids calling the
> deprecated DisplayWindow.getImagePlus(), which has the scary looking
> javadoc:
>

Wow, that works. Not bad, thanks.
You may take it for a ride :) Work in progress, but useful state, I
guess. Is it ok to post here the jar ? Sources ? 22k for the jar, 15k
for 2 .java source files.

--
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: Spam (8.588):Re: Spam (12.588):Re: Steps to get a functional plugin, lesson n+1

Nico Stuurman-2
Hi Carlos,
> Wow, that works. Not bad, thanks.
> You may take it for a ride :) Work in progress, but useful state, I
> guess. Is it ok to post here the jar ? Sources ? 22k for the jar, 15k
> for 2 .java source files.

Doubtful that the jar will make it through email.  If you have someplace
that you can provide it link to, that would be great, you can include
the sources in your email, or put them in a public place such as a
github repository.

It would be ideal to fork the micro-manager github repository, since
that would let you generate a pull request, making it easy to add your
code to Micro-Manager.

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: Spam (8.588):Re: Spam (12.588):Re: Steps to get a functional plugin, lesson n+1

tron
Nico Stuurman @ 10/04/2020 00:36 -0300 dixit:

> Hi Carlos,
>> Wow, that works. Not bad, thanks.
>> You may take it for a ride :) Work in progress, but useful state, I
>> guess. Is it ok to post here the jar ? Sources ? 22k for the jar, 15k
>> for 2 .java source files.
>
> Doubtful that the jar will make it through email.  If you have someplace
> that you can provide it link to, that would be great, you can include
> the sources in your email, or put them in a public place such as a
> github repository.
>
> It would be ideal to fork the micro-manager github repository, since
> that would let you generate a pull request, making it easy to add your
> code to Micro-Manager.

Ok, I will. I'm a little rusty in uploading to a code repo, but will do.
In the mean time, here is a link for you (or anybody else) to try:

        https://www.dropbox.com/s/63w8556u6dxj4vp/RTIntensities.jar?dl=0

Couple of things missing to make it a real usefull tool though:

* marking on the window.
Something that has bothered me, but not much, is a bluish rectangle that
uM puts in the data window. I don't know where it comes from, nor what
it represent. But trying to use the ImageJ processor to mark the ROIs
did not work.

        processor.setLineWidth(1);
        processor.setColor(Color.red);

        processor.setRoi(roi_[i]);
        v = processor.getStats().mean;
        data[i].add((double)imagesReceived_, v, false);
        processor.draw(roi_[i]);

That, or drawRoi(), do not make it.

* ROI set saving.
The ROI set should go into the datastore somehow, so the data can be
reproduced afterwards. I have't looked at that part yet, but I'm trying
to maximize the SNR of this message :)

TIA,

--
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: Spam (8.588):Re: Spam (12.588):Re: Steps to get a functional plugin, lesson n+1

PAVAK SHAH-3
Hi Carlos,

Are you talking about the rectangle in the upper left corner of the image? That may just be the indicator that the window the image is displayed in is too small for the display scaling of the image. Try hitting the buttons that make the image display larger and smaller in the corner of the display window and it should go away once the window is properly resized. 

Pavak

On Fri, Apr 10, 2020, 4:57 AM Carlos G Mendioroz <[hidden email]> wrote:
Nico Stuurman @ 10/04/2020 00:36 -0300 dixit:
> Hi Carlos,
>> Wow, that works. Not bad, thanks.
>> You may take it for a ride :) Work in progress, but useful state, I
>> guess. Is it ok to post here the jar ? Sources ? 22k for the jar, 15k
>> for 2 .java source files.
>
> Doubtful that the jar will make it through email.  If you have someplace
> that you can provide it link to, that would be great, you can include
> the sources in your email, or put them in a public place such as a
> github repository.
>
> It would be ideal to fork the micro-manager github repository, since
> that would let you generate a pull request, making it easy to add your
> code to Micro-Manager.

Ok, I will. I'm a little rusty in uploading to a code repo, but will do.
In the mean time, here is a link for you (or anybody else) to try:

        https://www.dropbox.com/s/63w8556u6dxj4vp/RTIntensities.jar?dl=0

Couple of things missing to make it a real usefull tool though:

* marking on the window.
Something that has bothered me, but not much, is a bluish rectangle that
uM puts in the data window. I don't know where it comes from, nor what
it represent. But trying to use the ImageJ processor to mark the ROIs
did not work.

        processor.setLineWidth(1);
        processor.setColor(Color.red);

        processor.setRoi(roi_[i]);
        v = processor.getStats().mean;
        data[i].add((double)imagesReceived_, v, false);
        processor.draw(roi_[i]);

That, or drawRoi(), do not make it.

* ROI set saving.
The ROI set should go into the datastore somehow, so the data can be
reproduced afterwards. I have't looked at that part yet, but I'm trying
to maximize the SNR of this message :)

TIA,

--
Carlos G Mendioroz  <[hidden email]>


_______________________________________________
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: Spam (10.598):Re: Spam (8.588):Re: Spam (12.588):Re: Steps to get a functional plugin, lesson n+1

tron
Yes, that one.
Aha, now I get it. It is kind of wierd because the MDA default window
for the demo camera (512x512) always opens with that, but is fully
viewable. Should be a corner case. And as it does not display two
borders, just one, its meaning was not obvious to me.

Thanks.

PAVAK SHAH @ 10/04/2020 10:33 -0300 dixit:

> Hi Carlos,
>
> Are you talking about the rectangle in the upper left corner of the
> image? That may just be the indicator that the window the image is
> displayed in is too small for the display scaling of the image. Try
> hitting the buttons that make the image display larger and smaller in
> the corner of the display window and it should go away once the window
> is properly resized. 
>
> Pavak
>
> On Fri, Apr 10, 2020, 4:57 AM Carlos G Mendioroz <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Nico Stuurman @ 10/04/2020 00:36 -0300 dixit:
>     > Hi Carlos,
>     >> Wow, that works. Not bad, thanks.
>     >> You may take it for a ride :) Work in progress, but useful state, I
>     >> guess. Is it ok to post here the jar ? Sources ? 22k for the jar, 15k
>     >> for 2 .java source files.
>     >
>     > Doubtful that the jar will make it through email.  If you have
>     someplace
>     > that you can provide it link to, that would be great, you can include
>     > the sources in your email, or put them in a public place such as a
>     > github repository.
>     >
>     > It would be ideal to fork the micro-manager github repository, since
>     > that would let you generate a pull request, making it easy to add your
>     > code to Micro-Manager.
>
>     Ok, I will. I'm a little rusty in uploading to a code repo, but will do.
>     In the mean time, here is a link for you (or anybody else) to try:
>
>             https://www.dropbox.com/s/63w8556u6dxj4vp/RTIntensities.jar?dl=0
>
>     Couple of things missing to make it a real usefull tool though:
>
>     * marking on the window.
>     Something that has bothered me, but not much, is a bluish rectangle that
>     uM puts in the data window. I don't know where it comes from, nor what
>     it represent. But trying to use the ImageJ processor to mark the ROIs
>     did not work.
>
>             processor.setLineWidth(1);
>             processor.setColor(Color.red);
>
>             processor.setRoi(roi_[i]);
>             v = processor.getStats().mean;
>             data[i].add((double)imagesReceived_, v, false);
>             processor.draw(roi_[i]);
>
>     That, or drawRoi(), do not make it.
>
>     * ROI set saving.
>     The ROI set should go into the datastore somehow, so the data can be
>     reproduced afterwards. I have't looked at that part yet, but I'm trying
>     to maximize the SNR of this message :)
>
>     TIA,
>
>     --
>     Carlos G Mendioroz  <[hidden email] <mailto:[hidden email]>>
>
>
>     _______________________________________________
>     micro-manager-general mailing list
>     [hidden email]
>     <mailto:[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
>

--
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: Steps to get a functional plugin, lesson n+1

Nico Stuurman-2
On 4/10/2020 6:49 AM, Carlos G Mendioroz wrote:
> Yes, that one.
> Aha, now I get it. It is kind of wierd because the MDA default window
> for the demo camera (512x512) always opens with that, but is fully
> viewable. Should be a corner case. And as it does not display two
> borders, just one, its meaning was not obvious to me.


Annoying issue: https://github.com/micro-manager/micro-manager/issues/238

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: Spam (8.588):Re: Spam (12.588):Re: Steps to get a functional plugin, lesson n+1

Nico Stuurman-2
In reply to this post by tron
Hi Carlos,

> a friendly reminder that I got stuck on a couple of issues on the last
> thread.

No worries, did not realize that it was my turn. Ccing the mailing list.

>
>> Couple of things missing to make it a real usefull tool though:
>>
>> * marking on the window.
>> Something that has bothered me, but not much, is a bluish rectangle that
>> uM puts in the data window. I don't know where it comes from, nor what
>> it represent. But trying to use the ImageJ processor to mark the ROIs
>> did not work.
>>
>> processor.setLineWidth(1);
>> processor.setColor(Color.red);
>>
>> processor.setRoi(roi_[i]);
>> v = processor.getStats().mean;
>> data[i].add((double)imagesReceived_, v, false);
>> processor.draw(roi_[i]);
>>
>> That, or drawRoi(), do not make it.

This is drawn by mageJ, to indicate that you are (slightly) zoomed in
and can pan the image around. It is a known bug that is hard to solve,
see: https://github.com/micro-manager/micro-manager/issues/238.

>> * ROI set saving.
>> The ROI set should go into the datastore somehow, so the data can be
>> reproduced afterwards. I have't looked at that part yet, but I'm trying
>> to maximize the SNR of this message :)

You will need to add these to the metadata.  This goes something like:

Metadata md = image.getMetadata();
PropertyMap.Builder pMapBuilder = md.getUserData().getCopyBuilder();
pMapBuilder.putRectangleList("YourKey",
ListofYourRoisTransformedToRectangles);
newMd =
md.copyBuilderPreservingUUID().userData(pMapBuilder.build()).build();
Image storeThisOne = image.copyWithMetadat(newMd);

Typing this without IDE, so doubtlessly errors.  This is a bit
complicated, but the design has the advantage that each object is
immutable.

Hope it makes sense!


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: Spam (8.588):Re: Spam (12.588):Re: Steps to get a functional plugin, lesson n+1

tron
Nico Stuurman @ 16/04/2020 12:41 -0300 dixit:

> Hi Carlos,
>
>> a friendly reminder that I got stuck on a couple of issues on the last
>> thread.
>
> No worries, did not realize that it was my turn. Ccing the mailing list.
>
>>
>>> Couple of things missing to make it a real usefull tool though:
>>>
>>> * marking on the window.
>>> Something that has bothered me, but not much, is a bluish rectangle that
>>> uM puts in the data window. I don't know where it comes from, nor what
>>> it represent. But trying to use the ImageJ processor to mark the ROIs
>>> did not work.
>>>
>>>     processor.setLineWidth(1);
>>>     processor.setColor(Color.red);
>>>
>>>     processor.setRoi(roi_[i]);
>>>     v = processor.getStats().mean;
>>>     data[i].add((double)imagesReceived_, v, false);
>>>     processor.draw(roi_[i]);
>>>
>>> That, or drawRoi(), do not make it.
>
> This is drawn by mageJ, to indicate that you are (slightly) zoomed in
> and can pan the image around. It is a known bug that is hard to solve,
> see: https://github.com/micro-manager/micro-manager/issues/238.

No, I should not have mixed my comment there...
My issue is that I want to show the ROIs in the display, and that the
code that I thought would do it, does not.

>>> * ROI set saving.
>>> The ROI set should go into the datastore somehow, so the data can be
>>> reproduced afterwards. I have't looked at that part yet, but I'm trying
>>> to maximize the SNR of this message :)
>
> You will need to add these to the metadata.  This goes something like:
>
> Metadata md = image.getMetadata();
> PropertyMap.Builder pMapBuilder = md.getUserData().getCopyBuilder();
> pMapBuilder.putRectangleList("YourKey",
> ListofYourRoisTransformedToRectangles);
> newMd =
> md.copyBuilderPreservingUUID().userData(pMapBuilder.build()).build();
> Image storeThisOne = image.copyWithMetadat(newMd);
>
> Typing this without IDE, so doubtlessly errors.  This is a bit
> complicated, but the design has the advantage that each object is
> immutable.
>
> Hope it makes sense!

It will (make sense :)

Will ImageJ be able to understand those tags afterwards ?

Tks,
--
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: Spam (8.588):Re: Spam (12.588):Re: Steps to get a functional plugin, lesson n+1

Nico Stuurman-2
Hi Carlos,

Finally got around playing with your plugin.  The idea is really nice,
but I quickly run into problems, and was never able to get a plot of a
time-lapse.  Specifically:

2020-04-21T15:56:41.089398 tid12468 [IFO,App] java.lang.NullPointerException
2020-04-21T15:56:41.089398 tid12468 [IFO,App]   at
org.micromanager.plugins.rtintensities.RTIntensitiesFrame$4$1.run(RTIntensitiesFrame.java:177)
2020-04-21T15:56:41.089398 tid12468 [IFO,App]   at
java.lang.Thread.run(Thread.java:748)

Also, it would be nice if ROI intensity plotting was available for a
live window.

Does the plugin work with images with multiple channels?

Is there a way of getting the intensity data out (copying to the
clipboard or saving)?
> My issue is that I want to show the ROIs in the display, and that the
> code that I thought would do it, does not.

That may be harder than it should be.  MM handles the display an
overlays, so most likely, the ImageJ way to draw ROIs no longer works in
the MM display.  Looks for Overlay plugins in the MM source code.

> Will ImageJ be able to understand those tags afterwards ?

No, ImageJ may (or may not?) have its own way of saving ROIs in images. 
The Micro-Manager API has no access to those.  However, your plugin
could look for those tags in open Micro-Manager datasets, and
reconstruct the ROIs.


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: Spam (8.588):Re: Spam (12.588):Re: Steps to get a functional plugin, lesson n+1

tron
Hey Nico,

Nico Stuurman @ 21/04/2020 20:05 -0300 dixit:

> Hi Carlos,
>
> Finally got around playing with your plugin.  The idea is really nice,
> but I quickly run into problems, and was never able to get a plot of a
> time-lapse.  Specifically:
>
> 2020-04-21T15:56:41.089398 tid12468 [IFO,App]
> java.lang.NullPointerException
> 2020-04-21T15:56:41.089398 tid12468 [IFO,App]   at
> org.micromanager.plugins.rtintensities.RTIntensitiesFrame$4$1.run(RTIntensitiesFrame.java:177)
>
> 2020-04-21T15:56:41.089398 tid12468 [IFO,App]   at
> java.lang.Thread.run(Thread.java:748)

That's ... unexpected.
That line is (AFAIK):

 if (studio.acquisitions().getAcquisitionSettings().intervalMs < 1000) {

Code has just started a new acquisition (by pressing the plugin's "Run
Acquisition") and is accessing the MDA period to "dampen" the refresh
cycle if frequency > 1Hz. I did not expect intervalMs to be null.

This or I've changed the code between my publishing it and now, which I
don't recall but it could be. I should start versioning... (In fact I
have already, but do not know if published jar corresponds to latest)


>
> Also, it would be nice if ROI intensity plotting was available for a
> live window.

Noted. I do not have knowledge of actual usage, but I can imagine that
seeing the evolution of intensities in some ROIs "just to get an idea"
could be useful.

>
> Does the plugin work with images with multiple channels?
>

Nope, it could. In that case it would be nice to have an obvious
relation between corresponding lines (may be same color dotted?), and
different scales ? But I would need some sense of usefulness from
someone to work in that.

> Is there a way of getting the intensity data out (copying to the
> clipboard or saving)?


THIS question I got from the guy I'm helping, and it actually confused
me. The DATA is in the images, the plot is only showing it. All you
would need to reproduce the plot is to document the ROIs, and that's why
I would like to embedd that info in the image set.
Afterwards, there are tons of tools to do other analysis and pretier
graphs and...


>> My issue is that I want to show the ROIs in the display, and that the
>> code that I thought would do it, does not.
>
> That may be harder than it should be.  MM handles the display an
> overlays, so most likely, the ImageJ way to draw ROIs no longer works in
> the MM display.  Looks for Overlay plugins in the MM source code.

Ah, this seems my mantra. It seems I got it wrong when I thought that
Micro-Manager used ImageJ for all analysis. There there is a ROI Manager
and I thought a ROI set could be easily embedded in an Image set.
Sounded like the logical way to documenting things.

>
>> Will ImageJ be able to understand those tags afterwards ?
>
> No, ImageJ may (or may not?) have its own way of saving ROIs in images. 
> The Micro-Manager API has no access to those.  However, your plugin
> could look for those tags in open Micro-Manager datasets, and
> reconstruct the ROIs.

Yep, what I thought ROI Manager would do.

>
>
> Best,
>
>
> Nico
>
Thanks,

--
--
Carlos G Mendioroz  <[hidden email]>


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