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

adding widget for adding points layer #20

Merged
merged 4 commits into from
Jan 23, 2025

Conversation

Natali124
Copy link
Contributor

Added code creates a points layer provided a csv file of coordinates and colors together with their features. Features x and y can then be used to plot Maxwell triangle using napari-clusters-plotter.

Copy link
Contributor

@ClementCaporal ClementCaporal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Natali124 for your useful contribution!
I added minor ideas if you have time to implement them.

@magic_factory(call_button="Create a Points layer", auto_call=False)
def read_csv_widget(filename = pathlib.Path('/path/to/csv/file.csv')):
# Getting the current viewer
viewer = napari.current_viewer()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know this existed! Cool!

from magicgui import magic_factory
import pathlib

def rgb_to_xy(r, g, b):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this function name could go to _utils_channel_space.py.
I also suggest to rename to something more specific that rgb_to_xy with something more explicit rgb_to_maxwell_triangle. You can also add a small docstring.

@@ -26,3 +29,6 @@ contributions:
display_name: Diagnose Brainbow Image
- command: napari-brainbow-diagnose.tooltip_pointer_widget
display_name: Brainbow Tooltip
- command: napari-brainbow-diagnose.read_csv_widget
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can reorder the widget list so your contribution comes first (It should be first step as it is a loading step)

points_layer = viewer.add_points(coordinates, name='points', face_color=colors, edge_color=colors, size=20, out_of_slice_display=True)

# Add Maxwell coordinates
df['x'], df['y'] = rgb_to_xy(df['red'], df['green'], df['blue'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe x and y can be renamed x-maxwell-triangle, y-maxwell-triangle to be explicit

@ClementCaporal ClementCaporal merged commit 499287c into LaboratoryOpticsBiosciences:main Jan 23, 2025
@ClementCaporal
Copy link
Contributor

ClementCaporal commented Jan 23, 2025

Thank you again @Natali124! and sorry for the delay

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 this pull request may close these issues.

2 participants