camap.config

On this page

camap.config#

Configuration models loaded from YAML.

Classes

AnalysisConfig(*, neural, behavior)

Top-level analysis config combining neural and behavior settings.

ArenaBehaviorDataConfig(*, fps, position, ...)

Arena (2D open-field) behavior data config.

BaseBehaviorDataConfig(*, fps, position, ...)

Behavior data paths and shared calibration.

BaseSpatialMapConfig(*, min_occupancy, ...)

Shared spatial map config: occupancy, smoothing, shuffle testing, stability.

BehaviorConfig(*, type, speed_threshold[, ...])

Behavior filtering and spatial map selection.

DataConfig(*[, neural, behavior, ...])

Per-session data config: optional neural and behavior blocks.

MazeBehaviorDataConfig(*, fps, position, ...)

Maze (1D arm) behavior data config.

NeuralConfig(*, fps, oasis[, trace_name])

Neural data paths and deconvolution settings.

NeuralDataConfig(*, path, timestamp)

Neural data paths.

OasisConfig(*, g[, baseline, penalty, s_min])

OASIS AR(2) deconvolution parameters.

SpatialMap1DConfig(*, min_occupancy, ...)

1D maze spatial map settings.

SpatialMap2DConfig(*, min_occupancy, ...)

2D arena spatial map settings.

ZoneDetectionConfig(*[, arm_max_distance, ...])

Parameters for the zone detection state machine.

class camap.config.OasisConfig(*, g: tuple[float, float], baseline: str | float = 'p10', penalty: Annotated[float, Ge(ge=0)] = 0.0, s_min: Annotated[float, Ge(ge=0)] = 0.0)#

Bases: BaseModel

OASIS AR(2) deconvolution parameters.

g, penalty, s_min are passed directly to oasisAR2. baseline is applied before deconvolution.

Parameters:
  • g (tuple[float, float])

  • baseline (str | float)

  • penalty (Annotated[float, Ge(ge=0)])

  • s_min (Annotated[float, Ge(ge=0)])

g: tuple[float, float]#
baseline: str | float#
penalty: float#
s_min: float#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class camap.config.NeuralConfig(*, fps: float, oasis: OasisConfig, trace_name: str = 'C')#

Bases: BaseModel

Neural data paths and deconvolution settings.

Parameters:
fps: float#
oasis: OasisConfig#
trace_name: str#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class camap.config.BaseSpatialMapConfig(*, min_occupancy: ~typing.Annotated[float, ~annotated_types.Ge(ge=0)], spatial_sigma: ~typing.Annotated[float, ~annotated_types.Ge(ge=0)], n_shuffles: ~typing.Annotated[int, ~annotated_types.Ge(ge=1), ~annotated_types.Le(le=10000)], random_seed: int | None = None, p_value_threshold: ~typing.Annotated[float, ~annotated_types.Ge(ge=0.0), ~annotated_types.Le(le=1.0)] = 0.05, min_shift_seconds: ~typing.Annotated[float, ~annotated_types.Ge(ge=0)] = 20.0, si_weight_mode: ~typing.Literal['amplitude', 'binary'], stability_splits: ~typing.Annotated[list[int], ~annotated_types.MinLen(min_length=1)] = <factory>, min_events: ~typing.Annotated[int, ~annotated_types.Ge(ge=0)] = 0, block_shift: ~typing.Annotated[float, ~annotated_types.Ge(ge=0.0), ~annotated_types.Lt(lt=1.0)] = 0.0)#

Bases: BaseModel

Shared spatial map config: occupancy, smoothing, shuffle testing, stability.

Subclasses add approach-specific binning and place field parameters.

