Passing custom stain vectors to third-party application

I am implementing QuPath functions into software for an image capture device as plugins. Currently WatershedCellDetection is working, but I’m trying to pass custom stain vector colors as well, so the user can utilize this feature within our current workflow.

This is my first attempt at creating a plugin using QuPath features (someone else built the cell detection plugin that’s currently being used) and I’d like to add an option prior to running cell detection to easily calibrate the stain color between slides.

The goal is to obtain the custom stain vector results in the same manner (ex. H&E: select ROI > set Hematoxylin, Eosin) to be written to a JSON object for integration into the program.

Does anyone have any experience passing QuPath stain vectors to other software as a plugin?

I’m afraid I don’t really understand exactly what you want to do. For example, with ‘for integration into the program’ I’m not entirely sure which one is ‘the program’, or whether the user is interacting through QuPath’s GUI or another one. Without knowing more about your software and how the integration looks I find it too abstract to give an answer.

However, if you check the workflow tab after setting the stain vectors in QuPath and choose ‘Create script’ you can see the scripting command that is logged there. Not sure if that’s a useful starting point or not.

1 Like

@petebankhead The user (pathologist) is using a separate GUI which takes an image feed from the microscope and lets them use ImageJ, QuPath, and other plugins within this GUI minus some of the more complex options (no changing the sigma, threshold, etc.). The goal being to fit the workflow of a less tech-savvy pathologist.

I will look into the scripts for stain vectors and see if that helps, I think that will be a good place to start. Cheers!

Ah, ok. If you’re integrating directly with the QuPath Java libraries then you’ll need the ImageData, from which you can set/get the ColorDeconvolutionStains.

1 Like

Excellent, I was vastly overthinking this, and am on the right track now. Thanks for that @petebankhead, although after implementation it seems like the stain params aren’t being used correctly.

Most of the params are being passed via JSON object from the application to the QuPath plugin and vice versa. The ROI and PixelSize are currently included.

It looks like once I have the ImageData set, and my params, which now include the Stain Name, Stain 1, Stain 2, and the RGB optical density values for each stain, I can pass this to QuPath objects as necessary.

My final question on this topic:
Do I need to create a new StainVector from the JSON encoded stain/value information within the plugin first, or should I create a new ColorDeconvolutionStains directly from this string using the parseColorDeconvolutionStainsArg method?

Good! I think the parse method is probably the way to go.