Predict.py plugin module for mutlichannel image error

Hi all,

Has anyone used the predict.py plugin for incorporating pixel classification of multichannel images in CP?

I have 16-bit images from a red and green channel, and it’s causing the module to fail (utilising predict.py on a single channel image is fine). The error I get is as follows:

Failed to run module Predict
Traceback (most recent call last):
File “c:\temp\edlaw89_cellprofiler\cellprofiler\cellprofiler\gui\pipelinecontroller.py”, line 2919, in do_step
self.__pipeline.run_module(module, workspace)
File “c:\temp\edlaw89_cellprofiler\cellprofiler\cellprofiler\pipeline.py”, line 2034, in run_module
module.run(workspace)
File “C:\Temp\edlaw89_CellProfiler\CellProfiler\plugins\CellProfiler-plugins\predict.py”, line 193, in run
raise ioe
IOError: Unable to open file (file signature not found)
Clipping input data to the valid range for imshow with RGB data ([0…1] for floats or [0…255] for integers).
INFO lazyflow.operators.filterOperators: Using fast filters.
WARNING init.py(11): UserWarning: init: Could not import tiktorch classifier
INFO ilastik_main: Starting ilastik from “C:\Program Files\ilastik-1.3.2post1”.
Starting ilastik from “C:\Program Files\ilastik-1.3.2post1”.
WARNING 2019-10-21 10:45:33,906 opConservationTracking 17732 6880 Could not find any ILP solver
WARNING 2019-10-21 10:45:33,929 opStructuredTracking 17732 6880 Could not find any ILP solver
WARNING 2019-10-21 10:45:33,932 structuredTrackingWorkflow 17732 6880 Could not find any learning solver. Tracking will use flow-based solver (DPCT). Learning for tracking will be disabled!
INFO ilastik.shell.projectManager: Opening Project: L:/High-throughput microscopy/CellProfiler/Ilastik Training/Lynsey1.ilp
WARNING stype.py(181): UserWarning: ArrayLike.isCompatible: FIXME here
INFO ilastik.workflows.pixelClassification.pixelClassificationWorkflow: Beginning Batch Processing
ERROR 2019-10-21 10:45:35,903 log_exception 17732 6880 Traceback (most recent call last):
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\ilastik\ilastik\shell\projectManager.py”, line 441, in _loadProject
self.workflow.onProjectLoaded( self )
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\ilastik\ilastik\workflows\pixelClassification\pixelClassificationWorkflow.py”, line 337, in onProjectLoaded
self.batchProcessingApplet.run_export_from_parsed_args(self._batch_input_args)
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\ilastik\ilastik\applets\batchProcessing\batchProcessingApplet.py”, line 66, in run_export_from_parsed_args
return self.run_export(role_path_dict, parsed_args.input_axes, sequence_axis=parsed_args.stack_along)
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\ilastik\ilastik\applets\batchProcessing\batchProcessingApplet.py”, line 131, in run_export
export_to_array=export_to_array)
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\ilastik\ilastik\applets\batchProcessing\batchProcessingApplet.py”, line 239, in _run_export_with_empty_batch_lane
opDataSelectionBatchLaneView.DatasetGroup[role_index].setValue(info)
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\lazyflow\lazyflow\slot.py”, line 118, in call_in_setup_context
return func(self, *args, **kwargs)
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\lazyflow\lazyflow\slot.py”, line 1232, in setValue
self._changed()
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\lazyflow\lazyflow\slot.py”, line 1433, in _changed
c._changed()
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\lazyflow\lazyflow\slot.py”, line 1433, in _changed
c._changed()
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\lazyflow\lazyflow\slot.py”, line 1433, in _changed
c._changed()
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\lazyflow\lazyflow\slot.py”, line 1439, in _changed
self._configureOperator(self)
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\lazyflow\lazyflow\slot.py”, line 1453, in _configureOperator
self.operator._setupOutputs()
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\lazyflow\lazyflow\operator.py”, line 455, in _setupOutputs
self.setupOutputs()
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\ilastik\ilastik\applets\dataSelection\opDataSelection.py”, line 487, in setupOutputs
self.Image.connect(providerSlot)
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\lazyflow\lazyflow\slot.py”, line 118, in call_in_setup_context
return func(self, *args, **kwargs)
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\lazyflow\lazyflow\slot.py”, line 557, in connect
self._changed()
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\lazyflow\lazyflow\slot.py”, line 1433, in _changed
c._changed()
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\lazyflow\lazyflow\slot.py”, line 1433, in _changed
c._changed()
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\lazyflow\lazyflow\slot.py”, line 1433, in _changed
c._changed()
[Previous line repeated 1 more times]
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\lazyflow\lazyflow\slot.py”, line 1439, in _changed
self._configureOperator(self)
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\lazyflow\lazyflow\slot.py”, line 1453, in _configureOperator
self.operator._setupOutputs()
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\lazyflow\lazyflow\operator.py”, line 455, in _setupOutputs
self.setupOutputs()
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\ilastik\ilastik\applets\featureSelection\opFeatureSelection.py”, line 246, in setupOutputs
super().setupOutputs()
File “C:\Program Files\ilastik-1.3.2post1\ilastik-meta\ilastik\ilastik\applets\featureSelection\opFeatureSelection.py”, line 181, in setupOutputs
raise DatasetConstraintError(“Feature Selection”, msg, fixing_dialogs=fix_dlgs)
ilastik.applets.base.applet.DatasetConstraintError: Constraint of ‘Feature Selection’ applet was violated: Some of your selected feature scales are too large for your dataset.
Reduce or remove these scales:
[0.3, 0.7, 1.0, 1.6, 3.5, 5.0, 10.0]
Alternatively use another dataset.

In ilastik, I combined the two channels into a stacked image to perform the training. I am wondering why the dimensions go to “cyx” (channel, y-axis, x-axis), when as a single channel they are in the format “yxc”. Could this cause a problem for the predict module in cellprofiler?

Additionally, I combined my images in cellprofiler into a stacked image, but this did not help either.

Ed

Hi @edward.law,

from the error message you provided I take it appears that your image axes have been interpreted in a wrong way, exactly as you already suspected.
There were a lot of changes regarding handling of input files from 1.3.2 to 1.3.3. Could you maybe just try using the 1.3.3, maybe this fixes it already.

Cheers

Hi @k-dominik,

Thanks I’ll give it a try and get back to you!

Cheers,

Ed

Hi Ed,
Did you ever get anywhere with this?
Having some trouble with predict.py myself!

Hi John,

I’m afraid not. For other reasons, we reduced the work to a single channel. However, I will need to work with multiple channels next year. I’m convinced it’s just a small bug that can be corrected in the predict.py module with the right change to the code, to ensure the channel order matches what ilastik expects.

Otherwise, you’ll need to do your training on each channel individually - not ideal I know!

Cheers,

Ed

Did you ever manage to get the predict module running ok on single channel images?

The issue I’m having is that the module works fine in test mode, but when I try and run my analysis , the pipeline hangs at the end of the module preceding Predict.

Thanks!!

Ah yes, I know this issue well! It’s a problem with the windows GUI version of CellProfiler (3.1.x). Have you tried testing your pipeline to make sure it works as you want, then running it headless from the command line?

Cheers,

Ed

Maybe @Christian_Tischer can help? :slight_smile:

Sorry, not sure here, I have never used it for multi-channel images.

I am also not sure whether this actually should work, because, afaik, Cellprofiler does not have internal logic for multi-channel images (in one image object), but rather wants each channel as a separate image object. At least I have only ever used any of the pipeline modules for single channel image objects.

[EDIT: If one wants to use predict.py with multi-channel images then I guess one would have to add the option to Add image and like this combine several single channel objects images into a multi-channel image. However, maybe this works like this already… ?]

@bcimini, maybe you can say something about this?

1 Like

Hi Ed,
Thanks for the work around! I’ve just noticed that this is up on github as an open issue.

For some reason it says it can’t find ‘predict.py’ in headless mode, but hopefully I can fix that.

Really odd how the pixel prediction does actually run, but only after you cancel the pipeline!

No problem John!

Yes it’s an odd one. Make sure you have included the plugins repository when running headless mode - see cellprofiler instructions for that.

Hopefully cellprofiler 4.0 will fix some of these issues!

Cheers,

Ed

…I was trying to have another look but I cannot find the module neither in my CellProfiler 3.1.9. installation (on a Mac) nor on github: https://github.com/CellProfiler/CellProfiler/tree/master/cellprofiler/modules

I was looking for both the names Predict and ClassifyPixels but I could not find either.

@bcimini @agoodman
Could you point us to the code?
@k-dominik
We looked at the code not too long ago, didn’t we? Do you remember where we found it?

Probably I am just overlooking it…

OK, found it. It is here: https://github.com/CellProfiler/CellProfiler-plugins/blob/8cec9ae4b8219cfe2a518ed1837b8e037804ac11/CellProfiler3/predict.py

I think this line of code fetches a single channel image?!

As said above, I think one would have to extend the UI of predict to allow to add more images and then stack them into one multichannel h5 dataset for ilastik.
@k-dominik what do you think?