Parameters:
  • min_occupancy (Annotated[float, Ge(ge=0)])

  • spatial_sigma (Annotated[float, Ge(ge=0)])

  • n_shuffles (Annotated[int, Ge(ge=1), Le(le=10000)])

  • random_seed (int | None)

  • p_value_threshold (Annotated[float, Ge(ge=0.0), Le(le=1.0)])

  • min_shift_seconds (Annotated[float, Ge(ge=0)])

  • si_weight_mode (Literal['amplitude', 'binary'])

  • stability_splits (Annotated[list[int], MinLen(min_length=1)])

  • min_events (Annotated[int, Ge(ge=0)])

  • block_shift (Annotated[float, Ge(ge=0.0), Lt(lt=1.0)])

min_occupancy: float#
spatial_sigma: float#
n_shuffles: int#
random_seed: int | None#
p_value_threshold: float#
min_shift_seconds: float#
si_weight_mode: Literal['amplitude', 'binary']#
stability_splits: list[int]#
min_events: int#
block_shift: float#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class camap.config.SpatialMap2DConfig(*, min_occupancy: ~typing.Annotated[float, ~annotated_types.Ge(ge=0)], spatial_sigma: ~typing.Annotated[float, ~annotated_types.Ge(ge=0)], n_shuffles: ~typing.Annotated[int, ~annotated_types.Ge(ge=1), ~annotated_types.Le(le=10000)], random_seed: int | None = None, p_value_threshold: ~typing.Annotated[float, ~annotated_types.Ge(ge=0.0), ~annotated_types.Le(le=1.0)] = 0.05, min_shift_seconds: ~typing.Annotated[float, ~annotated_types.Ge(ge=0)] = 20.0, si_weight_mode: ~typing.Literal['amplitude', 'binary'], stability_splits: ~typing.Annotated[list[int], ~annotated_types.MinLen(min_length=1)] = <factory>, min_events: ~typing.Annotated[int, ~annotated_types.Ge(ge=0)] = 0, block_shift: ~typing.Annotated[float, ~annotated_types.Ge(ge=0.0), ~annotated_types.Lt(lt=1.0)] = 0.0, bins: ~typing.Annotated[int, ~annotated_types.Ge(ge=5), ~annotated_types.Le(le=200)], event_threshold_sigma: float = 0.0, place_field_threshold: ~typing.Annotated[float, ~annotated_types.Gt(gt=0.0), ~annotated_types.Lt(lt=1.0)] = 0.35, place_field_min_bins: ~typing.Annotated[int, ~annotated_types.Ge(ge=1)] = 5, place_field_seed_percentile: float = 95.0)#

Bases: BaseSpatialMapConfig

2D arena spatial map settings.

Parameters:
  • min_occupancy (Annotated[float, Ge(ge=0)])

  • spatial_sigma (Annotated[float, Ge(ge=0)])

  • n_shuffles (Annotated[int, Ge(ge=1), Le(le=10000)])

  • random_seed (int | None)

  • p_value_threshold (Annotated[float, Ge(ge=0.0), Le(le=1.0)])

  • min_shift_seconds (Annotated[float, Ge(ge=0)])

  • si_weight_mode (Literal['amplitude', 'binary'])

  • stability_splits (Annotated[list[int], MinLen(min_length=1)])

  • min_events (Annotated[int, Ge(ge=0)])

  • block_shift (Annotated[float, Ge(ge=0.0), Lt(lt=1.0)])

  • bins (Annotated[int, Ge(ge=5), Le(le=200)])

  • event_threshold_sigma (float)

  • place_field_threshold (Annotated[float, Gt(gt=0.0), Lt(lt=1.0)])

  • place_field_min_bins (Annotated[int, Ge(ge=1)])

  • place_field_seed_percentile (float)

bins: int#
event_threshold_sigma: float#
place_field_threshold: float#
place_field_min_bins: int#
place_field_seed_percentile: float#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class camap.config.SpatialMap1DConfig(*, min_occupancy: ~typing.Annotated[float, ~annotated_types.Ge(ge=0)], spatial_sigma: ~typing.Annotated[float, ~annotated_types.Ge(ge=0)], n_shuffles: ~typing.Annotated[int, ~annotated_types.Ge(ge=1), ~annotated_types.Le(le=10000)], random_seed: int | None = None, p_value_threshold: ~typing.Annotated[float, ~annotated_types.Ge(ge=0.0), ~annotated_types.Le(le=1.0)] = 0.05, min_shift_seconds: ~typing.Annotated[float, ~annotated_types.Ge(ge=0)] = 20.0, si_weight_mode: ~typing.Literal['amplitude', 'binary'], stability_splits: ~typing.Annotated[list[int], ~annotated_types.MinLen(min_length=1)] = <factory>, min_events: ~typing.Annotated[int, ~annotated_types.Ge(ge=0)] = 0, block_shift: ~typing.Annotated[float, ~annotated_types.Ge(ge=0.0), ~annotated_types.Lt(lt=1.0)] = 0.0, bin_width_mm: ~typing.Annotated[float, ~annotated_types.Gt(gt=0)], split_by_direction: bool = True, require_complete_traversal: bool = False)#

Bases: BaseSpatialMapConfig

1D maze spatial map settings.

Parameters:
  • min_occupancy (Annotated[float, Ge(ge=0)])

  • spatial_sigma (Annotated[float, Ge(ge=0)])

  • n_shuffles (Annotated[int, Ge(ge=1), Le(le=10000)])

  • random_seed (int | None)

  • p_value_threshold (Annotated[float, Ge(ge=0.0), Le(le=1.0)])

  • min_shift_seconds (Annotated[float, Ge(ge=0)])

  • si_weight_mode (Literal['amplitude', 'binary'])

  • stability_splits (Annotated[list[int], MinLen(min_length=1)])

  • min_events (Annotated[int, Ge(ge=0)])

  • block_shift (Annotated[float, Ge(ge=0.0), Lt(lt=1.0)])

  • bin_width_mm (Annotated[float, Gt(gt=0)])

  • split_by_direction (bool)

  • require_complete_traversal (bool)

bin_width_mm: float#
split_by_direction: bool#
require_complete_traversal: bool#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class camap.config.ZoneDetectionConfig(*, arm_max_distance: Annotated[float, Gt(gt=0)] = 60.0, min_confidence: Annotated[float, Ge(ge=0.0), Le(le=1.0)] = 0.5, min_confidence_forbidden: Annotated[float, Ge(ge=0.0), Le(le=1.0)] = 0.8, min_seconds_same: Annotated[float, Gt(gt=0)] = 0.05, min_seconds_forbidden: Annotated[float, Gt(gt=0)] = 0.15, room_decay_power: Annotated[float, Gt(gt=0)] = 2.0, arm_decay_power: Annotated[float, Gt(gt=0)] = 0.5, soft_boundary: bool = True, hampel_window_frames: Annotated[int, Ge(ge=3)] = 7, hampel_n_sigmas: Annotated[float, Gt(gt=0)] = 3.0, interpolate: Annotated[int, Ge(ge=1)] = 5, playback_speed: Annotated[float, Gt(gt=0)] = 10.0)#

Bases: BaseModel

Parameters for the zone detection state machine.

Parameters:
  • arm_max_distance (Annotated[float, Gt(gt=0)])

  • min_confidence (Annotated[float, Ge(ge=0.0), Le(le=1.0)])

  • min_confidence_forbidden (Annotated[float, Ge(ge=0.0), Le(le=1.0)])

  • min_seconds_same (Annotated[float, Gt(gt=0)])

  • min_seconds_forbidden (Annotated[float, Gt(gt=0)])

  • room_decay_power (Annotated[float, Gt(gt=0)])

  • arm_decay_power (Annotated[float, Gt(gt=0)])

  • soft_boundary (bool)

  • hampel_window_frames (Annotated[int, Ge(ge=3)])

  • hampel_n_sigmas (Annotated[float, Gt(gt=0)])

  • interpolate (Annotated[int, Ge(ge=1)])

  • playback_speed (Annotated[float, Gt(gt=0)])

