Author: Henry Allen
IMPORTANT!: If you get errors, they most likely result from a missing or incorrect file path. This is especially likely when trying to generate figures or trying to save data in the Data/ folder.
Contains all the code for the project.
bayesian_model
: This code is not complete, but is meant to implement the vanBergen modification of the IEMDoG
: Contains permutation tests for derivative of Gaussiansfile_lists
: Contains various python lists and dictionaries for making automation easier. This is a bad way to do things, and these lists should probably be stored in .mat or .npy files in the futureinverted_encoding_model
: Completed Inverted encoding model, adapted from Sprague codeload_data
: various functions to help load MEG datamachine_learning
: various machine learning classes and helper functionsMEG_analysis
: meg preprocessing codepermutation_test
: main code for running permutation tests with MNE decoding algorithmssource_localization
: source localization helper functions
-
These notebooks are just my initial explorations for MEG analysis and decoding analysis.
-
The Adjustment_Analysis6.ipynb code does not belong to me (Henry)
-
Move these notebooks to
code/
if you want them to work properly
The work in here is either confusing to read, or may not work. Enter at your own risk
circular_regression
: attempts to do circular regression, but wasn't successfulmain_analysis
: Initial analysis to run machine learning modelstest_decoding_sample_rate
: test decoding with higher sample rateserial_dependence
: various functions for analyzing serial dependence, many of which were unsuccessful
This file includes some scripts to make it easier to do analysis. You may need to move them to the main /code/ directory for them to work
perform_bem
: Runs the make_bem_watershed code for all subjects in "subjs"plot_meg_figs
: Makes figures with averaged evoked responses and source localization figuresplot_model_weights
: plots the MVPA patterns for MNE decoding modelssave_mat
: saves loaded data to a mat file so that it can be easily reusedvalidate_epochs
: Checks the alignment of stim tracks with meg epochs
IMPORTANT!: Before running the main analysis code, you will have to set the path for where to save figures, as the current paths may not exist.
-
initial_results
/: Figures generated from exploratory analysis and preprocessing. Results here are not necessarily indicative of final model performance -
intermediate_results
/: Figures from intermediate data processing and analysis after preprocessing. There is a lot of clutter here, and these files are just kept for archiving progress -
final_results
/: Results computed with permutation tests, used in final draft of thesis and VSS poster.
Contains saved pre-processed data so that we don't have to run preprocessing every time we want to run the decoding analysis
For pre-processing, there are two main parts: (1) Filtering and processing the MEG data and (2) using MRI data for source localization. These steps can be seen as a diagram here: https://mne.tools/stable/overview/cookbook.html
-
Import the raw data
-
Filter the data. I used a high-pass filter at 2hz and a low-pass filter at 40hz.
-
Execute Independent Component Analysis (ICA). ICA helps us to remove heartbeats and eye blinks from the signals, which cause artifacts. These bad ICA components were picked out and excluded from the data. ICA also helps with some initial source localization.
-
Epoch the data. In this step, we create a ~2 second window for each trial and time-lock each trial to the stimulus onset. We drop trials that have a peak-to-peak gradiometer amplitude of 4000e-13 T/m.
-
Average the date. Use the mne.Evoked class to average the data and produce ERFs. We also use this data to plot power-spectral density plots, and as an input for source localization.
-
Generate Freesurfer surfaces
-
Run
mne.bem.make_watershed_bem()
on the subject to generate a head model -
Align the mri data with the meg data using
mne coreg
. This will create a new "subject" that you should use for further steps. -
Run
mne.bem.make_watershed_bem()
on the newly aligned model -
Create a source space from the Freesurfer data
-
Generate a BEM from the Freesurfer data
-
Calculate the forward solution
-
Calculate the inverse operator
-
Create the source estimate