-
Notifications
You must be signed in to change notification settings - Fork 8
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 the option for multiple views loading #197
base: main
Are you sure you want to change the base?
Conversation
Quality Gate passedIssues Measures |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #197 +/- ##
==========================================
+ Coverage 99.68% 99.78% +0.09%
==========================================
Files 11 14 +3
Lines 638 912 +274
==========================================
+ Hits 636 910 +274
Misses 2 2 ☔ View full report in Codecov by Sentry. |
Cross-linking this thread on Zulip, where we are discussing matters relevant to this PR. |
…ormatics-unit#193) * example usage for the median filter * formating and wording tweaks * make example titles and subtitles consistently imperative * finished first full draft of the example * added section about combining smoothing filters * ignore doi link during linkcheck * Apply suggestions from code review Co-authored-by: Chang Huan Lo <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix line lenghts * use px2 instead of dB --------- Co-authored-by: Chang Huan Lo <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* added from_numpy() function to the load_poses module * unit test new function * use from_numpy() function in other loaders as well * add Examples section to docstring and render in API index * add Examples section to docstring and render in API index * confidence array is optional * None is the default for confidence * rename private functions * renamef from_dlc_df to from_dlc_style_df * harmonise docstrings in load_poses * harmonised function names and docstrings in save_poses * harmonised docstrings in validators * split Input/Output section of API index into modules * renamed `_from_lp_or_dlc_file` to `_ds_from_lp_or_dlc_file`
updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.3 → v0.4.7](astral-sh/ruff-pre-commit@v0.4.3...v0.4.7) - [github.com/codespell-project/codespell: v2.2.6 → v2.3.0](codespell-project/codespell@v2.2.6...v2.3.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* bump python versions for PyPI and CI * recommend py3.11 for conda env during installation * display supported python versions as a shield in README * pyupgrade auto-update Union to | syntax
neuroinformatics-unit#206) * Validate required dimensions only * Fix fstring Co-authored-by: Niko Sirmpilatze <[email protected]> * Update docstring --------- Co-authored-by: Niko Sirmpilatze <[email protected]>
* Split validators into modules * Fix API index * Fix API reference * Fix docstring * Move validator module one level up
* move logging.py inside utils * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Skeleton for ValidBboxesDataset class * Add ID string format check * Print all IDs with wrong format * Check IDs are 1-based * Make ID list not optional * Add test for invalid centroid or shape arrays * Add test for invalid ID array * Fix confidence array setting to nan * Add test for confidence array * Add fixtures for valid bboxes arrays * move method to class * Add log message check to invalid_centroid_position_array test * Print attribute.name (rather than attribute) in error messages * Add log messages for shape_array tests * Add logs check for ID attribute * Fix log message * Add log message check to confidence array * Combine pattern matching tests * Change log messages in tests * Rename data array from centroid_position to position * Rename IDs to individual_names * Remove checks for position and shape arrays to be 3 dimensional * Remove enforcing IDs are 1-based in valid bbox class * Make individual_names optional and assign default value * Remove requirement (and test) for a indvidual_names to be in a specific format * Change validator and test to take individual_names as optional inputs * Add fixture request to confidence array test * Clean up * Clean up tests * Fix docstring * Small cosmetic edits * Add assert statement for default confidence matrix * Feedback from code review * Remove some comments * length of box --> extent * Refactor parameters into dict * Refactor as a function * Revert "Refactor as a function" This reverts commit 8056e28. * Clarify docstring for `individual_names` * Add feedback from code review
* Split validators into modules * Split validators tests. Factor out long fixture. * Check log messages in tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add bboxes tests and put dataset fixtures in test file * Fix rebase side effect * Fix ky -> key --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Since [PR208](neuroinformatics-unit#208), python v3.11 is the main version we test across OSes and it's the one we recommend in the installation guide. But I'd forgotten to update the python version in the quick install section of the README. This PR rectifies that.
* Add "type" to sample datasets metadata, to include bbox data * rename pytest fixture POSE_DATA_PATHS to DATA_PATHS * Add 'type' to metadata required fields * Update docs * Apply suggestions from code review Co-authored-by: Chang Huan Lo <[email protected]> * Add platform specific tabs for computing hash * Remove pass for not implemented bit * pytest.DATA_PATHS refactor * Refactor `fetch_dataset_paths` * Update `sample_data` docstrings to accommodate bboxes data * Suggestion from code review * Remove if poses case for now, clarify TODO --------- Co-authored-by: Chang Huan Lo <[email protected]>
updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.7 → v0.5.0](astral-sh/ruff-pre-commit@v0.4.7...v0.5.0) - [github.com/pre-commit/mirrors-mypy: v1.10.0 → v1.10.1](pre-commit/mirrors-mypy@v1.10.0...v1.10.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* API index just lists modules not single funcs * add customised jinja templated for sphinx-autosummary * Sanitise module-level docstrings * pre-commit applied * add modules rubric on api_index page * updated contributing guide section on API reference * monospace formating of attrs in module docstrings * Work around failing tests due to PR#231 * Hide attrs validator functions * Change class section "parameters" to "attributes" * Add MovementDataset class attributes docstrings * Revert "Work around failing tests due to PR#231" This reverts commit fe2c1c4. * Hide class method header if empty * Remove class attributes autosummary table * Remove extra space --------- Co-authored-by: lochhh <[email protected]>
…it#224) * added optional video argument to sample data fetchers * renamed otpional arg to with_video * use the smaller Aeon video for testing video fetching * updated docs section on sample data * apply suggestions from review * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…tics-unit#209) * Draft dataarray accessor * Move dataarray accessor methods to `filtering` * Add dataarray functions, test equality * Add tests * Add integration test * Remove filters taking Dataset as input * Reorganise filtering module * Update filter and smooth examples * Replace `window_length` with `window` * Format assert string * Remove old code accidentally reintroduced during rebase * Update docstrings * Add filtering methods to the `move` accessor * Add example to docstring * Remove obsolete and unused function imports * Move util functions to reports.py and logging.py * Apply suggestions from code review Co-authored-by: Niko Sirmpilatze <[email protected]> * Update docstrings * Add missing docstring * Add `move` accessor examples in docstrings * Remove `position` check in kinematics wrapper * Change`interpolate_over_time` to operate on num of observations * Add test for different `max_gap` values * Update `filter_and_interpolate.py` example * Fix `filtering_wrapper` bug * Update filter examples * Use dictionary `update` in `smooth` example * Move `logger` assignment to top of file * Add `update` example to "getting started" * Cover both dataarray and dataset in `test_log_to_attrs` * Test that ``log`` contains the filtering method applied * Use :py:meth: syntax for xarray.DataArray.squeeze() in examples * Update `reports.py` docstrings * Handle missing `individuals` and `keypoints` dims in NaN-reports * Return str in `report_nan_values` * Clean up examples * Convert filtering multiple data variables tip to section * Use `update()` in `filter_and_interpolate` example --------- Co-authored-by: Niko Sirmpilatze <[email protected]>
* Add zenodo badge and citation to readme * Create CITATION.CFF * Use full names * Add citation file to manifest * Add citation to website * updated citation.cff file after validation by cffinit * remove 2nd date from citation entry * homepage citation is included from README * added Sofia to pyproject.toml authors * harmonise spelling of my own name --------- Co-authored-by: niksirbi <[email protected]>
* Add frame_array to ValidBboxesDataset * Edit log * Add test * Fix docstring * Add missing spaces in warning messages * Change default IDs to 0-based * Adapt sample_data tests to new metadata.yaml file in GIN repo * Refactor shape check * Suggestion for consistent names * Add attribute type * Check frames are contiguous * Add a column vector converter to frame_array * Revert "Add a column vector converter to frame_array" This reverts commit 3a99c1a.
* Add skeleton for ValidVIAtracksCSV class * Add skeleton for ValidVIAtracksCSV test * Draft VIA file validator * Change asserts to errors (WIP) * Remove 1-based integer checks (for track ID and frames). Replace assert by errors * Small edits * Add tests for VIA file (pending fixtures) * Add one fixture * Add frame number as invalid file attribute * Factor out valid header fixture * Add test for frame number wrongly encoded in the filename * Add unique frame numbers test. Check bbox shape. * Add test for region attribute not defined * Add test for track ID not castable as an integer * Add test for unique track IDs per frame * Small edits to comments and docstrings * Apply suggestions from code review Co-authored-by: Niko Sirmpilatze <[email protected]> * Fix test duplicate from rebase * Rename symbols * csv to .csv * Small edits to comments --------- Co-authored-by: Niko Sirmpilatze <[email protected]>
* Updates and suggestions to i/o docs section * Update input output with bboxes edits * Update dataset section with bboxes edits * Update sample data section with bboxes edits * pose --> poses datasets * Fix typo * Add from_numpy * Add example to export csv tracking data * Refer to _poses_ datasets in API reference for loading pose tracking data * Apply suggestions from code review Co-authored-by: Niko Sirmpilatze <[email protected]> * Add bboxes dataset to CONTRIBUTING.md * Clarify 2D poses in dataset docs * Add tabs and shape as code * Change shape formatting back * Fix `ds_type` comment * Add line with `to_dataframe` method * Replace assign_attrs by dict syntax --------- Co-authored-by: Niko Sirmpilatze <[email protected]>
* Automate api_index.rst generation * Revert to using (updated) NIU build and publish docs actions * Include `make` commands in fancy tabs * Swap tab order * Mention index paths in the corresponding tabs
…it#286) * added new movement datasets figure, with caption * update caption according to review comment --------- Co-authored-by: sfmig <[email protected]>
updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.6 → v0.6.3](astral-sh/ruff-pre-commit@v0.5.6...v0.6.3) - [github.com/pre-commit/mirrors-mypy: v1.11.1 → v1.11.2](pre-commit/mirrors-mypy@v1.11.1...v1.11.2) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…#265) * Simplify and expand kinematic tests * Suggestion to rename internal method for clarity * Update docstrings for API reference docs * Add test for values * Refactor test for uniform linear motion * Add notes to dosctrings * Fix kinematics tests * Add fixture with uniform linear motion for poses * Add poses dataset to linear uniform motion test * Add test for dataset with nans * Edits to docstrings * Remove circular fixture * Small edits to fixture comments * Edits to comments in tests * Small edits * Clarify vector vs array in docstrings and make consistent where required * Add missing docstring in test and small edits * Remove TODOs * Fix offset in fixture for uniform linear motion poses * Apply suggestions from code review Co-authored-by: Chang Huan Lo <[email protected]> * Differentiation method Co-authored-by: Chang Huan Lo <[email protected]> * Docstrings fixes * :py:meth: to :meth: * Combine into one paragraph * Add uniform linear motion to doscstring of fixtures * Simplify valid_poses_array_uniform_linear_motion with suggestions * kinematic_variable --> kinematic_array * Simplify test_kinematics_uniform_linear_motion with suggestion from review * Update tests/test_unit/test_kinematics.py Co-authored-by: Chang Huan Lo <[email protected]> * Update tests/test_unit/test_kinematics.py Co-authored-by: Chang Huan Lo <[email protected]> * Cosmetic edits to test * Change docstring to time-derivative --------- Co-authored-by: Chang Huan Lo <[email protected]>
* use ds.sizes insted of ds.dims * Change .dims to .sizes in kinematics tests --------- Co-authored-by: sfmig <[email protected]>
* Add bbox centroid fix * Add tests * Remove loop from assert * Clarify docstring * Remove spaces * Update tests/test_unit/test_load_bboxes.py Co-authored-by: Niko Sirmpilatze <[email protected]> --------- Co-authored-by: Niko Sirmpilatze <[email protected]>
…euroinformatics-unit#294) * replace time dim validator with more generic validator * constrain kinematic functions to cartesian coordinates * renamed new validator to validate_dims_coords * add examples in validator docstring * unit tests for the new validator * Apply suggestions from code review do note validate x,y space coordinates specifically. Co-authored-by: Chang Huan Lo <[email protected]> * reuse fixture valid_poses_dataset_uniform_linear_motion * combine two unit tests into one * expose public `compute_time_derivative` function * Refactor test * Update refs to `compute_time_derivative` --------- Co-authored-by: Chang Huan Lo <[email protected]>
* Basic implementation of `compute_head_direction_vector()` * Minor fixes docstring * Added unit test for `compute_head_direction_vector()` * Bug fixes for `test_compute_head_direction_vector()` * Added validator (and test) to ensure input is 2D * Refactored `navigation.py` and implemented PR review feedback * Extended testing and added `front_keypoint` argument to `compute_head_direction_vector()` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Implemented PR feedback and bugfixes for `compute_2d_head_direction_vector()` * Removed uppercase letters from function names * Tweaked `compute_polar_coordinates.py` to use new function * Implemented feedback from Zulip discussion and created `compute_head_direction_vector()` alias function * Fixed typo in docstring * Tweaked `compute_forward_vector()` to use new validator * More fixes for `test_kinematics.py` * Bugfix for `compute_forward_vector()` and expanded `test_compute_forward_vector` to cover both `camera_view` options * Added test coverage for `compute_head_direction_vector()` alias * Reversed changes to `compute_polar_coordinates.py` and implemented final feedback --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
updates: - [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](pre-commit/pre-commit-hooks@v4.6.0...v5.0.0) - [github.com/astral-sh/ruff-pre-commit: v0.6.3 → v0.6.9](astral-sh/ruff-pre-commit@v0.6.3...v0.6.9) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add filter with nan under threshold and varying window * Get kinematics tests * Adapt integration tests for kinematics+polar * Update integration tests for filtering * Fix factor 2 difference * Update conftest * Remove redundant comment in conftest * Apply feedback from kinematic tests * Cosmetic changes * Spoof user-agent to avoid 403 error * Check different URL * Ignore link to license temporarily * Try fake-useragent * Revert "Try fake-useragent" This reverts commit d67de0e.
…oinformatics-unit#323) * Change command for installation of docs dependencies in the guide. * Small edits to phrasing * Move environment creation to the top of the section * Combine all dependencies installations
…rmatics-unit#304) * first draft of example to convert file formats and changing keypoints * second draft to convert and modify pose track files. I split the function into three separate operations. * formatted the code and gotrid of spelling mistakes for the docs * changed outline of code, new functions now handle ds not fpaths and added additional example function to run on fpath * Apply suggestions from code review added Niko's suggestions, implementing comments Co-authored-by: Niko Sirmpilatze <[email protected]> * pre-commit changes * corrected import error * pre-commit changes again * get rid of extra underlines * finishing touches * added default thumbnail for examples without plots --------- Co-authored-by: Niko Sirmpilatze <[email protected]>
* replace accessor with MovementDataset dataclass * moved pre-save validations inside save_poses module * deleted accessor code and associated tests * define dataset structure in modular classes * updated stale docstring for _validate_dataset() * remove mentions of the accessor from the getting started guide * dropped accessor use in examples * ignore linkcheck for opensource licenses * Revert "ignore linkcheck for opensource licenses" This reverts commit c8f3498. * use ds.sizes instead of ds.dims to suppress warning * Add references * remove movement_dataset.py module --------- Co-authored-by: lochhh <[email protected]>
Hey @vigji, sorry for the long silence on this. I'm going through stale PRs and I think it's time to resurrect this idea. For context, we are slowly undertaking changes to allow for more flexible dimensions in movement datasets, as you had suggested. We got rid of the accessor #322, and with it some overzealous validation steps. Now we only validate the dimensions we actually need, on a per-function basis. We are also planning to reorder the dimensions #236 and stop creating singleton dimensions, but these changes are still to be implemented. Given the above, I think it's time to go forward with this PR. As far as I can tell, the extra "views" dimensions shouldn't prevent you from running filtering and kinematics functions on your datasets. The computations will be simply broadcast across all extra dimensions. I think the first step would be to rebase this PR on the current main branch and check if the function or its docstring need updating. After that, it would just be a matter of modifying some tests - e.g creating a fixture with a multi-view dataset, and adding that to the parameters of some filtering and kinematics tests. I can do that last bit if you can't find the time. Let me know if you'd have time for this in the coming weeks and if you'll need help with anything. |
* Add `clean` action to Windows `make` file * Use `fail-on-warning` mode in Windows `make` file * Drop unused `--keep-going` flag in Makefile * Refactor auto-generate api docs * Update contributing docs * Remove Sphinx version constraint * Document make-mode only * Allow target chaining in Windows make
* added tip for R users * added script for converting admonitions to myst * refactored conversion script
* Draft inter-individual distances * Return vector norm in `compute_interindividual_distances` * Add `compute_interkeypoint_distances` * Refactor pairwise distances tests * Use `scipy.spatial.distance.cdist` * Add examples to docstrings * Rename variables * Update test function args + fix indentation * Handle scalar and 1d dims * Handle missing `core_dim` * Refactor `cdist` and tests * Fix docstrings * Reorder functions + cleanup docs * Reduce pairwise distances functions * Mention examples of available distance metrics * Update docstrings * Require `pairs` in `compute_pairwise_distances` * Raise error if there are no pairs to compute distances for * Rename `core_dim` to `labels_dim` * Spell out expected pairs in test * Merge old `kinematics` file changes into new * Rename `core_dim` to `labels_dim` in tests * Validate dims in `compute_pairwise_distances` * Apply suggestions from code review Co-authored-by: Niko Sirmpilatze <[email protected]> * Apply suggestions from code review Co-authored-by: Niko Sirmpilatze <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Niko Sirmpilatze <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.9 → v0.7.2](astral-sh/ruff-pre-commit@v0.6.9...v0.7.2) - [github.com/pre-commit/mirrors-mypy: v1.11.2 → v1.13.0](pre-commit/mirrors-mypy@v1.11.2...v1.13.0) - [github.com/mgedmin/check-manifest: 0.49 → 0.50](mgedmin/check-manifest@0.49...0.50) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…-unit#280) * implement compute_speed and compute_path_length functions * added speed to existing kinematics unit test * rewrote compute_path_length with various nan policies * unit test compute_path_length across time ranges * fixed and refactor compute_path_length and its tests * fixed docstring for compute_path_length * Accept suggestion on docstring wording Co-authored-by: Chang Huan Lo <[email protected]> * Remove print statement from test Co-authored-by: Chang Huan Lo <[email protected]> * Ensure nan report is printed Co-authored-by: Chang Huan Lo <[email protected]> * adapt warning message match in test * change 'any' to 'all' * uniform wording across path length docstrings * (mostly) leave time range validation to xarray slice * refactored parameters for test across time ranges * simplified test for path lenght with nans * replace drop policy with ffill * remove B905 ruff rule * make pre-commit happy --------- Co-authored-by: Chang Huan Lo <[email protected]>
Trying another ping, @vigji. I'm keen on your input. |
Thanks for re-pinging me and keeping me in the loop! I've lost a bit track of this but I started working back on it just this week, so I'll give this a try. So to confirm, now you think I can just rebase to main and the kinematics functions should work? Also, is there anything holding #236 and dropping singletons back? Do I still have to work under the assumption that I need "individuals" dimensions? adding my arbitrary "view" dimension is not an issue at all in this context? It feels that until you're free to drop singletons you are not really in "time and space are the only requirements" mode yet, right? |
Afaik @lochhh is planning to tackle #236 soon, and nothing should be holding us back from dropping singletons (other than what unforeseen effects we may discover when we try it). If you have a go at it now, assume that So in summary, I suggest implementing the multi-view loading assuming the current number and order of dimensions. When we fix #236 and the singleton problem, it will be our (the maintainers') job to make sure that your function is updated accordingly (together with all other loader functions). That's in the interest of keeping PRs atomic (at least conceptually). Does that make sense? |
Awesome! Yes, it does, I'll give this a try this week :) |
# Conflicts: # movement/io/load_poses.py # tests/test_unit/test_kinematics.py # tests/test_unit/test_load_poses.py
Quality Gate passedIssues Measures |
Description
This PR attempts at defining a loading mode for supporting multi-camera data.
This kind of data structure would be needed by anyone in the process of extracting 3D poses. This is something needed only as long as you do not have yet 3D coordinates, in my case (but I assume in anyone's) the end goal of having multiple views. So, if you want to support only the final, "clean" data where some triangulation of sort already happened, I would understand!
References
Discussion started in #196
How has this PR been tested?
Currently in the process of defining tests, atm just with already existing data, pretending it to be multi-camera.
Is this a breaking change?
If we decide to approve this, it will require some core redefinition in the dataset validator. Currently it seems to be quite strict; if the
view
dimension ends up being optional, it would require some work in theValidator
class. I am not familiar with the processing functions to compute kinematics, in principle I assume the semantic indexing ofxarray
should allow for a smooth handling of this optionality - but I am not yet anxarray
proDoes this PR require an update to the documentation?
If accepted, yes.
If any features have changed, or have been added. Please explain how the
documentation has been updated.
No changes yet
Checklist: