<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
Hi,</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<span style="white-space: pre-wrap;">Your problem seems to be related to the search for Images by bio-formats(loci-tools), within your target directory (imagePath).</span></div>
<div>
<pre style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; word-wrap: break-word; white-space: pre-wrap;">This is how the algorithm works in bio-formats,</pre>
<ol>
<li>
<pre style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; word-wrap: break-word; white-space: pre-wrap;">The target directory(imagePath) is searched for all ‘bioformats-readable’ images.</pre>
<pre style="word-wrap: break-word;"><font face="Calibri,sans-serif"><span style="font-size: 14px; white-space: pre-wrap;">-This is the very first step and this is where you are facing problems, I am assuming that you’re ‘</span></font><font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size: 15px; white-space: pre-wrap;">imagePath’, is a top directory which has images at various depth’s. The default folder-depth at which bio-formats searches is 4 (I.e, it might still be searching for 4 sub-level folder’s within the top directory, unless specified).</span></font></pre>
</li></ol>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<span class="Apple-tab-span" style="white-space:pre"></span>    - The easy alternative is to pre list all the
<span style="font-weight: bold;">RVG</span> format files within the ‘imagePath' (using file-system search), and read them one at a time
<span class="Apple-tab-span" style="white-space:pre"></span>    <span class="Apple-tab-span" style="white-space:pre">
</span>(iteratively). I.e imagePath == “Path to an individual image”.</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<span class="Apple-tab-span" style="white-space:pre"></span>       This basically removes the bio-formats intelligence of grouping similar files (files part of a stack,etc). Am assuming that should not be  a
<span class="Apple-tab-span" style="white-space:pre"></span>   <span class="Apple-tab-span" style="white-space:pre">
</span>problem in your case .</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<span class="Apple-tab-span" style="white-space:pre"></span>2.  <span style="font-family: Calibri, Verdana, Helvetica, Arial; font-size: 15px;">The other alternative is to use the ImagePlusReader instead of the ImageProcessor as suggested in the code, but this
 needs testing <span class="Apple-tab-span" style="white-space:pre"></span>    <span class="Apple-tab-span" style="white-space:pre">
</span>and playing around. </span></div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<span style="font-family: Calibri, Verdana, Helvetica, Arial; font-size: 15px;"><br>
</span></div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<span style="font-family: Calibri, Verdana, Helvetica, Arial; font-size: 15px;"><span class="Apple-tab-span" style="white-space:pre"></span></span>Quoting from the “ImageProcessorReader.java" code ,</div>
<div>
<ul style="font-family: Calibri, sans-serif; font-size: 14px;">
<li>
<pre style="word-wrap: break-word; white-space: pre-wrap;">A low-level reader for {@link ij.process.ImageProcessor} objects.
 * For a higher-level reader that returns {@link ij.ImagePlus} objects,
 * see {@link loci.plugins.in.ImagePlusReader} instead.</pre>
</li></ul>
</div>
<div><font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size: 15px;"><br>
</span></font></div>
<div><font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size: 15px;">Please do let us know, how it goes.</span></font></div>
<div><font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size: 15px;"><br>
</span></font></div>
<div><font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size: 15px;">Best,</span></font></div>
<div><font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size: 15px;">Balaji</span></font></div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<br>
</div>
<span id="OLK_SRC_BODY_SECTION" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">
<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>Mohammad Samarah <<a href="mailto:isamarah@mac.com">isamarah@mac.com</a>><br>
<span style="font-weight:bold">Reply-To: </span>"<a href="mailto:msamarah@alumni.fit.edu">msamarah@alumni.fit.edu</a>" <<a href="mailto:msamarah@alumni.fit.edu">msamarah@alumni.fit.edu</a>><br>
<span style="font-weight:bold">Date: </span>Saturday, 22 March 2014 03:36<br>
<span style="font-weight:bold">To: </span>"<a href="mailto:ome-users@lists.openmicroscopy.org.uk">ome-users@lists.openmicroscopy.org.uk</a>" <<a href="mailto:ome-users@lists.openmicroscopy.org.uk">ome-users@lists.openmicroscopy.org.uk</a>><br>
<span style="font-weight:bold">Subject: </span>[ome-users] ImageProcessorReader.setId performance<br>
</div>
<div><br>
</div>
<div>
<title>ImageProcessorReader.setId performance</title>
<div><font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size:10.5pt">We are using loci_tools.jar to read radiographs in RVG format and extract a thumbnail JPEG image. All works as expected, however if the image in question is in a directory whose
 parent directory contains several thousands subfolders, then the ImageProcesserReader takes minutes to complete the setId() method. Please see attached code. The same image placed in a folder with its parent directory having much fewer subfolders works with
 no delay. This behavior can also be seen when using loci_tools.jar UI to open the same image. The issue does not seem to be related to the image itself but rather the fact that the containing folder is a child of a directory with thousands of subfolders. Could
 you please point us to how we can resolve this issue.<br>