arm_max_distance: float#
min_confidence: float#
min_confidence_forbidden: float#
min_seconds_same: float#
min_seconds_forbidden: float#
room_decay_power: float#
arm_decay_power: float#
soft_boundary: bool#
hampel_window_frames: int#
hampel_n_sigmas: float#
interpolate: int#
playback_speed: float#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class camap.config.BehaviorConfig(*, type: Literal['arena', 'maze'], speed_threshold: float, speed_window_seconds: Annotated[float, Gt(gt=0)] = 0.25, hampel_window_frames: Annotated[int, Ge(ge=3)] = 7, hampel_n_sigmas: Annotated[float, Gt(gt=0)] = 3.0, spatial_map_2d: SpatialMap2DConfig | None = None, spatial_map_1d: SpatialMap1DConfig | None = None)#

Bases: BaseModel

Behavior filtering and spatial map selection.

Parameters:
  • type (Literal['arena', 'maze'])

  • speed_threshold (float)

  • speed_window_seconds (Annotated[float, Gt(gt=0)])

  • hampel_window_frames (Annotated[int, Ge(ge=3)])

  • hampel_n_sigmas (Annotated[float, Gt(gt=0)])

  • spatial_map_2d (SpatialMap2DConfig | None)

  • spatial_map_1d (SpatialMap1DConfig | None)

type: Literal['arena', 'maze']#
speed_threshold: float#
speed_window_seconds: float#
hampel_window_frames: int#
hampel_n_sigmas: float#
spatial_map_2d: SpatialMap2DConfig | None#
spatial_map_1d: SpatialMap1DConfig | None#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class camap.config.NeuralDataConfig(*, path: str, timestamp: str)#

Bases: BaseModel

Neural data paths.

Parameters:
  • path (str)

  • timestamp (str)

path: str#
timestamp: str#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class camap.config.BaseBehaviorDataConfig(*, fps: Annotated[float, Gt(gt=0)], position: str, timestamp: str, video: str | None = None, bodypart: str | None = None, overlay_frame_index: Annotated[int, Ge(ge=0)] = 1000, x_col: str = 'x', y_col: str = 'y')#

Bases: BaseModel

Behavior data paths and shared calibration. Subclassed by arena/maze.

Parameters:
  • fps (Annotated[float, Gt(gt=0)])

  • position (str)

  • timestamp (str)

  • video (str | None)

  • bodypart (str | None)

  • overlay_frame_index (Annotated[int, Ge(ge=0)])

  • x_col (str)

  • y_col (str)

fps: float#
position: str#
timestamp: str#
video: str | None#
bodypart: str | None#
overlay_frame_index: int#
x_col: str#
y_col: str#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class camap.config.ArenaBehaviorDataConfig(*, fps: Annotated[float, Gt(gt=0)], position: str, timestamp: str, video: str | None = None, bodypart: str | None = None, overlay_frame_index: Annotated[int, Ge(ge=0)] = 1000, x_col: str = 'x', y_col: str = 'y', type: Literal['arena'] = 'arena', arena_bounds: tuple[float, float, float, float] | None = None, arena_size_mm: tuple[float, float] | None = None, camera_height_mm: Annotated[float | None, Gt(gt=0.0)] = None, tracking_height_mm: Annotated[float | None, Ge(ge=0.0)] = None)#

Bases: BaseBehaviorDataConfig

Arena (2D open-field) behavior data config.

Parameters:
  • fps (Annotated[float, Gt(gt=0)])

  • position (str)

  • timestamp (str)

  • video (str | None)

  • bodypart (str | None)

  • overlay_frame_index (Annotated[int, Ge(ge=0)])

  • x_col (str)

  • y_col (str)

  • type (Literal['arena'])

  • arena_bounds (tuple[float, float, float, float] | None)

  • arena_size_mm (tuple[float, float] | None)

  • camera_height_mm (Annotated[float | None, Gt(gt=0.0)])

  • tracking_height_mm (Annotated[float | None, Ge(ge=0.0)])

