Spaak & De Lange (2019) analysis and experiment code
This is the analysis and experiment code related to the Spaak & De Lange (2019) paper "Hippocampal and prefrontal theta-band mechanisms underpin implicit spatial context learning", as published in The Journal of Neuroscience.
You'll need Matlab or Octave (tested with Matlab version R2017a) and FieldTrip installed. I think any recent version of FieldTrip should work; but see below for which specific versions were used/tested for the paper.
The analysis for the paper was performed using FieldTrip commit 6414ea0, which you'll be able to obtain using
git clone email@example.com:fieldtrip/fieldtrip.git cd fieldtrip git checkout 6414ea000dcf5bba0ec43ce6487e3425e480b161
Installing and basic setup
- Install dependencies (see above).
- Clone or download this repo like normal (see green "Clone or download" button in the top right corner of this page).
- Get a copy of the (raw and processed) data from the repository.
- Configure some paths in the code:
data_dirto where you put the data from the repository.
results_dirto where the results (figures and outputs of statistical tests) should appear. Will be created if it does not exist.
matlab/set_path.m- set the line referring to FieldTrip to point to where you installed FieldTrip.
matlabcmdto your Matlab executable (I recommend leaving the
-nodesktop -nosplashflags intact).
workingdirto the Matlab working directory (usually the folder in which you cloned this repo +
rootdirto the same as Matlab's
working_dirto the working directory of the Python script (usually the folder in which you cloned this repo +
That's it! You should be able to run the code now.
Further setup options
You can change the variable
matlab/run_all_analyses.m to specify whether and how you want the actual analyses starting from raw data to be executed. Quoting from the comments in that file:
% Analyses can be run in one of three modes: in-process (each subject % sequentially, very slow); individual qsub jobs (can also be relatively % slow, since every job will need to read in the full original data); or in % a slave pool running on the cluster (one long-running daemon job per % subject, keeping that subject's data in memory; execute jobs as instructed % by the master script; fastest option). % Alternatively, you can specify run_mode = 'load-only' to not execute the % individual jobs starting from raw data at all, and instead load the % intermediate results that should already be on disk. % Behavioural analyses (with the exception of the Bayesian modelling) are % all very fast and will always be done in-process.
The easiest is to leave it at
load-only of course (use existing intermediate results). Also rather fool-proof is
in-process, although that will take a long time. The other options
slavepool require a Torque cluster backend (like the one running at the Donders Centre for Cognitive Neuroimaging) and a Linux environment. The other run modes should (I think) also run under Windows, but I haven't tested this.
Additionally, the variable
call_python in the same file allows you to specify whether or not you want the MCMC Python code to be run at all. This might save you the hassle of setting up a Python environment with all the packages etc. installed. The relevant last bit of this analysis pipeline will then simply use the intermediate results that were provided in the data repository.
The Python code has an analogous
run_mode variable that can be
Start matlab, change directory to
<repo_dir>/matlab, and execute
The analysis code starts either from the intermediate results (when
load-only), or from the raw, yet artifact-cleaned and down-sampled, data (the
preproc-data-artreject-400hz.mat files from the repository; other run modes). If you want to start from the raw raw data, i.e. the
.ds datasets as they were recorded by the CTF MEG machine, you can do so by using the code in the
matlab/preproc folder. This code is not as streamlined as the analysis code, and requires manual interaction. Steps are, per subject:
You will probably need to change the default
datainfo to point to the data from the repository.
Note that there are also a few files included in
preproc related to the preprocessing of anatomical (MRI) data for the source analysis steps. You will not be able to run this code without the individual MRI images and headshape (Polhemus) files, which are not provided in the data repository due to privacy reasons. The resulting volume conduction and source models are included as intermediate files.
This code is released as Open Source software under the GNU General Public License v3.0.