A cellprofiler plugin works only in test mode

Hi,

I’m working on a Cellprofiler plugins based on a Basic model to calculate and apply background illumination. You might find the plugins in a repository.

The repository includes two plugins:

  1. BasicIlluminationCalculate plugin for calculating the illumination (calculating flat-field and dark-field images)
  2. BasicIlluminationApply plugin for applying the illumination on a set images (using flat-field and dark-field images)

The BasicIlluminationCalculate is written based on the code of CorrectIlluminationCalculate Module that gather all images from all cycles and computes a single background illumination.

My BasicIlluminationCalculate works properly during the ‘test mode’ with following setup:

During the test mode, it starts to generate a list of input images:

Screenshot 2021-04-22 at 17.47.10

and the output dark-field and flat-field images are as expected. So the plugin works well in test mode.

But in ‘Analyze images’ mode, the above message for listing the images is not shown and the logging system prints a similar message for all images one by one that

Worker 0: Starting job
Worker 0: Doing job: 4
Worker 0: Running module Images 1
Worker 0: Fri Jun  4 23:13:11 2021: Image # 4, module Images # 1: CPU_time = 0.00 secs, Wall_time = 0.00 secs
Worker 0: Running module Metadata 2
Worker 0: Fri Jun  4 23:13:11 2021: Image # 4, module Metadata # 2: CPU_time = 0.00 secs, Wall_time = 0.00 secs
Worker 0: Running module NamesAndTypes 3
Worker 0: Fri Jun  4 23:13:11 2021: Image # 4, module NamesAndTypes # 3: CPU_time = 0.14 secs, Wall_time = 0.06 secs
Worker 0: Running module Groups 4
Worker 0: Fri Jun  4 23:13:11 2021: Image # 4, module Groups # 4: CPU_time = 0.00 secs, Wall_time = 0.00 secs
Worker 0: Running module BasicIlluminationCalculate 5
/Users/mohammad.mirkazemi/Documents/basic_project/CellProfiler_package/CellProfiler/cellprofiler/gui/figure/_figure.py:2070: UserWarning: One or more intensity levels are NaN. Rescaling will broadcast NaN to the full image. Provide intensity levels yourself to avoid this. E.g. with np.nanmin(image), np.nanmax(image).
  image = skimage.exposure.rescale_intensity(image, in_range=in_range)
/Users/mohammad.mirkazemi/Documents/basic_project/CellProfiler_package/CellProfiler/cellprofiler/gui/figure/_figure.py:2070: UserWarning: One or more intensity levels are NaN. Rescaling will broadcast NaN to the full image. Provide intensity levels yourself to avoid this. E.g. with np.nanmin(image), np.nanmax(image).
  image = skimage.exposure.rescale_intensity(image, in_range=in_range)
Worker 0: Fri Jun  4 23:13:11 2021: Image # 4, module BasicIlluminationCalculate # 5: CPU_time = 76.37 secs, Wall_time = 10.01 secs
Progress Counter({'Unprocessed': 59, 'Done': 3, 'FinishedWaitingMeasurements': 1})
Progress Counter({'Unprocessed': 59, 'Done': 4})

and the output darkfield and flat-field images are completely filled by nan value.

I’d appreciate it if someone could help to solve the problem.

From a quick look, it seems likely that there’s something going wrong with the image provider you’re trying to setup. In test mode there is no pre/post run phase, only the current test image is used. Once in Analysis mode you’ll need it to be properly passing between each image set, and if there’s a divide by zero somewhere it’ll replace the array with NaN values.

We might be able to help further if you could outline what you’re trying to change about the CorrectIllumination modules? Generating an alternative method for producing the illum function is all well and good, but I’m not sure why you’d then need a modified CorrectIlluminationApply module to use that function?