type: Literal['arena']#
arena_bounds: tuple[float, float, float, float] | None#
arena_size_mm: tuple[float, float] | None#
camera_height_mm: float | None#
tracking_height_mm: float | None#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class camap.config.MazeBehaviorDataConfig(*, fps: Annotated[float, Gt(gt=0)], position: str, timestamp: str, video: str | None = None, bodypart: str | None = None, overlay_frame_index: Annotated[int, Ge(ge=0)] = 1000, x_col: str = 'x', y_col: str = 'y', type: Literal['maze'] = 'maze', behavior_graph: str | None = None, mm_per_pixel: Annotated[float | None, Gt(gt=0.0)] = None, arm_order: list[str] | None = None, zone_column: str = 'zone', arm_position_column: str = 'arm_position', zone_tracking: str | None = None, zone_connections: dict[str, list[str]] | None = None, zone_detection: ZoneDetectionConfig | None = None)#

Bases: BaseBehaviorDataConfig

Maze (1D arm) behavior data config.

Parameters:
  • fps (Annotated[float, Gt(gt=0)])

  • position (str)

  • timestamp (str)

  • video (str | None)

  • bodypart (str | None)

  • overlay_frame_index (Annotated[int, Ge(ge=0)])

  • x_col (str)

  • y_col (str)

  • type (Literal['maze'])

  • behavior_graph (str | None)

  • mm_per_pixel (Annotated[float | None, Gt(gt=0.0)])

  • arm_order (list[str] | None)

  • zone_column (str)

  • arm_position_column (str)

  • zone_tracking (str | None)

  • zone_connections (dict[str, list[str]] | None)

  • zone_detection (ZoneDetectionConfig | None)

type: Literal['maze']#
behavior_graph: str | None#
mm_per_pixel: float | None#
arm_order: list[str] | None#
zone_column: str#
arm_position_column: str#
zone_tracking: str | None#
zone_connections: dict[str, list[str]] | None#
zone_detection: ZoneDetectionConfig | None#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class camap.config.DataConfig(*, neural: NeuralDataConfig | None = None, behavior: Annotated[ArenaBehaviorDataConfig | MazeBehaviorDataConfig, FieldInfo(annotation=NoneType, required=True, discriminator='type')] | None = None, config_override: dict[str, Any] | None = None)#

Bases: BaseModel

Per-session data config: optional neural and behavior blocks.

At least one of neural or behavior must be present. Independent neural-only or behavior-only sessions are valid by omitting the other block; the pipeline gates each step on which side is configured.

Parameters:
neural: NeuralDataConfig | None#
behavior: Annotated[ArenaBehaviorDataConfig | MazeBehaviorDataConfig, FieldInfo(annotation=NoneType, required=True, discriminator='type')] | None#
config_override: dict[str, Any] | None#
classmethod from_yaml(path: str | Path) DataConfig#

Load a per-session data config from YAML.

Parameters:

path (str | Path)

Return type:

DataConfig

model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class camap.config.AnalysisConfig(*, neural: NeuralConfig, behavior: BehaviorConfig)#

Bases: BaseModel

Top-level analysis config combining neural and behavior settings.

Parameters:
model_config = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

neural: NeuralConfig#
behavior: BehaviorConfig#
classmethod from_yaml(path: str | Path) AnalysisConfig#

Load from a YAML file.

Parameters:

path (str | Path)

Return type:

AnalysisConfig

to_yaml(path: str | Path) None#

Serialize to a YAML file.

Parameters:

path (str | Path)

Return type:

None

with_data_overrides(data_cfg: DataConfig) AnalysisConfig#

Return a new config with data_cfg.config_override deep-merged in.

Parameters:

data_cfg (DataConfig)

Return type:

AnalysisConfig