[ome-users] Running Bio-Formats from a plugin

Jean-Marie Burel (Staff) j.burel at dundee.ac.uk
Tue Jun 30 16:05:37 BST 2015


Dear Ved

This is due to a threading issue
When your frame is displayed and you click on the button,
 you are "blocking"  the UI when Bio-Formats is reading the file.

If you do not invoke Bio-Formats in the UI thread, you should see the same performance
For demo


public void actionPerformed(ActionEvent e) {

        Thread queryThread = new Thread() {

            public void run() {

                IJ.run("Bio-Formats Importer", "open=[d:\\Users\\ved\\Test\\image.dv] autoscale color_mode=Default split_channels view=[Standard ImageJ] stack_order=Default");

            }

          };

          queryThread.start();



    }


Cheers

Jmarie

From: "Ved P. Sharma" <vedsharma at gmail.com<mailto:vedsharma at gmail.com>>
Reply-To: "ved.sharma at gmail.com<mailto:ved.sharma at gmail.com>" <ved.sharma at gmail.com<mailto:ved.sharma at gmail.com>>, OME User Support List <ome-users at lists.openmicroscopy.org.uk<mailto:ome-users at lists.openmicroscopy.org.uk>>
Date: Friday, 26 June 2015 18:51
To: "Balaji Ramalingam (Staff)" <b.ramalingam at dundee.ac.uk<mailto:b.ramalingam at dundee.ac.uk>>
Cc: OME User Support List <ome-users at lists.openmicroscopy.org.uk<mailto:ome-users at lists.openmicroscopy.org.uk>>
Subject: Re: [ome-users] Running Bio-Formats from a plugin

Dear Balaji,

I think the ActionListener in my plugin is slowing the BF Importer. Take a look at a sample code below. The first call to BF importer from inside BF_plugin() opens image quickly but when I press the "open image" button, it takes 5-10 sec to open the same image. Any thoughts on why ActionListener is slowing things down and how to remedy this?

Thanks,

Ved


// ******************* plugin starts here ****************************
import ij.plugin.frame.*;
import java.awt.event.*;
import ij.*;
import ij.gui.*;
import javax.swing.*;

public class BF_plugin extends PlugInFrame implements ActionListener {
    private JPanel panel;
    public BF_plugin() {
        super("BF_plugin");
        panel = new JPanel();
        JButton b = new JButton("open image");
        b.addActionListener(this);
        panel.add(b);
        add(panel);
        pack();
        GUI.center(this);
        setVisible(true);
        IJ.run("Bio-Formats Importer", "open=[d:\\Users\\ved\\Test\\image.dv] autoscale color_mode=Default split_channels view=[Standard ImageJ] stack_order=Default");
    }
    public void actionPerformed(ActionEvent e) {
        IJ.run("Bio-Formats Importer", "open=[d:\\Users\\ved\\Test\\image.dv] autoscale color_mode=Default split_channels view=[Standard ImageJ] stack_order=Default");
    }
}
// ******************* plugin ends here ****************************


On Fri, Jun 26, 2015 at 10:33 AM, Balaji Ramalingam (Staff) <b.ramalingam at dundee.ac.uk<mailto:b.ramalingam at dundee.ac.uk>> wrote:
Hi,

Thank you for reporting your issue.
It would be great if you could expand the "options" that were used to open the image within the plugin.

Could you please check the following,

  1.  open ImageJ. Go to Plugins->Macro-> Record
  2.  In the Macro Recorder window , please use the drop down menu for "Record" and select "Java" as the option.
  3.  Repeat the Manual workflow described in your post (which opens the file within a fraction of a second).This will record the api method call , in the Recorder window.
  4.  And check if the "options" in your plugin, matches the "options" in the Macro Recorder, for the IJ.Run method.

If they match, there should be no difference in terms of performance in the import call.
Please let us know, if you find otherwise.

Best,
Balaji

__________________

Mr Balaji Ramalingam

Software Developer

OME Team

College of Life Sciences

University of Dundee

From: "Ved P. Sharma" <vedsharma at gmail.com<mailto:vedsharma at gmail.com>>
Reply-To: "ved.sharma at gmail.com<mailto:ved.sharma at gmail.com>" <ved.sharma at gmail.com<mailto:ved.sharma at gmail.com>>, OME User Support List <ome-users at lists.openmicroscopy.org.uk<mailto:ome-users at lists.openmicroscopy.org.uk>>
Date: Thursday, 25 June 2015 20:11
To: "ome-users at lists.openmicroscopy.org.uk<mailto:ome-users at lists.openmicroscopy.org.uk>" <ome-users at lists.openmicroscopy.org.uk<mailto:ome-users at lists.openmicroscopy.org.uk>>
Subject: [ome-users] Running Bio-Formats from a plugin

Hi,

When I run Bio-Formats Importer from ImageJ, it opens an image file of size ~ 20MB within a fraction of a second. When I open the same image file by calling Bio-Formats Importer from inside a plugin using IJ.run("Bio-Formats Importer", "options"), it takes a long time to open the file (~ 10 sec). It starts with a white background and then after about ~5-10 seconds, the image is displayed. Can anybody tell me what am I doing wrong when calling BF Importer from inside a plugin?

System info: I have ImageJ 1.49v running on WIndows 7, 64-bit computer and I have installed bioformats_package.jar (ver 5.1.2) in the plugins folder of ImageJ.

Thanks,

Ved

_________________________________
Ved P. Sharma, PhD
Dept. of Anatomy and Structural Biology
Albert Einstein College of Medicine
Bronx, NY 10461


The University of Dundee is a registered Scottish Charity, No: SC015096


The University of Dundee is a registered Scottish Charity, No: SC015096
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-users/attachments/20150630/d0e89787/attachment.html>


More information about the ome-users mailing list