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

Error in Measurement with StarDist script with RGB fluorescence images #686

Closed
RAHoebe opened this issue Mar 22, 2021 · 6 comments
Closed
Labels
Milestone

Comments

@RAHoebe
Copy link

RAHoebe commented Mar 22, 2021

Bug report

Describe the bug
I compiled QuPath with Stardist as described in the docs. The detection of nuclei on the blue channel works fine (although the cell expansion value is ignored). The Measurements are however not correct! I get only values for the red channel of a RGB image (see attachment) and they are incorrect (negative values, see screenshot). There are no values for the green channel.

To Reproduce
The script (I have it in a subfolder of the QuPath executable 'ScriptStardist', it finds the model then automatically.
ScriptStardist.zip

The image (ImageJ Tiff file)
CTRL-01.zip

Expected behavior
Measurements like the 'Cell Detection' command.

Screenshots
Screenshot of the negative values.
ss-negative-values

Desktop (please complete the following information):

  • OS: Windows
  • QuPath Version 0.2.3 and 0.3.0 Snapshot 22/3/2021
@petebankhead
Copy link
Member

I can replicate the problem with the measurements. Basically, RGB images are a special case. QuPath + StarDist should measure them properly if they are brightfield (after color deconvolution), but if a fluorescence image is RGB then it just uses the packed RGB value as a single channel - rather than splitting out the red, green and blue components.

This is a bug that we can fix.

I don't see a problem with the cell expansion, but note that

  • you're constraining the cell expansion with the .cellConstrainScale(1.5) option
  • the pixel size of your image is 0.5, but based upon the scalebar it should be closer to 0.161 µm

In the short term, you can open your images in ImageJ/Fiji and run Image → Color → Make Composite. While you're there, you can call Analyze → Set Scale... with a line drawn over the scalebar and input the true length to fix the pixel size.

I've attached an example of the image after conversion; this should work in QuPath properly.
CTRL-01-composite.tif.zip

Finally, my guess is that your RGB image isn't the raw data - since it has a scalebar burned in to it. So the pixel values might be changed and analysis might not make sense anyway. I've written a bit about this topic in my image analysis handbook, e.g. here (and some other chapters about RGB conversion).

@RAHoebe
Copy link
Author

RAHoebe commented Mar 22, 2021

Thanks for the quick response. Converting to composite works. Is it an option to let QuPath do this automatically when the image type is set to Fluorescence? And for the standard "Cell Detection" the RGB Data was not a problem.
I overlooked the .cellConstrainScale(1.5) option.
You are right about the data not being the RAW data. This RAW data was lost by the researcher.
Thanks for the great program. We like QuPath a lot!

@petebankhead
Copy link
Member

Converting to composite works. Is it an option to let QuPath do this automatically when the image type is set to Fluorescence?

I'm afraid not, QuPath doesn't really allow you to modify the image in any way, so changes like this are difficult. Batch conversion in ImageJ is the easiest 'fix' I can think of.

The code used to make measurements with StarDist is a lot more generic than the code for the built-in cell detection... but I overlooked the RGB problem since I didn't have any images quite like that. Good to know about it now so we can fix it before the next release.

Thanks for the great program. We like QuPath a lot!

I'm glad! If you haven't already, it would be great if you could fill in the user survey - and please share it with anyone else you know uses the software!

@RAHoebe
Copy link
Author

RAHoebe commented Mar 22, 2021

I filled in the Survey a few days a ago already. I will ask my colleagues to do this also.

@RAHoebe RAHoebe closed this as completed Mar 22, 2021
@petebankhead
Copy link
Member

Great, thanks!
(I'll keep this open for a few days to make sure I don't forget to fix it...)

@petebankhead petebankhead reopened this Mar 22, 2021
petebankhead added a commit to petebankhead/qupath that referenced this issue Mar 22, 2021
See qupath#686
This fix should only impact StarDist intensity measurements for RGB images (or any scripts using ObjectMeasurements directly).
@petebankhead petebankhead added this to the v0.3.0 milestone Mar 22, 2021
petebankhead added a commit to petebankhead/qupath that referenced this issue Apr 4, 2021
See qupath#686
This fix should only impact StarDist intensity measurements for RGB images (or any scripts using ObjectMeasurements directly).
@petebankhead petebankhead changed the title Error in Measurement with StarDist script Error in Measurement with StarDist script with RGB fluorescence images Apr 4, 2021
@petebankhead petebankhead mentioned this issue Apr 4, 2021
@petebankhead
Copy link
Member

Closing now, since the fix is now merged and will be in v0.3.0.

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

No branches or pull requests

2 participants