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

Import header from brainglobe-utils #399

Merged
merged 2 commits into from
Apr 15, 2024
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
8 changes: 2 additions & 6 deletions cellfinder/napari/detect/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
from cellfinder.core.classify.cube_generator import get_cube_depth_min_max
from cellfinder.napari.utils import (
add_layers,
header_label_widget,
cellfinder_header,
html_label_widget,
widget_header,
)

from .detect_containers import (
Expand All @@ -40,7 +39,6 @@ def detect_widget() -> FunctionGui:
progress_bar = ProgressBar()

@magicgui(
header=header_label_widget,
detection_label=html_label_widget("Cell detection", tag="h3"),
**DataInputs.widget_representation(),
**DetectionInputs.widget_representation(),
Expand All @@ -52,7 +50,6 @@ def detect_widget() -> FunctionGui:
scrollable=True,
)
def widget(
header,
detection_label,
data_options,
viewer: napari.Viewer,
Expand Down Expand Up @@ -205,8 +202,7 @@ def update_progress_bar(label: str, max: int, value: int):
worker.update_progress_bar.connect(update_progress_bar)
worker.start()

widget.header.value = widget_header
widget.header.native.setOpenExternalLinks(True)
widget.native.layout().insertWidget(0, cellfinder_header())

@widget.reset_button.changed.connect
def restore_defaults():
Expand Down
Binary file removed cellfinder/napari/images/brainglobe.png
Binary file not shown.
11 changes: 2 additions & 9 deletions cellfinder/napari/train/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
from qtpy.QtWidgets import QScrollArea

from cellfinder.core.train.train_yml import run as train_yml
from cellfinder.napari.utils import (
header_label_widget,
html_label_widget,
widget_header,
)
from cellfinder.napari.utils import cellfinder_header, html_label_widget

from .train_containers import (
MiscTrainingInputs,
Expand Down Expand Up @@ -41,7 +37,6 @@ def run_training(

def training_widget() -> FunctionGui:
@magicgui(
header=header_label_widget,
training_label=html_label_widget("Network training", tag="h3"),
**TrainingDataInputs.widget_representation(),
**OptionalNetworkInputs.widget_representation(),
Expand All @@ -52,7 +47,6 @@ def training_widget() -> FunctionGui:
scrollable=True,
)
def widget(
header: dict,
training_label: dict,
data_options: dict,
yaml_files: Path,
Expand Down Expand Up @@ -161,8 +155,7 @@ def widget(
)
worker.start()

widget.header.value = widget_header
widget.header.native.setOpenExternalLinks(True)
widget.native.layout().insertWidget(0, cellfinder_header())

@widget.reset_button.changed.connect
def restore_defaults():
Expand Down
35 changes: 13 additions & 22 deletions cellfinder/napari/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,7 @@
import numpy as np
import pandas as pd
from brainglobe_utils.cells.cells import Cell
from pkg_resources import resource_filename

brainglobe_logo = resource_filename(
"cellfinder", "napari/images/brainglobe.png"
)


widget_header = """
<p>Efficient cell detection in large images.</p>
<p><a href="https://brainglobe.info" style="color:gray;">Website</a></p>
<p><a href="https://brainglobe.info/documentation/cellfinder/user-guide/napari-plugin/index.html" style="color:gray;">Documentation</a></p>
<p><a href="https://github.com/brainglobe/cellfinder" style="color:gray;">Source</a></p>
<p><a href="https://doi.org/10.1371/journal.pcbi.1009074" style="color:gray;">Citation</a></p>
<p><small>For help, hover the cursor over each parameter.</small>
""" # noqa: E501
from brainglobe_utils.qtpy.logo import header_widget


def html_label_widget(label: str, *, tag: str = "b") -> dict:
Expand All @@ -31,13 +17,18 @@ def html_label_widget(label: str, *, tag: str = "b") -> dict:
)


header_label_widget = html_label_widget(
f"""
<img src="{brainglobe_logo}"width="100">
<p>cellfinder</p>
""",
tag="h1",
)
def cellfinder_header():
"""
Create the header containing the brainglobe logo and documentation links
for all cellfinder widgets.
"""
return header_widget(
"cellfinder",
"Efficient cell detection in large images.",
documentation_path="cellfinder/user-guide/napari-plugin/index.html",
citation_doi="https://doi.org/10.1371/journal.pcbi.1009074",
help_text="For help, hover the cursor over each parameter.",
)


def add_layers(points: List[Cell], viewer: napari.Viewer) -> None:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ classifiers = [
]
requires-python = ">=3.9"
dependencies = [
"brainglobe-utils>=0.4.2",
"brainglobe-utils>=0.4.3",
"brainglobe-napari-io>=0.3.4",
"dask[array]",
"fancylog>=0.0.7",
Expand Down
Loading