-
Notifications
You must be signed in to change notification settings - Fork 10
Handle NaNs #360
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
Comments
how about we implement this in a minor version prior to v0.9.0? I think this would already be useful for the next workshop, I am getting errors with the dimensionality reduction algorithms sometimes because of this. |
It's a bit strange because this problem was encountered before and also fixed by #70 so I'm not quite sure why the algorithms fail sometimes... 🤔 |
I am using version I managed to make a MWE: Draw a label with a single pixel (and a couple others larger if you like) and measure all features with napari-skimage-regionprops. You will end up with a table with Then run UMAP with default parameters. I got the errors below and napari shuts itself down after a few seconds.
The |
@zoccoler Can not reproduce, unfortunately. This is my test code: import numpy as np
import napari
import pandas as pd
import napari_clusters_plotter as ncp
ncp.__version__
labels = np.zeros((100, 100), dtype=int)
labels[:1, :1] = 1
labels[10:15, 10:15] = 2
labels[20:25, 20:25] = 3
labels[30:35, 30:35] = 4
labels[40:45, 40:45] = 5
labels[50:55, 50:55] = 6
labels[60:65, 60:65] = 7
features = pd.DataFrame({
'label': [1, 2, 3, 4, 5, 6, 7],
'feature1': [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7],
'feature2': [0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0],
'feature3': [0.7, np.nan, 0.9, 1.0, 1.1, 1.2, 1.3]
})
viewer = napari.Viewer()
viewer.add_labels(labels, name='labels', features=features) When I run a UMAP on this data, the result looks just fine. If I add np.inf to the data, then the workflow still works - which it shouldn't. My susspicion here would be that the problem is that Edit: Version is also |
I ran your code and it works, but if I get the measurements using napari-skimage-regionprops (no intensity and moments in this case) and then run UMAP on all features, I get some warnings and the UMAP columns never show up.
Or this:
It is somehow inconsistent though, it does not always fail. One problem could be running UMAP with way more columns/features than rows. I can't identify fully the problem, so let's not change now to check if this really becomes an issue in the near future. I like the catching NaN decorator approach, maybe we could blend |
I tried that and I think we run into problems if we try to handle |
When using the algorithm widgets, there is no check for NaNs in the processed dataframes. To handle these correctly, NaN rows should be removed before passing the data onto the respective algorithm. Likewise, the NaN rows should be added again after the processing or napari will complain that the number of features in the input/outputs doesn't match.
The text was updated successfully, but these errors were encountered: