<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>Dear Ved</div>
<div><br>
</div>
<div>This is due to a threading issue</div>
<div>When your frame is displayed and you click on the button,</div>
<div> you are “blocking” the UI when Bio-Formats is reading the file. </div>
<div><br>
</div>
<div>If you do not invoke Bio-Formats in the UI thread, you should see the same performance</div>
<div>For demo</div>
<div><br>
</div>
<div>
<p style="margin: 0px; font-size: 11px; font-family: Monaco;"><span style="color: #931a68">public</span>
<span style="color: #931a68">void</span> actionPerformed(ActionEvent <span style="color: #7e504f">
e</span>) {</p>
<p style="margin: 0px; font-size: 11px; font-family: Monaco;"> Thread <span style="color: #7e504f">
queryThread</span> = <span style="color: #931a68">new</span> Thread() {</p>
<p style="margin: 0px; font-size: 11px; font-family: Monaco;"> <span style="color: #931a68">
public</span> <span style="color: #931a68">void</span> run() {</p>
<p style="margin: 0px; font-size: 11px; font-family: Monaco;"> <span style="font-family: Calibri, sans-serif; font-size: 14px;"> </span><span style="font-family: Calibri, sans-serif; font-size: 14px;">IJ.run("Bio-Formats Importer", "open=[d:\\Users\\ved\\Test\\image.dv]
autoscale color_mode=Default split_channels view=[Standard ImageJ] stack_order=Default");</span></p>
<p style="margin: 0px; font-size: 11px; font-family: Monaco;"> }</p>
<p style="margin: 0px; font-size: 11px; font-family: Monaco;"> };</p>
<p style="margin: 0px; font-size: 11px; font-family: Monaco;"> <span style="color: #7e504f">
queryThread</span>.start();</p>
<p style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;"> </p>
<p style="margin: 0px; font-size: 11px; font-family: Monaco;"> }</p>
<p style="margin: 0px; font-size: 11px; font-family: Monaco;"><br>
</p>
</div>
<div><br>
</div>
<div>Cheers</div>
<div><br>
</div>
<div>Jmarie</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>"Ved P. Sharma" <<a href="mailto:vedsharma@gmail.com">vedsharma@gmail.com</a>><br>
<span style="font-weight:bold">Reply-To: </span>"<a href="mailto:ved.sharma@gmail.com">ved.sharma@gmail.com</a>" <<a href="mailto:ved.sharma@gmail.com">ved.sharma@gmail.com</a>>, OME User Support List <<a href="mailto:ome-users@lists.openmicroscopy.org.uk">ome-users@lists.openmicroscopy.org.uk</a>><br>
<span style="font-weight:bold">Date: </span>Friday, 26 June 2015 18:51<br>
<span style="font-weight:bold">To: </span>"Balaji Ramalingam (Staff)" <<a href="mailto:b.ramalingam@dundee.ac.uk">b.ramalingam@dundee.ac.uk</a>><br>
<span style="font-weight:bold">Cc: </span>OME User Support List <<a href="mailto:ome-users@lists.openmicroscopy.org.uk">ome-users@lists.openmicroscopy.org.uk</a>><br>
<span style="font-weight:bold">Subject: </span>Re: [ome-users] Running Bio-Formats from a plugin<br>
</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr">
<div>
<div>Dear Balaji,<br>
<br>
</div>
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?<br>
<br>
</div>
<div>Thanks,<br>
<br>
</div>
<div>Ved<br>
<br>
</div>
<div><br>
</div>
// ******************* plugin starts here ****************************<br>
<div>import ij.plugin.frame.*;<br>
import java.awt.event.*;<br>
import ij.*;<br>
import ij.gui.*;<br>
import javax.swing.*;<br>
<br>
public class BF_plugin extends PlugInFrame implements ActionListener {<br>
private JPanel panel;<br>
public BF_plugin() {<br>
super("BF_plugin");<br>
panel = new JPanel();<br>
JButton b = new JButton("open image");<br>
b.addActionListener(this);<br>
panel.add(b);<br>
add(panel);<br>
pack();<br>
GUI.center(this);<br>
setVisible(true);<br>
IJ.run("Bio-Formats Importer", "open=[d:\\Users\\ved\\Test\\image.dv] autoscale color_mode=Default split_channels view=[Standard ImageJ] stack_order=Default");<br>
}<br>
public void actionPerformed(ActionEvent e) {<br>
IJ.run("Bio-Formats Importer", "open=[d:\\Users\\ved\\Test\\image.dv] autoscale color_mode=Default split_channels view=[Standard ImageJ] stack_order=Default");<br>
}<br>
}<br>
// ******************* plugin ends here ****************************<br>
<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Fri, Jun 26, 2015 at 10:33 AM, Balaji Ramalingam (Staff)
<span dir="ltr"><<a href="mailto:b.ramalingam@dundee.ac.uk" target="_blank">b.ramalingam@dundee.ac.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word;color:rgb(0,0,0);font-size:14px;font-family:Calibri,sans-serif">
<div>
<div>Hi,</div>
<div><br>
</div>
<div>Thank you for reporting your issue.</div>
<div>It would be great if you could expand the “options” that were used to open the image within the plugin. </div>
<div><br>
</div>
<div>Could you please check the following,</div>
<ol>
<li>open ImageJ. Go to Plugins—>Macro—> Record</li><li>In the Macro Recorder window , please use the drop down menu for “Record” and select “Java” as the option.</li><li>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.</li><li>And check if the “options” in your plugin, matches the “options” in the Macro Recorder, for the IJ.Run method.</li></ol>
<div>If they match, there should be no difference in terms of performance in the import call.</div>
<div>Please let us know, if you find otherwise.</div>
<div><br>
</div>
<div>Best,</div>
<div>Balaji</div>
<div>
<div><br>
</div>
<div>
<div style="color:rgb(40,40,40)"><span style="background-color:rgb(255,255,255)">__________________</span></div>
<div style="color:rgb(40,40,40)">
<p style="margin-top:0px;margin-bottom:0px">Mr Balaji Ramalingam</p>
<p style="margin-top:0px;margin-bottom:0px">Software Developer<br>
</p>
<p style="margin-top:0px;margin-bottom:0px">OME Team</p>
<p style="margin-top:0px;margin-bottom:0px">College of Life Sciences</p>
<p style="margin-top:0px;margin-bottom:0px">University of Dundee</p>
</div>
</div>
</div>
</div>
<div><br>
</div>
<span>
<div style="font-family:Calibri;font-size:11pt;text-align:left;color:black;BORDER-BOTTOM:medium none;BORDER-LEFT:medium none;PADDING-BOTTOM:0in;PADDING-LEFT:0in;PADDING-RIGHT:0in;BORDER-TOP:#b5c4df 1pt solid;BORDER-RIGHT:medium none;PADDING-TOP:3pt">
<span style="font-weight:bold">From: </span>"Ved P. Sharma" <<a href="mailto:vedsharma@gmail.com" target="_blank">vedsharma@gmail.com</a>><br>
<span style="font-weight:bold">Reply-To: </span>"<a href="mailto:ved.sharma@gmail.com" target="_blank">ved.sharma@gmail.com</a>" <<a href="mailto:ved.sharma@gmail.com" target="_blank">ved.sharma@gmail.com</a>>, OME User Support List <<a href="mailto:ome-users@lists.openmicroscopy.org.uk" target="_blank">ome-users@lists.openmicroscopy.org.uk</a>><br>
<span style="font-weight:bold">Date: </span>Thursday, 25 June 2015 20:11<br>
<span style="font-weight:bold">To: </span>"<a href="mailto:ome-users@lists.openmicroscopy.org.uk" target="_blank">ome-users@lists.openmicroscopy.org.uk</a>" <<a href="mailto:ome-users@lists.openmicroscopy.org.uk" target="_blank">ome-users@lists.openmicroscopy.org.uk</a>><br>
<span style="font-weight:bold">Subject: </span>[ome-users] Running Bio-Formats from a plugin<br>
</div>
<div>
<div>
<div><br>
</div>
<div>
<div>
<div dir="ltr">
<div>
<div>
<div>Hi,<br>
<br>
</div>
When I run <i>Bio-Formats Importer</i> 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
<i>Bio-Formats Importer</i> 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?<br>
<br>
<u>System info:</u> 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.
<br>
<br>
</div>
Thanks,<br>
<br>
</div>
Ved<br>
<br>
<font size="2">_________________________________<br>
Ved P. Sharma, PhD<br>
Dept. of Anatomy and Structural Biology <br>
Albert Einstein College of Medicine<br>
Bronx, NY 10461<br>
</font><br>
</div>
</div>
</div>
</div>
</div>
</span><br>
<span style="font-size:10pt">The University of Dundee is a registered Scottish Charity, No: SC015096</span></div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</span><br>
<span style="font-size:10pt;">The University of Dundee is a registered Scottish Charity, No: SC015096</span>
</body>
</html>