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

Elegantly set thresholds for empty channels #8

Open
adamjtaylor opened this issue Dec 15, 2021 · 0 comments · May be fixed by #9
Open

Elegantly set thresholds for empty channels #8

adamjtaylor opened this issue Dec 15, 2021 · 0 comments · May be fixed by #9

Comments

@adamjtaylor
Copy link

Auto-minerva story.py fails on blank channels as follows (where channel 15 is all zero)
[note there is also a Warning for channel 1]

This is likely to occur for techniques such as MIBI where there is very low contrast, particularly for normal tissues with no/few cells exhibiting a particular marker and for included control channels.

Could we add a try/except into the mixture fitting that perhaps just sets [0,1] threshold when fitting fails

nxf-scratch-dir ip-172-22-12-59.ec2.internal:/tmp/nxf.MWYxHayB6P
opening image: Point3301_31717.ome.tif
reading metadata
WARNING: Could not read OME metadata. Story will use generic channel names and
    the scale bar will be omitted.
analyzing channel 1/45
/venv/lib/python3.9/site-packages/sklearn/mixture/_base.py:143: ConvergenceWarning: Number of distinct clusters (2) found smaller than n_clusters (3). Possibly due to duplicate points in X.
  cluster.KMeans(
analyzing channel 2/45
analyzing channel 3/45
analyzing channel 4/45
analyzing channel 5/45
analyzing channel 6/45
analyzing channel 7/45
analyzing channel 8/45
analyzing channel 9/45
analyzing channel 10/45
analyzing channel 11/45
analyzing channel 12/45
analyzing channel 13/45
analyzing channel 14/45
analyzing channel 15/45
Traceback (most recent call last):
  File "/auto-minerva/story.py", line 139, in
    main()
  File "/auto-minerva/story.py", line 120, in main
    vmin, vmax = auto_threshold(img)
  File "/auto-minerva/story.py", line 22, in auto_threshold
    gmm.fit(img_log.reshape((-1,1)))
  File "/venv/lib/python3.9/site-packages/sklearn/mixture/_base.py", line 198, in fit
    self.fit_predict(X, y)
  File "/venv/lib/python3.9/site-packages/sklearn/mixture/_base.py", line 228, in fit_predict
    X = self._validate_data(X, dtype=[np.float64, np.float32], ensure_min_samples=2)
  File "/venv/lib/python3.9/site-packages/sklearn/base.py", line 561, in _validate_data
    X = check_array(X, **check_params)
  File "/venv/lib/python3.9/site-packages/sklearn/utils/validation.py", line 797, in check_array
    raise ValueError(
ValueError: Found array with 0 sample(s) (shape=(0, 1)) while a minimum of 2 is required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant