Deconvolving with ImageJ Ops 0.45.7

When running the Richardson-LucyTV deconvolution in ImageJ Ops 0.45.7, I get the error log below and I don’t know the scripting language well enough to interpret the error message. Can someone help and tell me what I’m doing wrong? Thank you very much.

[Wed Apr 28 08:27:26 CDT 2021] [ERROR] [] [] null
Traceback (most recent call last):
  File "op_browser.py", line 5, in <module>
	at net.imagej.ops.special.computer.UnaryComputerOp.run(UnaryComputerOp.java:74)
	at net.imagej.ops.special.computer.UnaryComputerOp.run(UnaryComputerOp.java:92)
	at org.scijava.command.CommandModule.run(CommandModule.java:196)
	at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:950)
	at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:136)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Computer expects input != output

	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:512)
	at org.python.core.PyObject.__call__(PyObject.java:517)
	at org.python.core.PyMethod.__call__(PyMethod.java:171)
	at org.python.pycode._pyx0.f$0(op_browser.py:5)
	at org.python.pycode._pyx0.call_function(op_browser.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 javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:157)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Computer expects input != output
	at net.imagej.ops.special.computer.UnaryComputerOp.run(UnaryComputerOp.java:74)
	at net.imagej.ops.special.computer.UnaryComputerOp.run(UnaryComputerOp.java:92)
	at org.scijava.command.CommandModule.run(CommandModule.java:196)
	at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:950)
	at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:136)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)
	... 24 more
[Wed Apr 28 08:27:41 CDT 2021] [ERROR] [] [] null
Traceback (most recent call last):
  File "op_browser.py", line 6, in <module>
	at net.imagej.ops.special.computer.UnaryComputerOp.run(UnaryComputerOp.java:74)
	at net.imagej.ops.special.computer.UnaryComputerOp.run(UnaryComputerOp.java:92)
	at org.scijava.command.CommandModule.run(CommandModule.java:196)
	at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:950)
	at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:136)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Computer expects input != output

	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.PyObject.__call__(PyObject.java:422)
	at org.python.core.PyMethod.__call__(PyMethod.java:187)
	at org.python.pycode._pyx1.f$0(op_browser.py:6)
	at org.python.pycode._pyx1.call_function(op_browser.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 javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:157)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Computer expects input != output
	at net.imagej.ops.special.computer.UnaryComputerOp.run(UnaryComputerOp.java:74)
	at net.imagej.ops.special.computer.UnaryComputerOp.run(UnaryComputerOp.java:92)
	at org.scijava.command.CommandModule.run(CommandModule.java:196)
	at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:950)
	at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:136)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)
	... 22 more
[Wed Apr 28 08:31:52 CDT 2021] [ERROR] [] [] null
Traceback (most recent call last):
  File "op_browser.py", line 9, in <module>
	at java.lang.reflect.Array.set(Native Method)
	at org.scijava.convert.DefaultConverter.convertToArray(DefaultConverter.java:241)
	at org.scijava.convert.DefaultConverter.convert(DefaultConverter.java:81)
	at org.scijava.convert.AbstractConverter.convert(AbstractConverter.java:123)
	at org.scijava.convert.AbstractConvertService.convert(AbstractConvertService.java:131)
	at org.scijava.convert.AbstractConvertService.convert(AbstractConvertService.java:117)
	at net.imagej.ops.DefaultOpMatchingService.convert(DefaultOpMatchingService.java:623)
	at net.imagej.ops.DefaultOpMatchingService.assign(DefaultOpMatchingService.java:611)
	at net.imagej.ops.DefaultOpMatchingService.assignInputs(DefaultOpMatchingService.java:161)
	at net.imagej.ops.DefaultOpMatchingService.createModule(DefaultOpMatchingService.java:571)
	at net.imagej.ops.DefaultOpMatchingService.moduleConforms(DefaultOpMatchingService.java:483)
	at net.imagej.ops.DefaultOpMatchingService.filterMatches(DefaultOpMatchingService.java:293)
	at net.imagej.ops.DefaultOpMatchingService.filterMatches(DefaultOpMatchingService.java:138)
	at net.imagej.ops.DefaultOpMatchingService.findMatch(DefaultOpMatchingService.java:95)
	at net.imagej.ops.DefaultOpMatchingService.findMatch(DefaultOpMatchingService.java:83)
	at net.imagej.ops.OpEnvironment.module(OpEnvironment.java:253)
	at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:136)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException

	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.PyObject.__call__(PyObject.java:422)
	at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:237)
	at org.python.core.PyMethod.__call__(PyMethod.java:228)
	at org.python.core.PyMethod.__call__(PyMethod.java:218)
	at org.python.pycode._pyx2.f$0(op_browser.py:9)
	at org.python.pycode._pyx2.call_function(op_browser.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 javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:157)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException
	at java.lang.reflect.Array.set(Native Method)
	at org.scijava.convert.DefaultConverter.convertToArray(DefaultConverter.java:241)
	at org.scijava.convert.DefaultConverter.convert(DefaultConverter.java:81)
	at org.scijava.convert.AbstractConverter.convert(AbstractConverter.java:123)
	at org.scijava.convert.AbstractConvertService.convert(AbstractConvertService.java:131)
	at org.scijava.convert.AbstractConvertService.convert(AbstractConvertService.java:117)
	at net.imagej.ops.DefaultOpMatchingService.convert(DefaultOpMatchingService.java:623)
	at net.imagej.ops.DefaultOpMatchingService.assign(DefaultOpMatchingService.java:611)
	at net.imagej.ops.DefaultOpMatchingService.assignInputs(DefaultOpMatchingService.java:161)
	at net.imagej.ops.DefaultOpMatchingService.createModule(DefaultOpMatchingService.java:571)
	at net.imagej.ops.DefaultOpMatchingService.moduleConforms(DefaultOpMatchingService.java:483)
	at net.imagej.ops.DefaultOpMatchingService.filterMatches(DefaultOpMatchingService.java:293)
	at net.imagej.ops.DefaultOpMatchingService.filterMatches(DefaultOpMatchingService.java:138)
	at net.imagej.ops.DefaultOpMatchingService.findMatch(DefaultOpMatchingService.java:95)
	at net.imagej.ops.DefaultOpMatchingService.findMatch(DefaultOpMatchingService.java:83)
	at net.imagej.ops.OpEnvironment.module(OpEnvironment.java:253)
	at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:136)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)
	... 24 more

