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 ternary segmentation input for localisation step #55

Closed
nthndy opened this issue Feb 4, 2022 · 6 comments · Fixed by #48
Closed

add ternary segmentation input for localisation step #55

nthndy opened this issue Feb 4, 2022 · 6 comments · Fixed by #48
Assignees
Milestone

Comments

@nthndy
Copy link
Contributor

nthndy commented Feb 4, 2022

So multi-class segmentation masks are accepted

@nthndy
Copy link
Contributor Author

nthndy commented Feb 4, 2022

@nthndy
Copy link
Contributor Author

nthndy commented Feb 4, 2022

@quantumjot shall i add ternary option or more wider N-ary option in case more than two classes...? in fact do we really need to check if its binary, ternary at all? cant we just pass the segmentation through the label function without checking

@nthndy
Copy link
Contributor Author

nthndy commented Feb 4, 2022

actually @KristinaUlicna just informed me that we shd keep the binary option as it can handle boolean arrays which is faster for big data sets and is generally a good idea to not meddle with preexisting functionality

@quantumjot
Copy link
Owner

I just want to draw your attention to #36 too. In that, @laureho was asking that the actual labels stored in the segmentation (i.e. ternary etc..) become object properties. That would be useful to you too @nthndy as you could use them as cell type markers.

@nthndy
Copy link
Contributor Author

nthndy commented Feb 7, 2022

@quantumjot is there any particular reason this is a tuple? https://github.com/quantumjot/BayesianTracker/blob/0be7225f958b75540ec6957622c9dd6b96f809bb/btrack/_localization.py#L35
Due to its tuple immutability (tuputability, if you like) it means I have to supply the property of class id assignment as a whole other parameter in https://github.com/quantumjot/BayesianTracker/blob/0be7225f958b75540ec6957622c9dd6b96f809bb/btrack/_localization.py#L105
If it were not a tuple we could just add an extra class id argument to properties which I would then delete after use, which seems tidier from a user perspective imo

@nthndy
Copy link
Contributor Author

nthndy commented Feb 7, 2022

@quantumjot quantumjot linked a pull request Feb 8, 2022 that will close this issue
paddyroddy added a commit that referenced this issue Mar 22, 2023
Fixes #55. Needs testing.
paddyroddy added a commit that referenced this issue Mar 22, 2023
* Initial commit

* updated requirements

* Update requirements.txt

* automated conversion to NPE2

* manually remove obsolete decorator

* implement  basic tracking widget

* update test to function widget

- dock widget no longer necessary
- functionality provided via function widget

* Update QT setup on github actions

* Comment out test that isn't yet working

* 💄 Blackify it

* test number of widgets

Co-authored-by: David Stansby <[email protected]>

* Names output layer using segmentation input

* 💄 Blackify

* 💄 Remove tabs from the automated conversion

* Add and run `pre-commit`

* Remove references to `cython`

* Final run of `pre-commit`

* Use v2 of codecov action

* add example script that opens widget

also populates with example cell config and segmentation

* Add dt to widget GUI

* wip:making the tracker config into widgets

* Add vscode

* Being creating widgets programmatically from pydantic

* add widgets for segmentation image, and config save/load

* Ignore vscode

* Add `pre-commit` workflow

* address review comments

- avoid use of private function
- format code with precommit

* fix example docstring

* Move workflow to correct place

* Change to all PRs and pushes to main

* Fix CI

* Tidy up and simplify widget creation

* Use extend instead of append

* Remove unnecessary initialisation

* Use two lists and zip

* Create separate widget methods

* Simplify names for widgets

* Create custom widget

* add dummy callbacks, naive implementation of reset defaults

* naive implementation of run button, uses only default config

* import some useful modules and define some global variables

* flesh out load + save, added matrix helper functionality, make widget scrollable

* fix adaptation from pydantic to widgets and back

* Fix typing issue

* Fix typing for tests?

* Revert "Fix typing for tests?"

This reverts commit 753b40e.

* Fix tests

* write widget-config roundtrip test

* implement naive mode (cell/particle) feature

* derive tracker volume from segmentation size

* make example use labels instead of image layer

* flesh out button tests

* document tests

* make tests py3.7 compatible

* make matrices easier to read

* Update/add docstrings to track.py

* add tooltip help for segmentation

* wip

* revert change to pre-commit config

* fix formatting

* expose max_search_radius to user

* improve comment

* fix tracker.volume computation

* Apply suggestions from code review

improve docstrings and function signature

Co-authored-by: David Stansby <[email protected]>

* improve variable names

* add more complete type hints to test

* add assertion to test_run_button

* call get_scaled_matrix with kwargs, fix E501 in docstring

* store matrices as np.arrays instead of lists

* rely on same viewer reference (initalised once) in the widget and tests

* small improvements from code review

* extend() -> append() where possible

* fix a problem with segmentation choices

* small more-pythonic reformulations

* make intent of hypothesis widget creation clearer

* Add `napari` and fix `magicgui` bug

* Adds isort and black configuration as part of the project

* Removes isort arguments from pre-commit as they are in pyproject

* Changed the line-length value and removed isort properties controlled by black

* isort-ing the project as per the rules defined

