<html>
    <head>
      <base href="http://fiji.sc/bugzilla/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Multithreading problem in javascript macro"
   href="http://fiji.sc/bugzilla/show_bug.cgi?id=854">854</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Multithreading problem in javascript macro
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Fiji
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P4
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Plugins
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>imagej-bugs@imagej.net
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>thomas.siegmund@evotec.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>thomas.siegmund@evotec.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi,

I've a a javascript macro running multithreaded as described in 

<a href="http://fiji.sc/Multithreaded_Image_Processing_in_Javascript">http://fiji.sc/Multithreaded_Image_Processing_in_Javascript</a>.

The script analyzes several images in parallel. For each image it loops over a
few hundered cell clusters and analyzes the nuclei within using the
ParticleAnalyzer. Most of the code seems to work fine, but within these few
lines there is a problem:

// now count and measure nuclei within
var nucleiMeasurements = Measurements.AREA + Measurements.CIRCULARITY;
var rt_nuclei = new ResultsTable();
var nucleiPA = new ParticleAnalyzer(ParticleAnalyzer.SHOW_RESULTS +
ParticleAnalyzer.ADD_TO_MANAGER + ParticleAnalyzer.CLEAR_WORKSHEET,
nucleiMeasurements, rt_nuclei, nucleusMinSize, nucleusMaxSize,
nucleusMinRoundness, 1);
var nuclei_manager = new RoiManager(true); 
nucleiPA.setRoiManager(nuclei_manager);
nucleiPA.analyze(dapiImg);
IJ.log("rt: "+ rt_nuclei.getCounter() + " rm: " +  nuclei_manager.getCount());
var nNuclei = rt_nuclei.getCounter();
if(nNuclei != nuclei_manager.getCount()) {
     // this happens only if the script runs multithreaded. ???
     IJ.log("number of nuclei != number of ROIS !!!!: "+image+" "+i+", nNuclei
"+nNuclei+", nucleiRoisLength "+nuclei_manager.getCount());
}

Maybe I'm doing something stupid here, but it seems to work perfectly if
running single threaded. The number of ROIs in the manager is the same as the
number of entries in the results table. But whenever I run this multithreaded
it fails in one out of a few hundered cell clusters.

Tested with current Fiji on Linux and Windows as well as with older versions of
Fiji.

Thanks

Thomas

Information about your version of Java:

  os.arch => amd64
  os.name => Linux
  os.version => 3.4.63-2.44-desktop
  java.version => 1.6.0_24
  java.vendor => Sun Microsystems Inc.
  java.runtime.name => Java(TM) SE Runtime Environment
  java.runtime.version => 1.6.0_24-b07
  java.vm.name => Java HotSpot(TM) 64-Bit Server VM
  java.vm.version => 19.1-b02
  java.vm.vendor => Sun Microsystems Inc.
  java.vm.info => mixed mode
  java.awt.graphicsenv => sun.awt.X11GraphicsEnvironment
  java.specification.name => Java Platform API Specification
  java.specification.version => 1.6
  sun.cpu.endian => little
  sun.desktop => null
  file.separator => /

The up-to-date check says: REMIND_LATER

Information relevant to JAVA_HOME related problems:

  JAVA_HOME is set to:
/usr/local/src/Fiji.app/java/linux-amd64/jdk1.6.0_24//jre
  imagej.dir => /usr/local/src/Fiji.app

Information about the version of each plugin:

Activated update sites:
ImageJ: <a href="http://update.imagej.net/">http://update.imagej.net/</a> (last check:20140712000647)
Fiji: <a href="http://fiji.sc/update/">http://fiji.sc/update/</a> (last check:20140715020940)

Files not up-to-date:
  9dda14a8 (LOCAL_ONLY) 20100729201826 macros/js/AA_README.txt
  20e2cec7 (LOCAL_ONLY) 20140207105410 plugins/ICTN_1_6_.jar
  d3260180 (LOCAL_ONLY) 20110303204101 scripts/Record_Desktop.py
  0ea7f8fc (LOCAL_ONLY) 20110303204101 scripts/Record_Window.py</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>