This repository contains the code used for the Master's thesis by Veera Itälinna.
-
dicom2nifti
Contains a MATLAB script for converting DICOM files to NIfTI format.
-
pipeline-tbi
Contains the steps of the source modelling pipeline (adapted from Rantala, 2020).
-
model
Contains the code for training and evaluating the model and visualizing the results.
- Run FreeSurfer on the MRI images (
pipeline-tbi/freesurfer
) - Make BEM meshes with Watershed algorithm (
pipeline-tbi/watershed
) - Perform ICA on the raw MEG measurements, and apply the ICA solutions also to the empty room recordings (
pipeline-tbi/ica
) - Calculate noise covariance matrices from the empty room recordings (
pipeline-tbi/noisecov
) - (Optional: Increase the dataset size using a sliding window approach on the MEG measurements (
pipeline-tbi/window
)) - Compute the coordinate transformations (
pipeline-tbi/trans
) - Compute source PSDs and morph to an average brain (
pipeline-tbi/psd
)
- Calculate mean and standard deviation matrices from the normative samples (
pipeline-tbi/averages
) - Calculate Z-score maps (
pipeline-tbi/zmap
) - Parcellate the Z-maps (
pipeline-tbi/parc
) - Collect all parcellated Z-maps into a single dataset (
pipeline-tbi/zmap/create_zmap_dataset.py
)
Training and evaluating the model is done by running the Python script model/run_zmap_svm.py
with appropriate options.
usage: run_zmap_svm.py [-h] [-f FIT_PARAMS] [-g] [-r] [-n] [--fs]
[--norm-data {full,age,random}] [-v] [-p]
optional arguments:
-h, --help show this help message and exit
-f FIT_PARAMS, --fit-params FIT_PARAMS
Parameters to pass to the classifier (JSON string)
-g, --grid Use grid search for model selection
-r, --repeat Use repeated cross-validation
-n, --nested Use nested cross-validation for model selection and
validation
--fs Apply feature selection
--norm-data {full,age,random}
Select what normative data to use
-v, --visualize Visualize the results
-p, --perm-test Use permutation test
How to obtain the results presented in the thesis:
- Nested and repeated cross-validation with full normative data and all features:
run_zmap_svm.py -n -r
- Nested and repeated cross-validation with full normative data and feature selection:
run_zmap_svm.py -n -r --fs
- Nested and repeated cross-validation with age-matched normative data and all features:
run_zmap_svm.py -n -r --norm-data age
- Nested and repeated cross-validation with age-matched normative data and feature selection:
run_zmap_svm.py -n -r --fs --norm-data age
- Nested and repeated cross-validation with random normative data and all features:
run_zmap_svm.py -n -r --norm-data random
* - Nested and repeated cross-validation with random normative data and feature selection:
run_zmap_svm.py -n -r --fs --norm-data random
*
* repeated three times with different random seeds and averaged the results
Rantala, A. (2020). Creating a normative database of resting-state brain activity from a large number of MEG recordings [Aalto University School of Science]. http://urn.fi/URN:NBN:fi:aalto-202101311732