Importing CellCounter plugin in Jython script

Hello,

I am writing a script in Jython that is trying to make use of the Cell Counter plugin commands without actually using the user interface (so that the process is automated for a lot of images). I am having trouble with simply importing the plugin. I came across the plugins.config file which shows the pathway for importation as this: sc.fiji.cellCounter.Cell_Counter

(taken from here:) [https://github.com/fiji/Cell_Counter/blob/master/src/main/resources/plugins.config]

However I am getting the error “No module named cellCounter” while running the import as:
from sc.fiji.cellCounter.Cell_Counter import CellCounter.

I am unsure if I am doing something wrong in the syntax and if there is something more I should be writing.

Any help would be appreciated!

Thanks,
Harris

Hi,

What is the version of the Cell Counter plugin you are using?

Here, ImageJ complaining that it cannot find a cellCounter module suggests that you have CellCounter ≤ 2.3.1, where the CellCounter class is not in a dedicated package and you can import it simply as follows:

import CellCounter

Note that even if you are using CellCounter 3.0.0, your import line would be wrong, it should be

from sc.fiji.cellCounter import CellCounter

That is, you have to import the class itself, instead of importing the constructor.

Hope that helps,

Damien

Hello Damien,

Thanks for the reply! That makes sense to me, but I can’t find what version of CellCounter I have, initially I had just installed it from: https://imagej.nih.gov/ij/plugins/cell-counter.html.

I also tried to take the one straight from the aforementioned github page, however they only contain the java files and not the class files so I need to compile it, but when I do I get a few errors while compiling. Do you have a link to an already fully compiled version of the latest CellCounter?

This is the error I get when I try and run Cell Counter from the github version.

C:\Users\Harris\AppData\Local\Temp\java1680692658481666909\src\main\java\sc\fiji\cellCounter\Cell_Counter.java:37: error: cannot find symbol
new CellCounter();
^
symbol: class CellCounter
location: class Cell_Counter
1 error
1 warning

Also thanks for correcting the syntax, I’m new to this and was trying to understand the proper format of importing.

Thanks,
Harris

I had misunderstood what you initially wrote and it now works using the
import CellCounter function. Thanks!

Harris