Custom input tool in QuPath extension

Hello, I am writing a QuPath extension to inject a custom input mode. I noticed that in QuPathGUI, Modes is an enum, which makes it a bit difficult to extend.

I’ve looked at the jpen extension, and since the jpen tool is a natural extension of the brush tool, subclassing and replacing the brush tool makes sense. In our case though, we would like to have an arc + line (= bow) tool that indicates an area of local drug diffusion, and I’m hesitant to subclass line or polyline, since we have uses cases for those tools as well.

Since our use is an edge case though, I have no complaints about it being an enum (GUIActions being an enum seems odd though).

Any insight is much appreciated.

-Sebastian Ahn

QuPath currently isn’t designed to support adding custom drawing tools. This may change in the future if there is sufficient need.

However, you can see how the Wand tool is installed using a separate extension here:

Therefore you may be able to repurpose the mode corresponding to the existing tool that is least useful to you in the short term while developing your custom tool, saving the question of how best to install it within QuPath until later.

Alternatively, you may try to use a ROI drawn by a built-in tool and have your command instead adapt it to the appropriate shape (similar to the expand annotations command).

1 Like

I see… I think we’ll use the polyline tool for now. Thanks Pete!

Hi Pete, I am having quite a bit of trouble creating a new tool. I think the RoiHandleAdjuster class and its subclasses are too tightly coupled with the RoiEditor, and I am having some trouble working around the bits of QuPath that are private.

I think I’ll just fork the repo and set our extension as a separate module for now, until there is better support for custom tools. Since this functionality is limited to our lab, it isn’t really an issue for us as we can package and release it in-house; I’ll just keep up with your commits.