Data Analysis¶
Functions for analyzing behavioral data and calculating performance metrics.
Data analysis functions for Ethopy experiments.
This module provides functions to analyze behavioral data, calculate performance metrics, and generate session summaries.
get_performance(animal_id, session, trials=None)
¶
Calculate performance as the ratio of reward trials to total decisive trials.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
animal_id
|
int
|
Animal identifier |
required |
session
|
int
|
Session identifier |
required |
trials
|
Optional[List[int]]
|
List of trial indices to filter by. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Optional[float]
|
Optional[float]: Performance ratio (0-1), or None if no decisive trials found |
Note
Decisive trials are those with state 'Reward' or 'Punish'. Performance is calculated as: count_reward_trials / (count_reward_trials + count_punish_trials)
Source code in src/ethopy_analysis/data/analysis.py
session_summary(animal_id, session)
¶
Print a comprehensive summary of a session including metadata and performance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
animal_id
|
int
|
The animal identifier |
required |
session
|
int
|
The session number |
required |
Prints
- Animal ID and session number
- User name and setup information
- Session start time and duration
- Experiment, stimulus, and behavior classes
- Task filename and git hash
- Session performance and number of trials
Source code in src/ethopy_analysis/data/analysis.py
trials_per_session(animal_id, min_trials=2, format='df')
¶
Returns the number of trials per session
Parameters:
Name | Type | Description | Default |
---|---|---|---|
animal_id
|
int
|
The animal identifier |
required |
min_trials
|
int
|
Minimum number of trials to include session. Defaults to 2. |
2
|
format
|
str
|
Return format, either "df" for DataFrame or "dj" for DataJoint expression. Defaults to "df". |
'df'
|
Returns:
Type | Description |
---|---|
Union[pd.DataFrame, Any]: DataFrame with trials_count column if format="df", DataJoint expression if format="dj" |