<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; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>Hi,</div>
<div><br>
</div>
<div>I missed a point in my previous message, turns out that the reader searches and ‘groups’ similar images (this is helpful in the case of stacks, etc). In your case turning that option ‘off’ might do the trick.</div>
<div><br>
</div>
<div>If you could add this call,</div>
<div>r.setGroupFiles(false)</div>
<div>Before the call,</div>
<div>R.setId(ImagePath)</div>
<div><br>
</div>
<div>Then that should do the trick.</div>
<div><br>
</div>
<div>Best,</div>
<div>Balaji</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>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>Tuesday, 25 March 2014 14:19<br>
<span style="font-weight:bold">To: </span>Balaji Ramalingam <<a href="mailto:b.ramalingam@dundee.ac.uk">b.ramalingam@dundee.ac.uk</a>>, "<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>Re: [ome-users] ImageProcessorReader.setId performance<br>
</div>
<div><br>
</div>
<div>
<title>Re: [ome-users] ImageProcessorReader.setId performance</title>
<div><font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size:11pt">Hi Balaji,<br>
<br>
Thanks for your insights. We examined the code more closely and through the debugger. We are passing a single full file path to the ImageProcesserReader.setId method. The case that fails specifies /images/001234/R1.RVG while the images folder has more than
 4000 sub-folders. We are able to make a workaround by means of copying the same file to /temp/images/001234/R1.RVG. Temp/images folder contains a small number of sub-folders. However this is not ideal as the copy takes time to complete given the size of the
 images being processed.<br>
<br>
You mentioned that the default folder-depth is 4. How do we change it to 1? Is there an API method to disable this behavior?
<br>
<br>
Many thanks for your help,<br>
<br>
--<br>
M. Samarah<br>
<a href="msamarah@alumni.fit.edu">msamarah@alumni.fit.edu</a><br>
<br>
<hr align="CENTER" size="3" width="95%">
<b>From: </b>Balaji Ramalingam <<a href="b.ramalingam@dundee.ac.uk">b.ramalingam@dundee.ac.uk</a>><br>
<b>Date: </b>Mon, 24 Mar 2014 10:42:02 +0000<br>
<b>To: </b>"<a href="msamarah@alumni.fit.edu">msamarah@alumni.fit.edu</a>" <<a href="msamarah@alumni.fit.edu">msamarah@alumni.fit.edu</a>>, "<a href="ome-users@lists.openmicroscopy.org.uk">ome-users@lists.openmicroscopy.org.uk</a>" <<a href="ome-users@lists.openmicroscopy.org.uk">ome-users@lists.openmicroscopy.org.uk</a>><br>
<b>Subject: </b>Re: [ome-users] ImageProcessorReader.setId performance<br>
<br>
Hi,<br>
<br>
Your problem seems to be related to the search for Images by bio-formats(loci-tools), within your target directory (imagePath).<br>
This is how the algorithm works in bio-formats,<br>
</span></font>
<ol>
<li><font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size:11pt">The target directory(imagePath) is searched for all ‘bioformats-readable’ images.
</span></font></li><li><font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size:11pt">-This is the very first step and this is where you are facing problems, I am assuming that you’re ‘</span><span style="font-size:11.5pt">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).<br>
</span></font></li></ol>
<font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size:10.5pt">   - The easy alternative is to pre list all the
<b>RVG</b> format files within the ‘imagePath' (using file-system search), and read them one at a time     (iteratively). I.e imagePath == “Path to an individual image”.<br>
       This basically removes the bio-formats intelligence of grouping similar files (files part of a stack,etc). Am assuming that should not be  a    problem in your case .<br>
<br>
2.  </span><span style="font-size:11.5pt">The other alternative is to use the ImagePlusReader instead of the ImageProcessor as suggested in the code, but this needs testing     and playing around.
<br>
<br>
</span><span style="font-size:10.5pt">Quoting from the “ImageProcessorReader.java" code ,<br>
</span></font>
<ul>
<li><font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size:10.5pt">A low-level reader for {@link ij.process.ImageProcessor} objects.
</span></font></li><li><font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size:10.5pt">* For a higher-level reader that returns {@link ij.ImagePlus} objects,
</span></font></li><li><font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size:10.5pt">* see {@link loci.plugins.in.ImagePlusReader} instead.<br>
</span></font></li></ul>
<font face="Calibri,Verdana,Helvetica,Arial"><span style="font-size:11.5pt"><br>
Please do let us know, how it goes.<br>
<br>
Best,<br>
Balaji<br>
</span><span style="font-size:10.5pt"><br>
<br>
<b>From: </b>Mohammad Samarah <<a href="isamarah@mac.com">isamarah@mac.com</a>><br>
<b>Reply-To: </b>"<a href="msamarah@alumni.fit.edu">msamarah@alumni.fit.edu</a>" <<a href="msamarah@alumni.fit.edu">msamarah@alumni.fit.edu</a>><br>
<b>Date: </b>Saturday, 22 March 2014 03:36<br>
<b>To: </b>"<a href="ome-users@lists.openmicroscopy.org.uk">ome-users@lists.openmicroscopy.org.uk</a>" <<a href="ome-users@lists.openmicroscopy.org.uk">ome-users@lists.openmicroscopy.org.uk</a>><br>
<b>Subject: </b>[ome-users] ImageProcessorReader.setId performance<br>
<br>
ImageProcessorReader.setId performance <br>
</span><font size="2"><span style="font-size:10pt">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><br>
</span></font><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>
<br>
</span><font size="2"><span style="font-size:10pt">The University of Dundee is a registered Scottish Charity, No: SC015096</span></font><span style="font-size:11pt"><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>