Python code used to import, tidy, and analyze MEDPC data in Python.
-
Import, tidy, & analyze your behavioral time-series data from MEDPC in Python.
-
Combine behavioral data with manually-defined subject & session metadata.
-
Combine behavioral data from multiple sessions & subjects into single tidy dataframe (with 1 row per event timestamp).
-
Break sessions into trials (with trialTypes) and other custom behavioral epochs.
-
Perform session-based, epoch-based, & trial-based analyses.
-
-
-
Designed to work with medpc2excel Python package.
-
Designed to be generalizable and modular- Currently focused on DS task analyses but should support many custom .MPC protocols & behavioral paradigms.
- Make sure you have Raw input data described in detail below workflow.
- Run importMPCdata.py
-
User defines variables depending on their experimentType (their .MPC protocol/behavioral paradigm) - this supports modularity.
-
eventVars= Variable names corresponding to recorded event timestamps (Matching variable name labels in .MPC file / .xlsx columns)
-
trialVars= Variable names of event timestamps which should break session into trials
- (as of 2023-09-20 analyses largely focused on DS Task .MPC protocols so trialIDs are defined by DS and NS onset times)
-
idVars= Subject & Session metadata variables corresponding to recorded event timestamps
-
-
Script imports MPC data, combines with relevant subject and session metadata (recorded in separate excel spreadsheets). Saves output tidy dataframe as .pkl file.
- Resulting dataframe has 1 row per event timestamp with columns for eventType and metadata
- Adds columns for fileIDs (session identifier), trialIDs (within-session), trialTypes (corresponding to trialVars), and other epoch labels (e.g. pre-trial, ITI, and post-trial)
- This approach enables efficient analyses and subsetting of data based on session-, file-, trial-, and epoch-
-
Some examples of analyses & vizualizations using the seaborn package. Again, mostly focused on DS task use-cases as of 2023-09-20:
-
Run behaviorAnalysis.py- Performs additional analyses and saves as .pkl
- Trial-based analyses
- Event count & event latency per trial
- Probability of behavioral outcome by trialType
- Trial-based analyses
-
Run optoAnalysis.m (for optogenetics experimentType)- Performs additional optogenetics-focused analyses and saves as .pkl
- Additional comparisons between trialType (e.g. laser vs no laser) & viral group (e.g. opsin vs control)
- customFunctions.py has additional custom functions including:
- Subsetting / aggregation of data according to hierarchical organization (e.g. by virus, subject, fileID, trialType, trialID)
- Automatic figure saving
-
MedPC data .xslx sheets (generated using medpc2excel Python package)
-
Manually-managed subject metadata .xlsx sheet (containing relevant metadata for each subject e.g. viral group, experimental condition, sex)
-
Manually-managed session metadata .xlsx sheet (containing relevant metadata for each session e.g. training stage, other session parameters)