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 batch selection by category/description/type #45

Closed
droumis opened this issue Oct 11, 2023 · 4 comments
Closed

Add batch selection by category/description/type #45

droumis opened this issue Oct 11, 2023 · 4 comments
Assignees

Comments

@droumis
Copy link
Member

droumis commented Oct 11, 2023

Issue:

In neuroscience multi-timeseries plots, the capability to select and modify all annotations associated with a specific description is crucial. Typically, these plots have fewer than 10 unique descriptions, yet a single description can encompass over 100 annotations. For efficient editing or removal of annotations under a specific description, a batch-select feature becomes indispensable. This batch-select is distinct but complementary to a shift-select feature (which also should be implemented), the latter being more apt for selecting a smaller number of annotations or those spanning multiple descriptions.

Proposed Solution:

Introduce a dropdown widget for category batch action:

  • The dropdown will list various description categories available.
  • Selecting an option from the dropdown will automatically select all annotations of that category for batch editing or removal.
  • Ensure synchronization between the dropdown values and the annotation table. Editing a description should reflect in the dropdown options.
  • The dropdown option colors should correspond to the color of the annotations in that description category.
  • The description field itself should be 'category' dtype.
@droumis
Copy link
Member Author

droumis commented Oct 18, 2023

This seems somewhat related to #42, although I'm not entirely clear on the scope of request on that one

@hoxbro hoxbro self-assigned this Dec 5, 2023
@hoxbro
Copy link
Member

hoxbro commented Jan 31, 2024

Updating multiple fields is possible by using annotator.update_annotation_fields. Some of the other criteria you setup likely need to be more tailored as an app:

Setup annotator

import hvplot.pandas
import pandas as pd
from holonote.annotate import Annotator, SQLiteDB


speed_data = pd.read_parquet("../assets/example.parquet")
curve = speed_data.hvplot("TIME", "SPEED")

annotator = Annotator(
    curve,
    fields=["category", "description"],
    connector=SQLiteDB(table_name="example"),
)

start_time = pd.date_range("2022-06-04", "2022-06-22", periods=5)
end_time = start_time + pd.Timedelta(days=2)
data = {
    "start_time": start_time,
    "end_time": end_time,
    "category": ["A", "B", "A", "C", "B"],
    "description": ["A", "B", "A", "C", "B"],
}
annotator.define_annotations(pd.DataFrame(data), TIME=("start_time", "end_time"))

Creating the app:

import panel as pn


def update_test_input(v):
    df = annotator.df
    mask = df.category == v
    text_input.value = df[mask].iloc[0]["description"]


def update_index(*e):
    indexes = annotator.df.category == widget.value
    annotator.update_annotation_fields(indexes, description=text_input.value)


widget = pn.widgets.Select(value="A", options=["A", "B", "C"], name="Category")
text_input = pn.widgets.TextInput(name="Description")
button = pn.widgets.Button(name="Update")

annotator.groupby = "category"
# annotator.visible = widget.rx.pipe(lambda x: [x])  # If you want to only show the category itself

button.on_click(update_index)

update_test_input(widget.value)
pn.bind(update_test_input, widget, watch=True)

pn.Row(pn.Column(widget, text_input, button), annotator * curve)
screenrecord-2024-01-31_12.37.22.mp4

@droumis droumis changed the title Add batch selection by description Add batch selection by category/description Mar 6, 2024
@droumis droumis changed the title Add batch selection by category/description Add batch selection by category/description/type Mar 6, 2024
@droumis
Copy link
Member Author

droumis commented Mar 6, 2024

Small point just to avoid further confusion, I wanted to clarify something: your code snippet treats category and description as two different fields; I was using these terms interchangeably to mean the 'primary' categorical identifier for a set of annotations (mostly because I had seen the term 'description' used in this repo for such a field in the past).

But let's call this primary field 'Category' from now on in this issue.

So for each Category of annotations, we need a UI demonstration of the following:

  • Edit the name of an entire category (e.g. change Category 'A' to Category 'AA'). This change should be reflected in the UI dropdown options.
  • Delete an entire category
  • An way to display all the annotation categories at once, categorically colored, or display certain categories

I haven't yet figured out a way to do these things.

@droumis
Copy link
Member Author

droumis commented Apr 20, 2024

superseded by #99

@droumis droumis closed this as completed Apr 20, 2024
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

No branches or pull requests

2 participants