## **ReadMe** ##
In this repository, you will find the data, scripts and materials necessary to reproduce the work reported in:
Quiroga-Martinez, D. R., Hansen, N. C., Højlund, A., Pearce, M., Brattico, E., & Vuust, P. (2020). Decomposing neural responses to melodic surprise in musicians and non-musicians: Evidence for a hierarchy of predictions in the auditory system. NeuroImage, 116816. https://doi.org/10.1016/j.neuroimage.2020.116816
## **Contents description** ##
The scripts, inputs and outputs are all in the MEG folder. In the following, we describe the scripts, folders and files grouped by the type of analysis that they addressed.
### **Data** ###
**Demographic information**
- Participants' information as well as musical expertise scores can be found in the file "**participants_info_anonymized.csv**".
**MEG data**
- The data for the main analyses in the paper can be found in the folder "**timelocked_data/data/**". These correspond to timelock averages per condition for each subject, stored in a matlab structure. Timelocked data are given for different IDyOM configurations, as indicated in the name of the file (e.g. "01_timelock_**both_plus_scaled_interval**_IC_10cat"). In addition, the suffixes "IC_MMN" and "int_control" are used for the timelock files used in the MMN/N1 comparison and interval-size control analyses.
- Raw data files and outputs of the epoching scripts can be requested by personal communication.
**Mean amplitude data**
- Data for the mean amplitude analyses can be found in the folder "**MA**". A similar naming pattern as for MEG data is used.
### **Preprocessing** ###
**Maxfilter_same_init.py**
- Script to submit maxfiltering jobs to Elekta's software.
- Input: raw ".fif" file
- Output: Maxfiltered and motion corrected ".fif" file.
**analysisPipelineFunctions_eog-ecg.py**
- Python functions to perform ICA.
- Input: Maxfiltered and motion corrected ".fif" file.
- Output: ICA decompositions and clean raw files
**analysisPipeline_clusterize_offline.py**
- Wrapper to loop and submit ICA jobs
- Input: Maxfiltered and motion corrected ".fif" file.
- Output: ICA decompositions and clean raw files
**visRejV5.py**
- Python script to visually inspect ICA outputs and reject additional components, if necesary.
- Input: Maxfiltered and motion corrected ".fif" file.
- Output: Clean raw files
**epoching_IC.m**
- Matlab script to perform epoching. This script requires a wrapper to be called.
- Input: Clean ".fif" files and IDyOM estimates (folder "**IDyOM_estimates**".
- Output: epoched data per subject and trigger checks. Note that the output of this step is not provided in the repository, but can be requested by personal communication.
### **IDyOM analyses** ###
**melody_models/IDyOM_models.lisp**
- LISP script with the commands to perform IDyOM analyses for our stimuli.
- Input: melody and training corpus stored in IDyOM's library.
- Output: Model estimates stored in "**melody_models/**"
**stimuli_and_corpus/**
- folder where our stimuli (in midi format) and the training corpus can be found.
**add_IC.R**
- R script to map the output of the IDyOM models with the log files of the MEG stimulation.
- Input: MEG log files (in "**Logs/**") and IDyOM's output in "**melody_models/**".
- Output: ".csv" files in "**IDyOM_estimates/**"
**calculate_quants.R**
- R script to calculate 10 IC quantiles for each IDyOM configuration compared.
- Input: IDyOM's output in "**melody_models/**".
- Output: "**IDyOM_estimates/quantiles.csv**"
### **Main MEG IC analyses** ###
**timelocking_IC.m**
- Matlab script to average epochs per condition and participant.
- Input: Epoched data and "**IDyOM_estimates/quantiles.csv**" file.
- Output: Timelock files and figures in "**timelocked_data/**"
**grand_avg_stats_and_plots_IC.m**
- Matlab script to do cluster-based statistics, grand averages and some plotting.
- Input: Timelock files in "**timelocked_data/data/**".
- Output: Grand averages, figures and statistics in their respective subfolders in "**results/**".
**grand_avg_stats_and_plots_IC_wrapper.m**
- Matlab script to iteratively call **"grand_avg_stats_and_plots_IC.m"** for different IDyOM configurations.
**Extract_MA_IC_peak.m**
- Matlab function to extract mean amplitudes from timelock averages per participant.
- Input: Timelock files in "**timelocked_data/data/**" and subjects information in "**participants_info_anonymized.csv**".
- Output: Mean amplitude data stored in "**MA/**".
**MA_stats_IC_peaks.R**
- R script for the Bayesian analyses of mean amplitudes.
- Input: Mean amplitude data stored in "**MA/**".
- Output: Results stored in "**results/stats/**".
**MA_compare_models.R**
- R script for the comparison of different IDyOM configurations with regard to MA amplitudes.
- Input: Mean amplitude data stored in "**MA/**".
- Output: Comparison results in "**results/stats/**".
### **Interval size control analyses** ###
**timelocking_interval_control.m**
- Matlab script to average epochs corresponding to orthogonal manipulations of interval size and information content.
- Input: Epoched data and "**IDyOM_estimates/quantiles.csv**" file.
- Output: Timelock files and figures in "**timelocked_data/**"
**grand_avg_stats_and_plots_int_control.m**
- Matlab script to do cluster-based statistics, grand averages and some plotting for the interval size control analyses.
- Input: Timelock files in "**timelocked_data/data/**".
- Output: Grand averages, figures and statistics in their respective subfolders in "**results/**".
**grand_avg_stats_and_plots_int_control_wrapper.m**
- Matlab script to iteratively call **"grand_avg_stats_and_plots_int_control.m"** for different IDyOM configurations.
### **Comparison between MMNm and N1m** ###
**timelocking_MMN_vs_IC.m**
- Matlab script to average epochs per condition of interest for the MMNm vs N1m comparison.
- Input: Epoched data and "**IDyOM_estimates/quantiles.csv**" file.
- Output: Timelock files and figures in "**timelocked_data/**"
**grand_avg_stats_and_plots_IC_vs_MMN.m**
- Matlab function to do cluster-based statistics, grand averages and some plotting.
- Input: Timelock files in "**timelocked_data/data/**".
- Output: Grand averages, figures and statistics in their respective subfolders in "**results/**".
**grand_avg_stats_and_plots_IC_vs_MMN_wrapper.m**
- Matlab script to iteratively call **"grand_avg_stats_and_plots_IC_vs_MMN.m"** for different IDyOM configurations.
**Extract_MA_IC_vs_MMN_peak.m**
- Matlab function to extract mean amplitudes from timelock averages per participant.
- Input: Timelock files in "**timelocked_data/data/**" and subjects information in "**participants_info_anonymized.csv**".
- Output: Mean amplitude data stored in "**MA/**".
**MA_stats_IC_vs_MMN_peaks.R**
- R script for comparison of mean amplitudes and peak latencies of MMNm vs N1m.
- Input: Mean amplitude data stored in "**MA/**".
- Output: Results stored in "**results/stats/**".
### **Source localization** ###
**convert_to_spm.m**
- Matlab script to convert fieldtrip timelock files to SPM format.
- Input: Timelock data in "**timelocked_data/data/**" and raw MEG files (to extract sensor coordinates and stuff).
- Output: SPM timelock files (available upon request).
**head_model_and_inversion.m**
- Matlab/SPM batch script to perform source localization.
- Input: SPM timelock files plus individual anatomical MRIs (not shared due to data protection restrictions).
- Output: Inverse solutions stored in the corresponding SPM files and average volumes in a given time window shared in the respective subfolder of "source_localization/".
**one_samples_t_source.m**
- Matlab/SPM batch script to perform 1 samples t-test for the extracted volumes per conditon.
- Input: Average volumes in the respective subfolder of **"source_localization/"**.
- Output: SPM statistics file and statistical maps in **"source_reconstruction/XXX/stats/"**.
**N1_MMN_source_stats.m**
- Matlab/SPM batch script to perform paired samples t-test for the comparison between N1 and MMN.
- Input: Average volumes in the respective subfolderS of **"source_localization/"**.
- Output: SPM statistics file and statistical maps in **"source_reconstruction/stats/"**.
### **Scripts for plotting** ###
- **plot_channsel_IC_vs_MMN.m**: N1/MMN comparison
- **plot_r2_values.m**: Comparison of IDyOM configurations
- **plot_topo_q10_q1.m**: Topomaps of different effects
- **render_source_results.m**: Result of source localization
### **Other files and scripts** ###
- **SuppFile1 - instruments_info.pdf**: supplementary file 1
- **SuppFile2 - pars_plot.jpeg**: supplementary file 2
- **SuppFile3 - acoustic_analysis.pdf**: supplementary file 2
- **pool.csv**: tone codes of the melodic sequences used in the experiment. This file is use for melody recognition in **"add_IC.R"**.
- **cortex_20484.surf.gii**: high resolution template mesh for rendering source localization results. Taken from SPM.
- **cortex_8196.surf.gii**: lower resolution template mesh for rendering source localization results. Taken from SPM.
- **acoustic_analysis/calculate_similarities.R**: R script for the acoustic analyses reported in supplementary file 3. It takes the tone pool stored in **/acoustic_analysis/stimuli/** and makes the plots in **/acoustic_analysis/**.
### **List of folders** ###
- **acoustic_analysis/**: stores files related to supplementary file 3.
- **IDyOM_estimates/**: stores IDyOM's output mapped onto individual participants' MEG log files.
- **Logs/**: MEG log files
- **MA/**: Stores extracted mean amplitudes.
- **melody_models/**: stores IDyOM's output.
- **results/**: stores stats, figures, and data resulting from the analyses, in their respective subfolder.
- **source_localization/**: stores volumes and statistical outputs for source localization analyses.
- **stimuli_and_corpus/**: stores our stimuli (in midi format) and the training corpus used for IDyOM analyses.
- **timelocked_data/**: store timelock averages per participant and condition, as well as some figures.