A search bar for ImageJ



Hey guys,

I just found some time to work on a potential extension for ImageJ which may be useful for everyone. I took a prototype implementation for a search bar within ImageJ by @ctrueden and extended it. That’s how it looks so far:

In fact, it’s a remake of the good old CommandFinder but with additional support for the ImageJ wiki and the forum. The web search works OPT-IN, so it will not search the internet unless you ask for it by clicking the tab.

I would be happy for feedback, firstly from developers, as there is no release yet. You can try the search bar, by cloning the search-bar branch from my imagej-legacy fork:

Afterwards, you can start ImageJ with the search-bar by running this main function, e.g. from your IDE:

Furthermore, I would be super happy about feedback regarding the implementation. I tried to use ImageJ2/SciJava best practices whenever possible:

Happy searching and thanks for any support!


Search field on menu

Great to see that you worked on this!

When we were discussing this idea at the dais learnathon in Dresden back in June, @ctrueden suggested that the list of results (e.g. the commands found) show allow not only to run a given command, but offer flexible (and extensible) options, such as for example:

  • Run
  • Display Help (from wiki?)
  • Add code snippet to script editor
  • Batch Process (using the Batch Processor currently in development ;-); latest state on the wip branch)

So, how about improving SearchResultDisplay in a way that it’s extensible by plugins (i.e. a common ResultHandler interface with RunResultHandler, CodeResultHandler, BatchResultHandler)?

Actually, I think most of this whole work should live in the scijava org, just the UI-specific things should go to scijava-ui-swing or (if necessary) to imagej-legacy.


@haesleinhuepf It is awesome that you worked on this.

I had a bunch of work I did on my local machine awhile ago, and unfortunately forgot to push (got distracted with other things). I have now pushed that work to the search-bar branch of imagej-legacy. It is extremely not-done and non-working, but shows the direction I was thinking would be good.

Unfortunately, I am currently in an extreme time crunch, and do not have time to look at or work on this code at all until after October. I agree with @imagejan that it would be fantastic to have plugins for the actions one can perform with a search result, and that this code will ultimately not live in imagej-legacy at all. A dream we have is to be able to launch a command in batch mode via the new batch processing support, for example.

It would be great to pair program with you on this project during the December hackathon at MPI-CBG, assuming this project still needs a push forward at that time.


Great idea for the code snippets. it seems a bit convoluted to have to use the macro recorder to quickly understand how the API labels commands, and then copy-paste from the macro recorder to get the methods into your script/batch macro.


Hey @ctrueden,

I just downloaded a recent new Fiji from the website and saw that the new search bar has been published! Awesome!

However, I’m afraid its result list contains quite different elements compared to the last running prototype I’ve seen.

Users who are looking for a simple menu like “Apply threshold” may be a bit lost…

Would it maybe make sense to rollback the search bar until it is properly tested?

I’d volunteer for extensive testing :wink:



Addendum: The search options dialog throws this exception:

(Fiji Is Just) ImageJ 2.0.0-rc-62/1.51s; Java 1.8.0_66 [64-bit]; Windows 10 10.0; 169MB of 48948MB (<1%)

at net.imagej.legacy.LegacyService.runLegacyCompatibleCommand(LegacyService.java:289)
at net.imagej.legacy.DefaultLegacyHooks.interceptRunPlugIn(DefaultLegacyHooks.java:163)
at ij.IJ.runPlugIn(IJ.java)
at ij.Executer.runCommand(Executer.java:137)
at ij.Executer.run(Executer.java:66)
at java.lang.Thread.run(Thread.java:745)


Dear all,

Thank you for the effort of adding this tool to Fiji!
However, as of 3 minutes ago, the old trusty Command Finder (L key) has been replaced by the search bar.

Thing is, that it does not provide information on commands!

I am running Fiji on Win10 and this is what it looks like if I search for “threshold”

The “commands” category appeared once after the Fiji Update but there were no results as well. After restarting Fiji, now that category is gone…

I was rather relying on the command finder for my Fiji installation, due to the sheer number of plugins that are now piled up in it, so I would appreciate some help on this matter.




Hi @oburri,

you can get the command finder back by switching the radio button in the search options dialog. This should help for the moment :wink:



Thank you! You’re a life saver.
I will definitely keep testing this tool as new updates come out!




Yes, because Fiji’s environment has many more SciJava modules than the imagej-legacy test environment does.

Fixed in scijava/scijava-search@f78b9c7c. Now only modules with either a label or a menu path are displayed. So this excludes e.g. all those thresholding ops.

I am working on adding a separate Ops category now. Once it is ready, I will make another release and reply back again here.

