Skip to content

Commit

Permalink
Moseq Pipeline (LorenFrankLab#1056)
Browse files Browse the repository at this point in the history
* Add organization tables for keypoint pose data

* Add model training tables

* apply fit moseq model to data

* add ability to initialize model training from pre-existing model

* make model names unique

* add initial tutorial

* add moseq pipeline diagram

* get rid of PoseOutput and fetch pose data from PositionOutput

* remove PoseOutput and corresponding references

* allow passing of null entries from DLCPoseEstimation to PositionOutput for Pose-dependent analysis

* Apply suggestions from code review

Co-authored-by: Chris Broz <[email protected]>

* lint

* implement changes from review

* rename fetch_video_name to fetch_video_path

* cleanup outdated usages of PoseOutput

* Cleanup errors from removal of PoseOutput

* add get_position_interval_epoch

* Add method to get training results pdf

* Add description and example of hyperparameter sweep

* move moseq dir definition to spyglass config

* move moseq config function to method

* Update changelog

* update pipeline diagram

* Apply suggestions from code review

Co-authored-by: Chris Broz <[email protected]>

* move moseq into v1 folder

* add docstrings

* make video symlink more robust

* cleanup setup_project call

* cleanup config method

* Implement suggestions from code review

* cleanup readability of DLCPosV1 make conditions

* allow key argument when fetching video path

* add moseq dependencies

* Add moseq install instructions to tutorials

* accept key in all get video path functions

* fix spelling

* fix spelling

* make model project dir unique

* add default empty restriction

* add moseq to omitted tests

* tutorial error cleanup

* fix for codespell update

* typo fix

* remove jax version pin

* add docstrings

* make restriction in fetch_pose_dataframe compatible with export

* add moseq dirs to config example

* Update src/spyglass/position/v1/position_dlc_pose_estimation.py

Co-authored-by: Chris Broz <[email protected]>

* cleanup long settings if statements

* change to and register the behavior schema  prefix

* Update src/spyglass/position/position_merge.py

Co-authored-by: Chris Broz <[email protected]>

* lint

---------

Co-authored-by: Samuel Bray <[email protected]>
Co-authored-by: Samuel Bray <[email protected]>
Co-authored-by: Chris Broz <[email protected]>
  • Loading branch information
4 people authored Feb 27, 2025
1 parent 4f39dfa commit 2b71fb3
Show file tree
Hide file tree
Showing 26 changed files with 4,245 additions and 57 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Ensure merge tables are declared during file insertion #1205
- Update URL for DANDI Docs #1210
- Add common method `get_position_interval_epoch` #1056
- Improve cron job documentation and script #1226, #1241
- Update export process to include `~external` tables #1239
- Only add merge parts to `source_class_dict` if present in codebase #1237
Expand All @@ -22,6 +23,10 @@
- Fix compatibility bug between v1 pipeline and `SortedSpikesGroup` unit
filtering #1238

- Behavior
- Implement pipeline for keypoint-moseq extraction of behavior syllables #1056


## [0.5.4] (December 20, 2024)

### Infrastructure
Expand Down
5 changes: 5 additions & 0 deletions dj_local_conf_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
"video": "/your/base/path/deeplabcut/video",
"output": "/your/base/path/deeplabcut/output"
},
"moseq_dirs": {
"base": "/your/base/path/moseq",
"project": "/your/base/path/moseq/projects",
"video": "/your/base/path/moseq/video",
},
"kachery_zone": "franklab.default"
}
}
42 changes: 42 additions & 0 deletions environment_moseq_cpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 1. Install a conda distribution.
# https://mamba.readthedocs.io/en/latest/installation/mamba-installation.html
# 2. Run: `mamba env create -f environment.yml`
# 3. Activate: `conda activate spyglass`
#
# (lines intentionally left blank)
#
#
name: spyglass-moseq-cpu
channels:
- conda-forge
# - defaults # deprecated
- franklab
- edeno
# - pytorch # dlc-only
# - anaconda # dlc-only, for cudatoolkit
dependencies:
- bottleneck
# - cudatoolkit=11.3 # dlc-only
# - ffmpeg # dlc-only
- ipympl
- jupyterlab>=3.*
# - libgcc # dlc-only
- matplotlib
- non_local_detector
- numpy
- pip
- position_tools
- pybind11 # req by mountainsort4 -> isosplit5
- pydotplus
- pyfftw<=0.12.0 # ghostipy req. install from conda-forge for Mac ARM
- python>=3.9,<3.13
- pytorch<1.12.0
- ripple_detection
- seaborn
# - torchaudio # dlc-only
# - torchvision # dlc-only
- track_linearization>=2.3
- pip:
- ghostipy # for common_filter
- mountainsort4
- .[moseq-cpu]
42 changes: 42 additions & 0 deletions environment_moseq_gpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 1. Install a conda distribution.
# https://mamba.readthedocs.io/en/latest/installation/mamba-installation.html
# 2. Run: `mamba env create -f environment.yml`
# 3. Activate: `conda activate spyglass`
#
# (lines intentionally left blank)
#
#
name: spyglass-moseq-gpu
channels:
- conda-forge
# - defaults # deprecated
- franklab
- edeno
# - pytorch # dlc-only
# - anaconda # dlc-only, for cudatoolkit
dependencies:
- bottleneck
# - cudatoolkit=11.3 # dlc-only
# - ffmpeg # dlc-only
- ipympl
- jupyterlab>=3.*
# - libgcc # dlc-only
- matplotlib
- non_local_detector
- numpy
- pip
- position_tools
- pybind11 # req by mountainsort4 -> isosplit5
- pydotplus
- pyfftw<=0.12.0 # ghostipy req. install from conda-forge for Mac ARM
- python>=3.9,<3.13
- pytorch<1.12.0
- ripple_detection
- seaborn
# - torchaudio # dlc-only
# - torchvision # dlc-only
- track_linearization>=2.3
- pip:
- ghostipy # for common_filter
- mountainsort4
- .[moseq-gpu]
Binary file added notebook-images/moseq_outline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 43 additions & 3 deletions notebooks/00_Setup.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,47 @@
"The Decoding pipeline relies on `jax` to process data with GPUs. Please see\n",
"their conda installation steps\n",
"[here](https://jax.readthedocs.io/en/latest/installation.html#conda-installation).\n",
"\n"
"\n",
"#### Deep Lab Cut (DLC)\n",
"\n",
"Spyglass provides an environment build for using the DLC pipeline. To create an \n",
"environment with these features, please:\n",
"1. navigate to your cloned spyglass repo.\n",
"2. build the environment from the dlc version\n",
"3. activate the environment to use\n",
"\n",
"```bash\n",
"cd /path/to/spyglass # 1\n",
"mamba env create -f environment_dlc.yml # 2\n",
"mamba activate spyglass-dlc # 3\n",
"```\n",
"\n",
"Alternatively, you can pip install using\n",
"```bash\n",
"pip install spyglass[dlc]\n",
"```\n",
"\n",
"#### Keypoint-Moseq\n",
"\n",
"Spyglass provides an environment build for using the Moseq pipeline. To create an \n",
"environment with these features, please:\n",
"1. navigate to your cloned spyglass repo.\n",
"2. build the environment from one of the moseq versions\n",
"3. activate the environment to use\n",
"\n",
"```bash\n",
"cd /path/to/spyglass # 1\n",
"mamba env create -f environment_moseq_cpu.yml # 2\n",
"mamba activate spyglass-moseq-cpu # 3\n",
"```\n",
"\n",
"Alternatively, you can pip install using\n",
"```bash\n",
"pip install spyglass[moseq-cpu]\n",
"```\n",
"\n",
"To use a GPU enabled version of the package, replace `cpu` with `gpu` in the above \n",
"commands\n"
]
},
{
Expand Down Expand Up @@ -593,7 +633,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "spyglass",
"language": "python",
"name": "python3"
},
Expand All @@ -607,7 +647,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.19"
"version": "3.9.18"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 2b71fb3

Please sign in to comment.