How carolfs/fmri_magic_carpet works
Main System Components
• Task Module: Represented by the “code/task” folder, this contains the experimental framework. It holds assets (instructions and quizzes), configuration files, and scripts (e.g., fmri_game.py, run.py) that drive the behavioral tasks. It essentially acts as the data acquisition front-end.
• Analysis Module: Shown under “code/analysis”, this part consists of many Python scripts (e.g., analyse_ratings.py, process_pupil_diameter.py) and Stan model files used for fMRI and behavioral data analysis. This module implements the data processing, statistical modeling (hybrid, logistic regression, etc.), and computes predictors from the collected data.
• Data Store: The “data” directory gathers all the raw inputs:
• Eye-tracking data (in compressed asc files)
• Questionnaire responses (plain text files)
• Task behavior data (CSV files)
• Additional ratings and other CSV files.
• External Dependencies & Configuration:
• The repository makes use of configuration files (for both task and analysis modules) and includes scripts relying on external libraries (e.g., Stan models, Bayesian analysis frameworks) and neuroimaging tools to process NIFTI files.
Out the Relationships and Data Flows
• Inside the Analysis Module, illustrate internal workflows – for example:
• fMRI analysis (using files like Nacc_3mm.nii.gz and mask_gm_conj_3mm.nii.gz)
• First-level and second-level data modeling (first_level_repl*.py, second_level_*.py)
• Bayesian and mixed effect modeling (seen in hybrid_*.stan, hybrid_bayesian.py, logreg.py).
• A component for configuration that is used by both the task and analysis submodules (referencing config.py files) to manage experiment settings and analysis parameters.
Incorporate Important Architectural Patterns and Technologies
• Modular separation between data collection (Task) and data analysis.
• Notice the lean “pipeline” nature typical of research code:
• Data acquisition (via task) → Data storage → Data processing & statistical modeling (via analysis).
• Use of probabilistic programming (Stan models) and standard Python scripting, typical in scientific computation workflows.