Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
17 changes: 17 additions & 0 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ jobs:
auto-update-conda: true
channels: conda-forge,defaults
activate-environment: movement-env
- name: "Ensure D: Drive on Windows"
if: matrix.os == 'windows-latest'
shell: cmd
run: |
echo Current directory: %CD%
if not "%CD:~0,2%"=="D:" (
echo Switching to D: drive
D:
cd "%GITHUB_WORKSPACE%"
if not "%CD:~0,2%"=="D:" (
echo ERROR: Failed to switch to D: drive
exit 1
)
echo Now on: %CD%
) else (
echo Already on D: drive
)
- uses: neuroinformatics-unit/actions/test@v2
with:
python-version: ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ To add a new file, you will need to:
```yaml
"SLEAP_three-mice_Aeon_proofread.analysis.h5":
sha256sum: "82ebd281c406a61536092863bc51d1a5c7c10316275119f7daf01c1ff33eac2a"
source_software: "SLEAP"
source_format: "SLEAP"
type: "poses" # "poses" or "bboxes" depending on the type of tracked data
fps: 50
species: "mouse"
Expand Down
10 changes: 5 additions & 5 deletions docs/source/user_guide/input_output.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ds = load_poses.from_sleap_file("/path/to/file.analysis.h5", fps=30)

# or equivalently
ds = load_poses.from_file(
"/path/to/file.analysis.h5", source_software="SLEAP", fps=30
"/path/to/file.analysis.h5", source_format="SLEAP", fps=30
)
```
To load [SLEAP analysis files](sleap:tutorials/analysis) in .slp format (experimental, see notes in {func}`movement.io.load_poses.from_sleap_file`):
Expand All @@ -62,7 +62,7 @@ ds = load_poses.from_dlc_file("/path/to/file.h5", fps=30)

# or equivalently
ds = load_poses.from_file(
"/path/to/file.h5", source_software="DeepLabCut", fps=30
"/path/to/file.h5", source_format="DeepLabCut", fps=30
)
```

Expand All @@ -80,7 +80,7 @@ ds = load_poses.from_lp_file("/path/to/file.analysis.csv", fps=30)

# or equivalently
ds = load_poses.from_file(
"/path/to/file.analysis.csv", source_software="LightningPose", fps=30
"/path/to/file.analysis.csv", source_format="LightningPose", fps=30
)
```
:::
Expand All @@ -95,7 +95,7 @@ ds = load_poses.from_anipose_file(

# or equivalently
ds = load_poses.from_file(
"/path/to/file.analysis.csv", source_software="Anipose", fps=30, individual_name="individual_0"
"/path/to/file.analysis.csv", source_format="Anipose", fps=30, individual_name="individual_0"
)

```
Expand Down Expand Up @@ -149,7 +149,7 @@ ds = load_bboxes.from_via_tracks_file("path/to/file.csv", fps=30)
# or equivalently
ds = load_bboxes.from_file(
"path/to/file.csv",
source_software="VIA-tracks",
source_format="VIA-tracks",
fps=30,
)
```
Expand Down
6 changes: 3 additions & 3 deletions docs/source/user_guide/movement_dataset.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Data variables:
Attributes:
fps: 50.0
time_unit: seconds
source_software: SLEAP
source_format: SLEAP
source_file: /home/user/.movement/data/poses/SLEAP_three-mice_Aeon...
ds_type: poses
frame_path: /home/user/.movement/data/frames/three-mice_Aeon_fram...
Expand Down Expand Up @@ -88,7 +88,7 @@ Data variables:
confidence (time, individuals) float64 3kB nan nan nan nan ... nan nan nan
Attributes:
time_unit: frames
source_software: VIA-tracks
source_format: VIA-tracks
source_file: /home/user/.movement/data/bboxes/VIA_multiple-crabs_5...
ds_type: bboxes
```
Expand Down Expand Up @@ -175,7 +175,7 @@ Both poses and bounding boxes datasets in `movement` have associated metadata. T
Right after loading a `movement` dataset, the following **attributes** are created:
- `fps`: the number of frames per second in the video (absent if not provided by the user during loading).
- `time_unit`: the unit of the `time` **coordinates** (either `frames` or `seconds`).
- `source_software`: the software that produced the pose or bounding box tracks.
- `source_format`: the software that produced the pose or bounding box tracks.
- `source_file`: the path to the file from which the data were loaded (absent if the dataset was not loaded from a file).
- `ds_type`: the type of dataset loaded (either `poses` or `bboxes`).

Expand Down
22 changes: 11 additions & 11 deletions movement/io/load_bboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def from_numpy(
individual_names: list[str] | None = None,
frame_array: np.ndarray | None = None,
fps: float | None = None,
source_software: str | None = None,
source_format: str | None = None,
) -> xr.Dataset:
"""Create a ``movement`` bounding boxes dataset from NumPy arrays.

Expand Down Expand Up @@ -70,7 +70,7 @@ def from_numpy(
the ``time`` coordinates are in seconds, they will indicate the
elapsed time from the capture of the first frame (assumed to be frame
0).
source_software : str, optional
source_format : str, optional
Name of the software that generated the data. Defaults to None.

Returns
Expand Down Expand Up @@ -145,14 +145,14 @@ def from_numpy(
individual_names=individual_names,
frame_array=frame_array,
fps=fps,
source_software=source_software,
source_format=source_format,
)
return _ds_from_valid_data(valid_bboxes_data)


def from_file(
file_path: Path | str,
source_software: Literal["VIA-tracks"],
source_format: Literal["VIA-tracks"],
fps: float | None = None,
use_frame_numbers_from_file: bool = False,
frame_regexp: str = DEFAULT_FRAME_REGEXP,
Expand All @@ -166,7 +166,7 @@ def from_file(
file_path : pathlib.Path or str
Path to the file containing the tracked bounding boxes. Currently
only VIA-tracks .csv files are supported.
source_software : "VIA-tracks".
source_format : "VIA-tracks".
The source software of the file. Currently only files from the
VIA 2.0.12 annotator [1]_ ("VIA-tracks") are supported.
See .
Expand Down Expand Up @@ -216,12 +216,12 @@ def from_file(
>>> from movement.io import load_bboxes
>>> ds = load_bboxes.from_file(
>>> "path/to/file.csv",
>>> source_software="VIA-tracks",
>>> source_format="VIA-tracks",
>>> fps=30,
>>> )

"""
if source_software == "VIA-tracks":
if source_format == "VIA-tracks":
return from_via_tracks_file(
file_path,
fps,
Expand All @@ -230,7 +230,7 @@ def from_file(
)
else:
raise log_error(
ValueError, f"Unsupported source software: {source_software}"
ValueError, f"Unsupported source software: {source_format}"
)


Expand Down Expand Up @@ -356,11 +356,11 @@ def from_via_tracks_file(
else None
),
fps=fps,
source_software="VIA-tracks",
source_format="VIA-tracks",
) # it validates the dataset via ValidBboxesDataset

# Add metadata as attributes
ds.attrs["source_software"] = "VIA-tracks"
ds.attrs["source_format"] = "VIA-tracks"
ds.attrs["source_file"] = file.path.as_posix()

logger.info(f"Loaded tracks of the bounding boxes from {via_file.path}:")
Expand Down Expand Up @@ -666,7 +666,7 @@ def _ds_from_valid_data(data: ValidBboxesDataset) -> xr.Dataset:
time_unit = "frames"

dataset_attrs: dict[str, str | float | None] = {
"source_software": data.source_software,
"source_format": data.source_format,
"ds_type": "bboxes",
}
# if fps is provided:
Expand Down
Loading