Without seeing the source code of your script op_browser.py (in particular line 5), it’s hard to provide any useful advice, we can only guess…

That seems to be the essence of the error message. Could it be that you provided an output container to the op that was the same as the input? Try making a copy of your input, or creating an empty image, to feed as output container to your op.

1 Like

Thank you for your response, Dr. Eglinger. I tried having the input and output image the same, with a copy of the input image as the output image, and with a new, blank image as the output image. None of them worked. The source code should be in this zip file I downloaded from the ImageJ Ops GitHub site. Thank you for your help!!
imagej-ops-imagej-ops-0.45.7.zip (3.2 MB)

Hi @GopherConfocal

I just tried the ‘DeconWithTheoreticalPSF.py’ script that is under ‘templates->deconvolution’ in the script editor. It seems that the script no longer works and I had to change the last line as follows. The output has to be the first input of the richardsonLucy call.

deconvolved=ops.create().img(imgF)

deconvolved = ops.deconvolve().richardsonLucy(deconvolved, imgF, psf, borderSize, None,
					None, None, None, numIterations, True, True);

Does that work for you?

1 Like

Hi Brian,

Sorry for my delayed response. I tried running the “DeconWithTheoreticalPSF.py” script and it generates the PSF just fine, but then the process aborts and I get the error message below. I welcome your advice. Thank you very much.

Traceback (most recent call last):
  File "C:\Users\MARYBR~1\Desktop\FIJI~1.APP\scripts\file:\C:\Users\MARYBR~1\Desktop\FIJI~1.APP\jars\imagej-scripting-0.8.2.jar!\script_templates\Deconvolution\DeconWithTheoreticalPSF.py", line 44, in <module>

Request:
-	net.imagej.ops.Ops$Create$Img(
		ArrayImg,
		null)

Candidates:
1. 	(Img out) =
	net.imagej.ops.create.img.CreateImgFromImg(
		Img in)
	Too many arguments: 2 > 1
2. 	(Img out) =
	net.imagej.ops.create.img.CreateImgFromII(
		IterableInterval in)
	Too many arguments: 2 > 1
3. 	(Img out) =
	net.imagej.ops.create.img.CreateImgFromRAI(
		RandomAccessibleInterval in)
	Too many arguments: 2 > 1
4. 	(Img out) =
	net.imagej.ops.create.img.CreateImgFromDimsAndType(
		Dimensions in1,
==>		NativeType in2,
		ImgFactory factory?)
	Missing required argument
5. 	(Img out) =
	net.imagej.ops.create.img.CreateImgFromInterval(
		Interval in)
	Too many arguments: 2 > 1

	at net.imagej.ops.DefaultOpMatchingService.singleMatch(DefaultOpMatchingService.java:432)
	at net.imagej.ops.DefaultOpMatchingService.findMatch(DefaultOpMatchingService.java:97)
	at net.imagej.ops.DefaultOpMatchingService.findMatch(DefaultOpMatchingService.java:83)
	at net.imagej.ops.OpEnvironment.module(OpEnvironment.java:269)
	at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:157)
	at net.imagej.ops.create.CreateNamespace.img(CreateNamespace.java:116)
	at net.imagej.ops.deconvolve.DeconvolveNamespace.create(DeconvolveNamespace.java:934)
	at net.imagej.ops.deconvolve.DeconvolveNamespace.richardsonLucy(DeconvolveNamespace.java:719)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: No matching 'net.imagej.ops.Ops$Create$Img' op

Request:
-	net.imagej.ops.Ops$Create$Img(
		ArrayImg,
		null)

Candidates:
1. 	(Img out) =
	net.imagej.ops.create.img.CreateImgFromImg(
		Img in)
	Too many arguments: 2 > 1
2. 	(Img out) =
	net.imagej.ops.create.img.CreateImgFromII(
		IterableInterval in)
	Too many arguments: 2 > 1
3. 	(Img out) =
	net.imagej.ops.create.img.CreateImgFromRAI(
		RandomAccessibleInterval in)
	Too many arguments: 2 > 1
4. 	(Img out) =
	net.imagej.ops.create.img.CreateImgFromDimsAndType(
		Dimensions in1,
==>		NativeType in2,
		ImgFactory factory?)
	Missing required argument
5. 	(Img out) =
	net.imagej.ops.create.img.CreateImgFromInterval(
		Interval in)
	Too many arguments: 2 > 1


	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.PyObject.__call__(PyObject.java:422)
	at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:237)
	at org.python.core.PyMethod.__call__(PyMethod.java:228)
	at org.python.core.PyMethod.__call__(PyMethod.java:218)
	at org.python.pycode._pyx2.f$0(C:\Users\MARYBR~1\Desktop\FIJI~1.APP\scripts\file:\C:\Users\MARYBR~1\Desktop\FIJI~1.APP\jars\imagej-scripting-0.8.2.jar!\script_templates\Deconvolution\DeconWithTheoreticalPSF.py:44)
	at org.python.pycode._pyx2.call_function(C:\Users\MARYBR~1\Desktop\FIJI~1.APP\scripts\file:\C:\Users\MARYBR~1\Desktop\FIJI~1.APP\jars\imagej-scripting-0.8.2.jar!\script_templates\Deconvolution\DeconWithTheoreticalPSF.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 javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:157)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: No matching 'net.imagej.ops.Ops$Create$Img' op

Request:
-	net.imagej.ops.Ops$Create$Img(
		ArrayImg,
		null)

Candidates:
1. 	(Img out) =
	net.imagej.ops.create.img.CreateImgFromImg(
		Img in)
	Too many arguments: 2 > 1
2. 	(Img out) =
	net.imagej.ops.create.img.CreateImgFromII(
		IterableInterval in)
	Too many arguments: 2 > 1
3. 	(Img out) =
	net.imagej.ops.create.img.CreateImgFromRAI(
		RandomAccessibleInterval in)
	Too many arguments: 2 > 1
4. 	(Img out) =
	net.imagej.ops.create.img.CreateImgFromDimsAndType(
		Dimensions in1,
==>		NativeType in2,
		ImgFactory factory?)
	Missing required argument
5. 	(Img out) =
	net.imagej.ops.create.img.CreateImgFromInterval(
		Interval in)
	Too many arguments: 2 > 1

	at net.imagej.ops.DefaultOpMatchingService.singleMatch(DefaultOpMatchingService.java:432)
	at net.imagej.ops.DefaultOpMatchingService.findMatch(DefaultOpMatchingService.java:97)
	at net.imagej.ops.DefaultOpMatchingService.findMatch(DefaultOpMatchingService.java:83)
	at net.imagej.ops.OpEnvironment.module(OpEnvironment.java:269)
	at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:157)
	at net.imagej.ops.create.CreateNamespace.img(CreateNamespace.java:116)
	at net.imagej.ops.deconvolve.DeconvolveNamespace.create(DeconvolveNamespace.java:934)
	at net.imagej.ops.deconvolve.DeconvolveNamespace.richardsonLucy(DeconvolveNamespace.java:719)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)
	... 24 more

Hi @GopherConfocal

So currently the last line of the last line of the script is as follows

deconvolved = ops.deconvolve().richardsonLucy(imgF, psf, borderSize, None,
					None, None, None, numIterations, True, True);

you need to replace with the following two lines

deconvolved=ops.create().img(imgF)

deconvolved = ops.deconvolve().richardsonLucy(deconvolved, imgF, psf, borderSize, None,
					None, None, None, numIterations, True, True);

I should probably update the scripts to make sure they work with the latest version of ops. It’s my fault they don’t. I changed some interfaces such that one needed to pass in the output memory.

There is actually a valid technical reason for this, having to do with the scenario where one processes a very large image in blocks and wants to pass in the memory location to write to. However ideally we would also have the deconvolution op available as a function, it is a tricky design issue. At the very least I should update the scripts so they work.

1 Like

Updates would be appreciated very much! Thank you so much!

1 Like

Hi Dr. Northan,

I entered the code as you instructed, but I still had problems. The PSF image came out totally black and the error message below appeared. I welcome your advice. Thank you!

Started DeconWithTheoreticalPSF.py at Mon May 03 06:47:25 CDT 2021
Traceback (most recent call last):
  File "C:\Users\MARYBR~1\Desktop\DeepFiji.app\scripts\file:\C:\Users\MARYBR~1\Desktop\DeepFiji.app\jars\imagej-scripting-0.8.2.jar!\script_templates\Deconvolution\DeconWithTheoreticalPSF.py", line 44, in <module>
NameError: name 'deconvolved' is not defined

	at org.python.core.Py.NameError(Py.java:261)
	at org.python.core.PyFrame.getname(PyFrame.java:257)
	at org.python.pycode._pyx0.f$0(C:\Users\MARYBR~1\Desktop\DeepFiji.app\scripts\file:\C:\Users\MARYBR~1\Desktop\DeepFiji.app\jars\imagej-scripting-0.8.2.jar!\script_templates\Deconvolution\DeconWithTheoreticalPSF.py:44)
	at org.python.pycode._pyx0.call_function(C:\Users\MARYBR~1\Desktop\DeepFiji.app\scripts\file:\C:\Users\MARYBR~1\Desktop\DeepFiji.app\jars\imagej-scripting-0.8.2.jar!\script_templates\Deconvolution\DeconWithTheoreticalPSF.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 javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:157)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Hi Dr. Northan,

I entered the last two lines as you instructed in your last post and when I tried running the edited script, I get the error message below the script window. I would really appreciate your advice. Thank you.

Traceback (most recent call last):
  File "C:\Users\MARYBR~1\Desktop\FIJI~1.APP\scripts\file:\C:\Users\MARYBR~1\Desktop\FIJI~1.APP\jars\imagej-scripting-0.8.2.jar!\script_templates\Deconvolution\DeconWithTheoreticalPSF.py", line 46, in <module>
	at net.imagej.ops.deconvolve.PadAndRichardsonLucy.initialize(PadAndRichardsonLucy.java:112)
	at net.imagej.ops.DefaultOpMatchingService.singleMatch(DefaultOpMatchingService.java:425)
	at net.imagej.ops.DefaultOpMatchingService.findMatch(DefaultOpMatchingService.java:97)
	at net.imagej.ops.DefaultOpMatchingService.findMatch(DefaultOpMatchingService.java:83)
	at net.imagej.ops.OpEnvironment.module(OpEnvironment.java:269)
	at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:157)
	at net.imagej.ops.deconvolve.DeconvolveNamespace.richardsonLucy(DeconvolveNamespace.java:197)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
java.lang.NoSuchMethodError: java.lang.NoSuchMethodError: net.imglib2.outofbounds.OutOfBoundsConstantValueFactory.<init>(Ljava/lang/Object;)V

	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.PyObject.__call__(PyObject.java:422)
	at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:237)
	at org.python.core.PyMethod.__call__(PyMethod.java:228)
	at org.python.core.PyMethod.__call__(PyMethod.java:218)
	at org.python.pycode._pyx2.f$0(C:\Users\MARYBR~1\Desktop\FIJI~1.APP\scripts\file:\C:\Users\MARYBR~1\Desktop\FIJI~1.APP\jars\imagej-scripting-0.8.2.jar!\script_templates\Deconvolution\DeconWithTheoreticalPSF.py:46)
	at org.python.pycode._pyx2.call_function(C:\Users\MARYBR~1\Desktop\FIJI~1.APP\scripts\file:\C:\Users\MARYBR~1\Desktop\FIJI~1.APP\jars\imagej-scripting-0.8.2.jar!\script_templates\Deconvolution\DeconWithTheoreticalPSF.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 javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:157)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoSuchMethodError: net.imglib2.outofbounds.OutOfBoundsConstantValueFactory.<init>(Ljava/lang/Object;)V
	at net.imagej.ops.deconvolve.PadAndRichardsonLucy.initialize(PadAndRichardsonLucy.java:112)
	at net.imagej.ops.DefaultOpMatchingService.singleMatch(DefaultOpMatchingService.java:425)
	at net.imagej.ops.DefaultOpMatchingService.findMatch(DefaultOpMatchingService.java:97)
	at net.imagej.ops.DefaultOpMatchingService.findMatch(DefaultOpMatchingService.java:83)
	at net.imagej.ops.OpEnvironment.module(OpEnvironment.java:269)
	at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:157)
	at net.imagej.ops.deconvolve.DeconvolveNamespace.richardsonLucy(DeconvolveNamespace.java:197)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)
	... 24 more
1 Like

Hi @GopherConfocal

I just tried again on my side. I even downloaded a completely fresh copy of Fiji (just in case a recent change affected things). When changing the last two lines as follows it works for me

deconvolved=ops.create().img(imgF)

deconvolved = ops.deconvolve().richardsonLucy(deconvolved, imgF, psf, borderSize, None,
					None, None, None, numIterations, True, True);

What size of image and dimensions are you using? Is it possible to give me a sample of an image that doesn’t work along with the input parameters you are using?

1 Like

Thank you so much for your efforts, Dr. Northan. I have attached a cropped widefield image taken by a client at our imaging facility. The dye is FAM and it was imaged with a 20X air objective with an NA of 0.75. The image is a maximum intensity projection from a 12-slice stack. The image is badly blurred, but I’d to get the deconvolution working consistently so I can show our facility clients how to use it. Thank you again!
MAX_RB0409_300_001Crop.tif (19.4 MB)

1 Like

Hi @GopherConfocal

I think the problem in this case was that the image was 2D, but the DeconWithTheoreticalPSF.py script was written for 3D images (the scripts are meant to act as examples and templates, but often times tweaks have to be made for specific scenarios).

I made some tweaks such that it works with large 2D images. If you copy the below into the script editor does it work?

#@ OpService ops
#@ UIService ui
#@ ImgPlus img
#@ Integer numIterations(value=30)
#@ Float numericalAperture(value=1.4)
#@ Float wavelength(value=550)
#@ Float riImmersion(value=1.5)
#@ Float riSample(value=1.4)
#@ Float xySpacing(value=62.9)
#@ Float zSpacing(value=160)
#@OUTPUT ImgPlus psf
#@OUTPUT ImgPlus deconvolved

from net.imglib2 import FinalDimensions
from net.imglib2.type.numeric.real import FloatType;
from net.imglib2.view import Views

# convert to float (TODO: make sure deconvolution op works on other types)
imgF=ops.convert().float32(img)

# make psf same size as image
#psfSize=FinalDimensions([img.dimension(0), img.dimension(1), img.dimension(2)]);
psfSize=FinalDimensions([30, 30, img.dimension(2)]);

wavelength=wavelength*1E-9
xySpacing=xySpacing*1E-9
zSpacing=zSpacing*1E-9

depth = 0 

psf = ops.create().kernelDiffraction(psfSize, numericalAperture, wavelength,
				riSample, riImmersion, xySpacing, zSpacing, depth, FloatType());

psf_ = Views.dropSingletonDimensions(psf)

print(psf.numDimensions())

#deconvolved=ops.deconvolve().richardsonLucyTV(imgF, psf, numIterations, 0.01)

deconvolved=ops.create().img(imgF)

deconvolved = ops.deconvolve().richardsonLucy(deconvolved, imgF, psf_, None, None,
					None, None, None, numIterations, True, True);				
1 Like

The original image was 3D, but I wasn’t sure how to share it with you. Thank you though for writing new code to accommodate 2D images. The original image is about 1 GB. What’s the best way to share it with you? Thanks.

1 Like

Hi @GopherConfocal

Dropbox or another cloud drive that is easy to set up public access on would be good.

If it is a 1G image you could be running into memory issues. Either the machine is running out of memory, or ops deconvolution can’t handle that much memory. I could give it a try on my end as I have a lot of memory on my machine.

Brian

1 Like

Hi Brian,

Here’s a link to a Dropbox folder that contains the tiff file plus the metadata file. I really appreciate your efforts! Thank you so much!

1 Like

It’s also my fault, for changing Ops such that things broke. For what it’s worth, we are not planning any more changes to the current incarnation of ImageJ Ops—future improvements will come with the new ImageJ Ops2, targeting release by end of 2021.

I look forward eagerly to the release of ImageJ Ops2!

1 Like