<br>
Many thanks for your help,<br>
<br>
--<br>
M. Samarah<br>
<a href="msamarah@alumni.fit.edu">msamarah@alumni.fit.edu</a></span></font><font face="Times New Roman"><span style="font-size:12pt"><br>
</span></font><font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size:11pt"><br>
 <br>
private ImagePlus readDicomImage(String imagePath)<br>
    {<br>
        ImagePlus imp            = null;<br>
        ImagePlus colorizedImage = null;<br>
        <br>
        ImageProcessorReader r = new ImageProcessorReader(new ChannelSeparator(LociPrefs.makeImageReader()));<br>
        try<br>
        {<br>
            log_message("INFO: Examining file " + imagePath);<br>
<br>
            // the next line takes 10 to 20 minutes to complete when parent folder contains 4000+ subfolders. It takes no time when parent folder has 100 subfolders<br>
            <font color="#FF0000">r.setId(imagePath);<br>
</font><br>
            log_message("INFO: Setting file path " + imagePath);<br>
            int num = r.getImageCount();<br>
            log_message("INFO: Image count is" + num);<br>
            int width = r.getSizeX();<br>
            int height = r.getSizeY();<br>
            log_message("INFO: Image Width %d Height %d", width, height);<br>
            ImageStack stack = new ImageStack(width, height);<br>
            log_message("INFO: After constructing image stack");<br>
            byte[][][] lookupTable = new byte[r.getSizeC()][][];<br>
            log_message("INFO: After Allocating memmory for image");<br>
            for (int i=0; i<num; i++) <br>
            {<br>
                ImageProcessor ip = r.openProcessors(i)[0];<br>
                stack.addSlice("" + (i + 1), ip);<br>
                int channel = r.getZCTCoords(i)[1];<br>
                lookupTable[channel] = r.get8BitLookupTable();<br>
            }<br>
            log_message("INFO: After constructing lookup table");<br>
            log_message("INFO:Constructing image");<br>
            imp = new ImagePlus("Dicom", stack);<br>
               <br>
            colorizedImage = applyLookupTables(r, imp, lookupTable);<br>
            r.close();<br>
<br>
        }<br>
        catch(Exception exc)<br>
        {<br>
           log_message("ERROR an error occurred: " + exc.getMessage());<br>
        }<br>
       return colorizedImage;       <br>
    }<br>
<br>
<font color="#FF0000">Example: Takes 10 to 20 minutes on an 8 core machine with 24GB of memory to complete setId method<br>
</font></span></font>
<blockquote><font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt"><font color="#FF0000">Data <folder><br>
</font></span></font>
<blockquote><font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt"><font color="#FF0000">0001 <folder><br>
0002 <folder><br>
0003 <folder><br>
...<br>
1000 <folder><br>
1001 <folder><br>
</font></span></font>
<blockquote><font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt"><font color="#FF0000">File R1.RVG<br>
</font></span></font></blockquote>
<font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt"><font color="#FF0000">...<br>
4000 <folder><br>
</font></span></font></blockquote>
</blockquote>
<font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size:11pt"><br>
<font color="#008000">Example: Works with no delay<br>
</font></span></font>
<blockquote><font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt"><font color="#008000">Data <folder><br>
</font></span></font>
<blockquote><font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt"><font color="#008000">0001 <folder><br>
0002 <folder><br>
0003 <folder><br>
...<br>
0050 <folder><br>
0051 <folder><br>
</font></span></font>
<blockquote><font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt"><font color="#008000">File R1.RVG<br>
</font></span></font></blockquote>
<font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt"><font color="#008000">...<br>
00080 <folder><br>
</font></span></font></blockquote>
</blockquote>
<font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size:11pt"><br>
<br>
</span></font></div>
</div>
</span><br>
<span style="font-size:10pt;">The University of Dundee is a registered Scottish Charity, No: SC015096</span>
</body>
</html>