Animal-Level Plots¶
Functions for creating visualizations that analyze animal behavior across multiple sessions.
find_uniq_pos(arr)
¶
Find unique values and their starting positions in a list.
Helper function that identifies unique consecutive values in a list and returns both the unique values and their starting positions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arr
|
List
|
Input list to analyze for unique consecutive values. |
required |
Returns:
Type | Description |
---|---|
List
|
A tuple containing: |
List[int]
|
|
tuple[List, List[int]]
|
|
Source code in src/ethopy_analysis/plots/animal.py
plot_performance_liquid(animal_id, animal_sessions, xaxis='session', save_path=None)
¶
Plot performance vs liquid reward consumption over sessions.
Creates a dual-axis plot showing both behavioral performance and liquid reward consumption across sessions. This helps identify relationships between motivation (liquid consumption) and task performance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
animal_id
|
int
|
The animal identifier to analyze. |
required |
animal_sessions
|
DataFrame
|
DataFrame containing session information with columns: - 'session': Session identifiers - 'session_tmst': Session timestamps (required if xaxis='date') |
required |
xaxis
|
str
|
X-axis format, either 'session' for session IDs or 'date' for timestamps. Defaults to 'session'. |
'session'
|
save_path
|
Optional[str]
|
Path to save the plot image. If None, plot is not saved. |
None
|
Source code in src/ethopy_analysis/plots/animal.py
plot_session_date(animal_id, min_trials=0, save_path=None)
¶
Plot sessions per date to visualize training schedule.
Creates a bar chart showing the number of sessions conducted on each date for a specific animal. This helps visualize training consistency and patterns.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
animal_id
|
int
|
The animal identifier to analyze. |
required |
min_trials
|
int
|
Minimum number of trials required per session to include in analysis. Sessions with fewer trials will be excluded. Defaults to 0. |
0
|
save_path
|
Optional[str]
|
Path to save the plot image. If None, plot is not saved. |
None
|
Returns:
Type | Description |
---|---|
Dict[date, List[int]]
|
Dictionary mapping each date to a list of session IDs conducted on that date. |
Source code in src/ethopy_analysis/plots/animal.py
plot_session_performance(animal_id, sessions, perf_func, save_path=None)
¶
Plot session performance over time with protocol visualization.
Creates a line plot showing performance across sessions, with colored background regions indicating different experimental protocols. This helps visualize how performance changes over time and across different task conditions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
animal_id
|
int
|
The animal identifier to analyze. |
required |
sessions
|
List[int]
|
List of session IDs to include in the analysis. |
required |
perf_func
|
callable
|
Function that calculates performance for a given animal_id and session. Should have signature: perf_func(animal_id: int, session: int) -> float |
required |
save_path
|
Optional[str]
|
Path to save the plot image. If None, plot is not saved. |
None
|
Returns:
Type | Description |
---|---|
List[float]
|
List of performance values for each session, in the same order as input sessions. |
Source code in src/ethopy_analysis/plots/animal.py
plot_trial_per_session(animal_id, min_trials=2, save_path=None)
¶
Plot the distribution of trials per session.
Creates a bar chart showing the number of trials completed in each session for a specific animal. This helps assess session length consistency and identify potential issues with session termination.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
animal_id
|
int
|
The animal identifier to analyze. |
required |
min_trials
|
int
|
Minimum number of trials required per session to include in analysis. Sessions with fewer trials will be excluded. Defaults to 2. |
2
|
save_path
|
Optional[str]
|
Path to save the plot image. If None, plot is not saved. |
None
|