camap.loaders#

I/O functions for loading behavior and neural data.

Functions

compute_overlap_time_range(neural_timestamp, ...)

Compute the overlapping time range between neural and behavior recordings.

load_behavior_data(behavior_position, ...[, ...])

Load the raw behavior trajectory at behavior rate.

load_visualization_data(neural_path, trace_name)

Load visualization data: traces, max projection, and footprints.

camap.loaders.compute_overlap_time_range(neural_timestamp: Path, behavior_timestamp: Path, use_neural_last_timestamp: bool = True, *, neural_first_col: str = 'timestamp_first', neural_last_col: str = 'timestamp_last', behavior_time_col: str = 'unix_time') tuple[float, float]#

Compute the overlapping time range between neural and behavior recordings.

Parameters:
  • neural_timestamp (Path) – Path to neural timestamp CSV.

  • behavior_timestamp (Path) – Path to behavior timestamp CSV.

  • use_neural_last_timestamp (bool) – Whether to use neural_last_col for neural frames.

  • neural_first_col (str) – Neural timestamp CSV column names for the start- and end-of-exposure times.

  • neural_last_col (str) – Neural timestamp CSV column names for the start- and end-of-exposure times.

  • behavior_time_col (str) – Behavior timestamp CSV column name for the unix time of each frame.

Returns:

(start_time, end_time) of the overlapping window in unix time.

Return type:

tuple[float, float]

camap.loaders.load_behavior_data(behavior_position: Path, behavior_timestamp: Path, bodypart: str, *, x_col: str = 'x', y_col: str = 'y', frame_col: str = 'frame_index', time_col: str = 'unix_time') DataFrame#

Load the raw behavior trajectory at behavior rate.

Returns frame_index, x, y, unix_time. Speed is computed downstream at the neural sample rate against the canonical neural-rate table, so no speed column is attached here.

Parameters:
  • behavior_position (Path) – Path to behavior position CSV file.

  • behavior_timestamp (Path) – Path to behavior timestamp CSV file.

  • bodypart (str) – Body part name to use for trajectory.

  • x_col (str) – Coordinate column names in the behavior CSV.

  • y_col (str) – Coordinate column names in the behavior CSV.

  • frame_col (str) – Frame-index and unix-time column names in the behavior timestamp CSV. Renamed internally to frame_index / unix_time.

  • time_col (str) – Frame-index and unix-time column names in the behavior timestamp CSV. Renamed internally to frame_index / unix_time.

Return type:

DataFrame

camap.loaders.load_visualization_data(neural_path: Path | None, trace_name: str) tuple[Any, ndarray | None, Any]#

Load visualization data: traces, max projection, and footprints.

Parameters:
  • neural_path (Path | None) – Path to neural data directory.

  • trace_name (str) – Name of trace zarr to load.

Returns:

(traces, max_proj, footprints) - xarray DataArray or None for each.

Return type:

tuple