Fixed in imagej/imagej-legacy@5794a3cc.

Hmm. Perhaps one of the extensions installed into your Fiji causes an issue? If so, let’s isolate what’s happening and fix it. Could you please test with a freshly downloaded Fiji? Then try reintroducing your update sites and extensions half at a time? You could also try launching ImageJ in debug mode and look for any search-related messages.


I completed the new Op searcher: imagej/imagej-ops@a2c208db. Unfortunately, there is a critical bug in the ImageJ legacy layer relating to image translation which causes an infinite loop when harvesting certain kinds of ImgLib2 image inputs. I will work on fixing this bug before releasing the Op searcher.

In the meantime, I released a new ImageJ 2.0.0-rc-63 that includes the imagej-legacy and scijava-search fixes and improvements from today. Update Fiji and you will receive it. Hopefully all of the issues discussed above will be resolved by this update.

I fixed a bug which caused the command searcher to fail sometimes (scijava/scijava-search@a3fa53d0). I also added better error handling to the search framework, such that if anything goes wrong when searching, the error will be displayed in the UI. So @oburri, please update and try again—I am guessing the commands will appear correctly for you now, but if not, hopefully you’ll see an exception stack trace showing what happened.


Hi @ctrueden,

Thanks for the update! Indeed I get an error now.

More readable

	at java.util.ArrayList.addAll(ArrayList.java:577)
	at org.scijava.util.ClassUtils.getAnnotatedFields(ClassUtils.java:464)
	at org.scijava.util.ClassUtils.getAnnotatedFields(ClassUtils.java:434)
	at org.scijava.command.CommandInfo.checkFields(CommandInfo.java:446)
	at org.scijava.command.CommandInfo.initParams(CommandInfo.java:432)
	at org.scijava.command.CommandInfo.parseParams(CommandInfo.java:427)
	at org.scijava.command.CommandInfo.isValid(CommandInfo.java:383)
	at org.scijava.search.module.ModuleSearcher.isGoodModule(ModuleSearcher.java:155)
	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
	at org.scijava.search.module.ModuleSearcher.search(ModuleSearcher.java:80)
	at org.scijava.search.DefaultSearchOperation$SearchAttempt.run(DefaultSearchOperation.java:174)
	at org.scijava.thread.DefaultThreadService$2.run(DefaultThreadService.java:221)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	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)

I’ve done this this morning, by activating one update site at a time, and it seems that the BigStitcher update site causes the error above.

More specifically I think it is linked to the bigdataviewer-core.jar file.

To hopefully reproduce the error:

  1. Activate the BigStitcher Update Site
  2. Restart Fiji, and try a search > Error
  3. Deactivate BigStitcher Update Site
  4. Restart Fiji, try a search > Error
  5. Run Update again -> Will re-update bigdataviewer-core.jar
  6. Restart Fiji again -> No error when searching

This is the case for me on a Win10 machine with Java 1.8.0_144 [64-bit]


Hey @ctrueden !

Awesome, it works. Now, users get the same search results as the former Command Finder gave. Thanks! I guess that was super important. Thanks again for all your efforts and quick fixes like this one! Looking forward to more ImageJ releases in 2018!





When searching for “threshold” I get two identical menu entries Ïmage > Adjust > Threshold (unlike Command finder). The second Thresholder window looks like this:

It’s IJ2, right? Is it intentional? It’s a bit confusing…



Hopefully fixed with scijava/scijava-search@e2ce266e.

Fixed with imagej/imagej-legacy@86fa670f.

I’m going to hold off on making new releases though until I can fix imagej/imagej1#50 as well.
Edit: It is fixed; new scijava-search and imagej-legacy have been uploaded.


I released ImageJ 2.0.0-rc-64 encompassing all the bug-fixes over the past couple of days. I also made a news post announcing the search bar. And others have already tweeted it. So I’m going to mark this thread as “solved” now. :smile:


Awesome @ctrueden! Works great for me.

Just a small thing - the current order of the command result list is confusing because it is sorted by command name but displayed by menu path. I changed it to look like this (borrowed from KNIME):


I also added a little counter to the header to show if there are more results than displayed.

I would create a PR if that’s fine.


@frauzufall That looks awesome! Please go ahead.


Thanks, already did! https://github.com/scijava/scijava-search/pull/2


Just a comment perhaps… But hitting Run or pressing Enter closes the search results. It would be nice to regain the functionality of the command finder to keep it open.

I usually end up making use of the command finder to run the same command multiple times or to have a shortcut to a command that is too nested in the menus…

I can do it myself and add a pull request after @ctrueden pulls the last one. I think it’s just one line to remove…