Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programmatically calling search results #241

Open
kephale opened this issue May 24, 2023 · 6 comments
Open

Programmatically calling search results #241

kephale opened this issue May 24, 2023 · 6 comments
Assignees
Milestone

Comments

@kephale
Copy link
Contributor

kephale commented May 24, 2023

I was hoping to programmatically make calls to commands/scripts with napari-imagej.

I've read up to ResultRunner, jc.SearchResult, and python_actions_for but it looks like search is pretty directly connected to the UI.

Is there a way to do something like:

endpoint = "sc.fiji:fiji:2.13.0+org.morphonets:SNT:MANAGED"

...

search_results = get_matching_commands("tracing")
command_result = run_command(search_results[0], <some args>)
@gselzer
Copy link
Collaborator

gselzer commented May 24, 2023

@kephale you can get much of this functionality from pyimagej, but there's of course additional value in the processing napari-imagej adds on top of pyimagej. And @ctrueden asks for a lot of this functionality in #208 - the functionality is, like you say, too tied in to the GUI. A better separation of functionality from UI is already on the docket!

What's your use case here? I really want to support stuff like this - I'm just not sure whether it is napari-imagej's job or pyimagej's job to do it.

@gselzer gselzer self-assigned this May 24, 2023
@kephale
Copy link
Contributor Author

kephale commented May 24, 2023

I'm trying to port workflows from purely being run within Fiji to being run as Python scripts, so I'm starting with a skeleton script that sets up an endpoint, then incrementally adding/tweaking code line-by-line.

I think the main thing I want is to have Python functions that correspond to IJ2 Commands which have the logic for taking napari layers as input. It is definitely possible to do this stuff with pyimagej, but it seems as though napari-imagej is already providing the logic for mapping from IJ2 types to napari layers.

More on using pyimagej+napari-imagej in another issue.

@ctrueden
Copy link
Member

@gselzer Is it possible to make use of napari-imagej's layer conversion logic programmatically by using ij.py.to/from_java, since napari-imagej registers that conversion logic as scyjava converters?

@gselzer
Copy link
Collaborator

gselzer commented May 24, 2023

@gselzer Is it possible to make use of napari-imagej's layer conversion logic programmatically by using ij.py.to/from_java, since napari-imagej registers that conversion logic as scyjava converters?

Yup, all you have to do is register the converters (either by letting napari-imagej install them for you by calling init_ij, or manually by calling install_converters)

@ctrueden
Copy link
Member

ctrueden commented May 24, 2023

OK, so @kephale's script could use napari_imagej.java.init_ij to synchronously initialize PyImageJ according to its current settings, and then he's good to go? I guess that still doesn't resolve this issue though, which is about exposing programmatic access to the search functions. You could do that now by using the Java API by accessing the SearchService, but there's nothing more Pythonic yet. What else (if anything) does napari-imagej add on top of the search service that would be good to expose?

@ctrueden ctrueden added this to the 1.0.0 milestone May 24, 2023
@ctrueden
Copy link
Member

As part of my work on #265, I'm creating a model.py with NapariImageJ central class holding all the non-Qt-specific business logic. This will include the REPL of course, but I'll also see about making the search logic part of that as well. Then maybe this issue can be closed out at the same time as #265, assuming my plan is successful. API calls for everyone! 🎂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants