SchmollerLab / Cell_ACDC

A Python GUI-based framework for segmentation, tracking and cell cycle annotations of microscopy data
BSD 3-Clause "New" or "Revised" License
131 stars 22 forks source link

Easier ways to check background pixel intensities during Data Prep #74

Open jordanyx opened 2 years ago

jordanyx commented 2 years ago

I'm interested in having an easy way to check the distribution of background pixel intensities (i.e. non-cell pixels).

To that end, it would be helpful to have the unaligned, uncropped image for each channel saved in the same position folder, rather than having to reference the raw_microscopy_files folder.

Perhaps when drawing the Background ROI in the Data prep module, it would also be useful to be able to view a histogram/distribution of background pixel intensities for different fluorescence channels within the drawn rectangle, or some representative statistics like mean, median, etc. It would also be useful to have that option to check the stats for everything outside the regular ROI, not just wherever the Background ROI is drawn.

While I'm at it, a couple questions about how the downstream values for autoPrepBkgr and dataPrepBkgr work: If one crops such that most of the aligned/cropped image is just cells, does this decrease the accuracy of the autoPrepBkgr median value since there are fewer pixels? And what happens to the dataPrepBkgr median value if the cropped image doesn't include the Background ROI?

ElpadoCan commented 2 years ago

Hi Jordan, I agree that it would be nice to view distributions of background intensities. This is related to #64 since having a widget that allows quick visualization (distributions, plots etc.) would help in both cases.

For the autoBkgr, you are right, when you crop very close to the cells I would guess that with fewer background pixels left, one might skew the distribution a little bit, but this would require testing and it is case dependant. Maybe we add a third catergory in the visualization, that is the auto background inside the ROI? This would allow you to visualize the effect of cropping close to the cells.

The dataPrepBkgr, however, already solves this issue because when you place the background ROI outside of the cropping area, Cell-ACDC saves a file (for each channel) that ends with bkgrRoiData.npz with the intensities from the background ROIs. This file contains one array per background ROI drawn in the dataprep step (you can draw as many backround ROIs as you want, press the Add background ROI button on the toolbar). When you save the measurements, Cell-ACDC detects this file and compute the median for the dataPrepBkgr value. If you need to access this file, it is a Numpy file containing multiple arrays, where each array is accessible as in a dictionary with the keys roi0_data, roi1_data etc.

Anyway, I will soon develop a widget for visualization of data directly in the GUI. I will keep you updated, cheers.

jordanyx commented 2 years ago

Hi Francesco, For the autoBkgr, I like the idea of the 3rd category--would definitely be helpful to know how much padding is needed to make sure a position's background doesn't get skewed.

Glad to know that the dataPrepBkgr is preserved in its own file even after cropping. Thanks for the clarification of what that file is!