* correctly pass DISPLAY and XAUTHORITY env variables to tox (#41)

* Add Q matrix to list of Matrices.names to create widgets for

* Add improved linting

* Run `pre-commit` as is

* Don't create the MotionModel widgets twice

* Satisfy `pre-commit`

* Fix linting

* Import annotations from __future__

* Don't set strict=True when call zip.

It's not supported for Python < 3.10

* More sparing use of `ignore`

* Remove flake8 file (#45)

Missed in #43

* Add issues to project board automatically (#39)

For this to work, we need admin access to add the `ADD_TO_PROJECT_PAT`
environment variable @quantumjot

* Fix failing tests (#47)

Fixes #46 

Tests were failing for various reasons:

- `add_plugin_dock_widget` should be used instead of
`add_function_widget` to add the plugin to napari for testing

- when updating the config with values from the widgets, the widget name
is used to set the key for the corresponding value in the config.
However, for matrices, the widget names are e.g. `A_sigma` but the
matrix name in the config is e.g. `A`. I've added a
`Matrices.widget_name` attribute so we can map between widget names and
matrix names

- in the same function (`_update_widgets_from_config`), the check `if
parameter == "hypotheses` should use an `elif` instead. Otherwise matrix
widgets will be added to the config twice (the second time using the
actual widget name)

I've also removed support and testing of Python 3.7. `BayesianTracker`
is [also only
tested](https://github.com/quantumjot/BayesianTracker/blob/main/.github/workflows/test.yml#L33)
on 3.8 - 3.10

* Forgot toml all flag (#48)

This is like the main benefit!

* Make the btrack widget scrollable (#51)

Fixes #49 

There's now a scrollbar so we can access all the widgets
<img width="1440" alt="scrollbar"
src="https://user-images.githubusercontent.com/29753790/222483511-aa2a8b7c-a65c-4505-a769-477bf0ca564b.png">

Needed to set `scrollable=True` when creating the container

* Move to `pyproject.toml` format (#58)

Fixes #55. Needs testing.

* Use qtpy instead of pyqt5 (#59)

Fixes #50 

- Add `qtpy` as a dependency
- Make `pyqt5` and `pyside2` optional dependencies, specifying the [same
versions as
napari](https://github.com/napari/napari/blob/main/setup.cfg#L91)

* Fix links for readme badges (#62)

Fixes #60 

- change organisation in links to `lowe-lab-ucl`
- refer to `main` branch rather than `master`
- remove badges that can't be displayed because they require a package
to be released on `pypi`

* Remove cell and particle modes to support arbitrary TrackerConfig configs (#64)

Fixes #63 

- handle arbitrary user configs
- when the plugin starts, the example `cell_config` and
`particle_config` files are loaded, and users can load more of their own

This ended up being a bigger refactor than I planned - I need to
refactor quite a few of the functions because they assume there are two
modes ('cell' and 'particle'). And at the same time I moved toward a
more modular structure as has been suggested
lowe-lab-ucl/napari-btrack#26.

**refactor `napari_btrack.track` into various sub-packages and modules**

- `napari_btrack.track`:
    - renamed to `napari_btrack.main`
- contains only code for launching the plugin, defining callback
functions, and running the analysis

- `napari_btrack.config`:
- a new module with classes to handle converting between scaled and
unscaled matrices in `MotionModel`s
- removed `Matrices` class (which hardcoded values for `cell` or
`particle`modes) and replaced with `UnscaledTrackerConfig` to handle
arbitrary user configs

- `napari_btrack.widgets`:
    - a new sub-package for creating the widgets for the plugin

- `napari_btrack.sync`:
- a new module to handle updating a config from widget values or vice
versa

**other changes**

- added per-file-ignores for some linting rules (allow `assert` in test
files, allow unused imports in `__init__.py` files)
- some classes / functions were being imported only for type checking -
move these imports in a check `if TYPE_CHECKING:` so that they're not
imported at runtime
- renamed the function that launches the plugin from
`napari_btrack.track.track` to `napari_btrack.main.create_btrack_widget`
- explicitly set the expected `widget_type` when using
`magicgui.widgets.create_widget` - knowing the widgets we're using
should make it easier to move to using `qt` directly at some point,
which would allow us to have separate tabs for each section
- add tooltips for every widget - they're based on the `btrack` api docs

---------

Co-authored-by: Patrick Roddy <[email protected]>

* Move everything into a `btrack/napari` folder to mirror the parent

* Forgot to move the hidden files

* Remove reference to the old plugin

* Incorporate parts of `pyproject.toml` from `napari-btrack`

* Borrow stuff from `napari-btrack`

* Update linting.yml

* Add qt to CI for tests

* Removing `napari_btrack` folder

* Add examples about the plugin

* Delete unrequired files

* Ignore .envrc

* Add track making widget to repo

* Rename `napari_btrack` to `btrack.napari`

* Make black 79 characters

* Delete `napari.yml`

* Fix linting

* Move `napari-btrack` test to the correct plac

* Always run the reader test

* Remove `numpy` as in `requirements.txt`

* Fix napari test referring to old plugin name

* Fix tests badge

---------

Co-authored-by: quantumjot <[email protected]>
Co-authored-by: alessandrofelder <[email protected]>
Co-authored-by: David Stansby <[email protected]>
Co-authored-by: David Pérez-Suárez <[email protected]>
Co-authored-by: Alessandro Felder <[email protected]>
Co-authored-by: Paul Smith <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants