GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Can't uses `stats.mean` with a `SamplingIterableInterval` · Issue #270 · scijava/scijava

Can't uses stats.mean with a SamplingIterableInterval #270

New issue
Copy link
New issue
Copy link
Open
Open
Can't uses stats.mean with a SamplingIterableInterval#270
Copy link

Description

@elevans
elevans
opened on Aug 22, 2024
Issue body actions

With SciJava ops in Fiji (via a Jython script) I am unable to use the stats.mean Op on a sample created from an ImgLabeling.

Here's small example that replicates this behavior (use with the Blobs example open).

#@ OpEnvironment ops
#@ Img img

from net.imglib2.algorithm.labeling.ConnectedComponents import StructuringElement
from net.imglib2.roi import Regions
from net.imglib2.roi.labeling import LabelRegions
from net.imglib2.type.logic import BitType

# create an ImgLabeling
thres = ops.op("create.img").input(img, BitType()).apply()
ops.op("threshold.otsu").input(img).output(thres).compute()
labeling = ops.op("labeling.cca").input(thres, StructuringElement.FOUR_CONNECTED).apply()

# create a sample for each label and run stats.mean
regions = LabelRegions(labeling)
for r in regions:
    sample = Regions.sample(r, img)
    print(ops.op("stats.mean").input(sample).apply())

This creates the following stack trace:

Started bug_ops_stats_mean.py at Thu Aug 22 11:42:24 CDT 2024
Traceback (most recent call last):
  File "/home/edward/Documents/workspaces/ops/examples/bugs/bug_ops_stats_mean.py", line 18, in <module>
    print(ops.op("stats.mean").input(sample).apply())

Name: "stats.mean", Types: java.util.function.Function<net.imglib2.roi.util.SamplingIterableInterval<net.imglib2.type.numeric.integer.UnsignedByteType>, org.scijava.common3.Any>
Input Types: 
		* net.imglib2.roi.util.SamplingIterableInterval<net.imglib2.type.numeric.integer.UnsignedByteType>
Output Type: 
		* org.scijava.common3.Any

See debugging output for full failure report.
	at org.scijava.ops.engine.impl.DefaultOpEnvironment.findOp(DefaultOpEnvironment.java:367)
	at org.scijava.ops.engine.impl.DefaultOpEnvironment.op(DefaultOpEnvironment.java:215)
	at org.scijava.ops.api.OpBuilder.matchFunctionHelper(OpBuilder.java:15392)
	at org.scijava.ops.api.OpBuilder.matchFunction(OpBuilder.java:15233)
	at org.scijava.ops.api.OpBuilder$Arity1_IV_OU.function(OpBuilder.java:945)
	at org.scijava.ops.api.OpBuilder$Arity1_IV_OU.apply(OpBuilder.java:982)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
org.scijava.ops.engine.DependencyMatchingException: org.scijava.ops.engine.DependencyMatchingException: Error matching dependencies for request:

Name: "stats.mean", Types: java.util.function.Function<net.imglib2.roi.util.SamplingIterableInterval<net.imglib2.type.numeric.integer.UnsignedByteType>, org.scijava.common3.Any>
Input Types: 
		* net.imglib2.roi.util.SamplingIterableInterval<net.imglib2.type.numeric.integer.UnsignedByteType>
Output Type: 
		* org.scijava.common3.Any

See debugging output for full failure report.

	at org.python.core.Py.JavaError(Py.java:547)
	at org.python.core.Py.JavaError(Py.java:538)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:192)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:208)
	at org.python.core.PyObject.__call__(PyObject.java:461)
	at org.python.core.PyObject.__call__(PyObject.java:465)
	at org.python.core.PyMethod.__call__(PyMethod.java:126)
	at org.python.pycode._pyx22.f$0(/home/edward/Documents/workspaces/ops/examples/bugs/bug_ops_stats_mean.py:16)
	at org.python.pycode._pyx22.call_function(/home/edward/Documents/workspaces/ops/examples/bugs/bug_ops_stats_mean.py)
	at org.python.core.PyTableCode.call(PyTableCode.java:173)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1687)
	at org.python.core.__builtin__.eval(__builtin__.java:497)
	at org.python.core.__builtin__.eval(__builtin__.java:501)
	at org.python.util.PythonInterpreter.eval(PythonInterpreter.java:255)
	at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:57)
	at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:31)
	at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:262)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:173)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:125)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:64)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:247)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: org.scijava.ops.engine.DependencyMatchingException: Error matching dependencies for request:

Name: "stats.mean", Types: java.util.function.Function<net.imglib2.roi.util.SamplingIterableInterval<net.imglib2.type.numeric.integer.UnsignedByteType>, org.scijava.common3.Any>
Input Types: 
		* net.imglib2.roi.util.SamplingIterableInterval<net.imglib2.type.numeric.integer.UnsignedByteType>
Output Type: 
		* org.scijava.common3.Any

See debugging output for full failure report.
	at org.scijava.ops.engine.impl.DefaultOpEnvironment.findOp(DefaultOpEnvironment.java:367)
	at org.scijava.ops.engine.impl.DefaultOpEnvironment.op(DefaultOpEnvironment.java:215)
	at org.scijava.ops.api.OpBuilder.matchFunctionHelper(OpBuilder.java:15392)
	at org.scijava.ops.api.OpBuilder.matchFunction(OpBuilder.java:15233)
	at org.scijava.ops.api.OpBuilder$Arity1_IV_OU.function(OpBuilder.java:945)
	at org.scijava.ops.api.OpBuilder$Arity1_IV_OU.apply(OpBuilder.java:982)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)
	... 24 more

Using ImageJ-Ops stats.mean works just fine.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.