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

Add magicgui to requirements #16

Merged
merged 7 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension-pkg-whitelist=pyqt, pyqt5, pyqt5-qt5
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ install_requires =
matplotlib
scipy
napari-clusters-plotter >= 0.7.2
magicgui
python_requires = >=3.10
include_package_data = True
package_dir =
Expand Down
19 changes: 13 additions & 6 deletions src/napari_tomotwin/load_umap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
import numpy as np
from matplotlib.patches import Circle
from napari.utils import notifications

from qtpy.QtCore import Qt
from qtpy.QtGui import QGuiApplication # pylint: disable=E0611
from typing import List

Check warning on line 11 in src/napari_tomotwin/load_umap.py

View check run for this annotation

Codecov / codecov/patch

src/napari_tomotwin/load_umap.py#L9-L11

Added lines #L9 - L11 were not covered by tests
plotter_widget: PlotterWidget = None
circle: Circle = None
circles: List[Circle] = []

Check warning on line 13 in src/napari_tomotwin/load_umap.py

View check run for this annotation

Codecov / codecov/patch

src/napari_tomotwin/load_umap.py#L13

Added line #L13 was not covered by tests
umap: pd.DataFrame

def _draw_circle(data_coordinates, label_layer, umap):
global circle
global circles
global plotter_widget

label_layer.visible = 1
Expand All @@ -26,10 +28,15 @@
center = umap_coordinates.values.tolist()[0]
except IndexError:
return

if circle is not None:
circle.remove()
modifiers = QGuiApplication.keyboardModifiers()
if modifiers == Qt.ShiftModifier:
pass

Check warning on line 33 in src/napari_tomotwin/load_umap.py

View check run for this annotation

Codecov / codecov/patch

src/napari_tomotwin/load_umap.py#L31-L33

Added lines #L31 - L33 were not covered by tests
else:
for c in circles[::-1]:
c.remove()
circles = []

Check warning on line 37 in src/napari_tomotwin/load_umap.py

View check run for this annotation

Codecov / codecov/patch

src/napari_tomotwin/load_umap.py#L35-L37

Added lines #L35 - L37 were not covered by tests
circle = Circle(tuple(center), 0.5, fill=False, color='r')
circles.append(circle)

Check warning on line 39 in src/napari_tomotwin/load_umap.py

View check run for this annotation

Codecov / codecov/patch

src/napari_tomotwin/load_umap.py#L39

Added line #L39 was not covered by tests
plotter_widget.graphics_widget.axes.add_patch(circle)
plotter_widget.graphics_widget.draw_idle()

Expand Down
3 changes: 2 additions & 1 deletion src/napari_tomotwin/make_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
"""
if len(embeddings)>max_embeddings:
# For samples more than 50k it's way to slow and memory hungry.
embeddings = embeddings.sample(max_embeddings)
print(f"Your cluster size ({len(embeddings)}) is bigger then {max_embeddings}. Make a random sample to calculate medoid.")
embeddings = embeddings.sample(max_embeddings)

Check warning on line 19 in src/napari_tomotwin/make_targets.py

View check run for this annotation

Codecov / codecov/patch

src/napari_tomotwin/make_targets.py#L19

Added line #L19 was not covered by tests

only_emb = embeddings.drop(columns=["X", "Y", "Z", "filepath"], errors="ignore").astype(np.float32)
distance_matrix=cdist(only_emb,only_emb,metric='cosine') # its not the cosine similarity, rather a distance (its 0 in case of same embeddings)
medoid_index = np.argmin(np.sum(distance_matrix,axis=0))
Expand Down
Loading