This repository provides a complete pipeline for processing rodent training data, converting raw .mat
files into structured .rds
files, extracting behavioral metrics, and visualizing performance trends in an interactive Shiny dashboard.
The system enables researchers to:
- Import experimental data from BControl or Bpod sessions.
- Process and transform data into a clean, analysis-ready format.
- Automatically aggregate session-level metrics into
TRAINING.csv
. - Explore data interactively with Shiny visualizations.
shiny-performance-tracking/
├── docs/
│ ├── architecture.md
│ ├── data_dictionary.md
│ ├── usage_guide.md
│ └── setup_notes.md
├── shiny_app/
│ ├── app.R
│ ├── TRAINING.csv # Main dataset for the dashboard
│ ├── full_TRAINING.csv # Optional, long-term aggregation
│ └── functions/ # Modular ggplot-based visualization scripts
├── utility_functions/ # File parsing and processing logic
│ ├── ConvertToRDS.R
│ ├── ReadBcontrolData.R
│ ├── ReadBpodData.R
│ ├── ReadData.R
│ ├── ReadTrialData.R
│ └── TRAININGtoCSV.R
├── .Rprofile # R environment configuration and package management
├── ExtractSaveData.R # Main ETL pipeline: from .mat to .csv
└── README.md # Overview + links to docs
Launch the app locally:
setwd("shiny_app")
shiny::runApp()
The dashboard includes:
- Stage tracking by animal
- Correct ratio trends
- Trial completion rates
- Choice direction distributions
The system uses several R packages organized by functionality:
tidyverse
- Data manipulation and visualizationmagrittr
- Pipe operator for cleaner codeparallel
- Parallel computing support
R.matlab
- MATLAB file supportreadr
- Fast data importtibble
- Modern data frames
stringr
- String manipulationforcats
- Categorical data handlingpurrr
- Functional programmingzoo
,chron
,padr
- Time series analysis
ggplot2
- Base plottingggpubr
- Enhanced ggplot2ggrepel
- Label positioningplotly
- Interactive plotsgridExtra
- Multi-plot layouts
shiny
- Web application frameworkshinyjs
- JavaScript integrationDT
- Interactive tableskableExtra
- Enhanced tablesrmarkdown
,knitr
- Dynamic documents
All dependencies are automatically loaded through .Rprofile
, which also:
- Manages utility function loading using a vector-based approach
- Configures system-specific data paths
- Sets up the R environment for optimal performance
ExtractSaveData.R
supports batch processing and parallel conversion.- New
.mat
files added to the source directory are automatically processed and appended. - The system supports both session-level and trial-by-trial data (optional).
- Utility functions are loaded dynamically through
.Rprofile
for better maintainability.