Coder Social home page Coder Social logo

deepsif's Introduction

DeepSIF: Deep Learning based Source Imaging Framework

DeepSIF is an EEG/MEG source imaging framework aiming at providing an estimation of the location, size, and temporal activity of the brain activities from scalp EEG/MEG recordings. There are three components: training data generation (forward/), neural network training (main.py), and model evaluation (eval_sim.py,eval_recal.py), as detailed below. The codes are provided as a service to the scientific community, and should be used at users’ own risks.

This work was supported in part by the National Institutes of Health grants NS096761, EB021027, AT009263, MH114233, EB029354, and NS124564, awarded to Dr. Bin He, Carnegie Mellon University. Additional data in 20 human epilepsy patients tested in this work can be found at

https://figshare.com/s/580622eaf17108da49d7.

Please cite the following publication if you are using any part of the codes:

Sun R, Sohrabpour A, Worrell GA, He B: “Deep Neural Networks Constrained by Neural Mass Models Improve Electrophysiological Source Imaging of Spatio-temporal Brain Dynamics.” Proceedings of the National Academy of Sciences of the United States of America 119.31 (2022): e2201128119.

Train Data Generation

The Virtual Brain Simulation

python generate_tvb_data.py --a_start 0 --a_end 10

The simulation for each region can also run in parallel. (Require multiprocessing installed.)

Process Raw TVB Data and Prepare Training/Testing Dataset

Run in Matlab

process_raw_nmm
generate_sythetic_source

The output of generate_sythetic_source can be used as input for loaders.SpikeEEGBuild or loaders.SpikeEEGBuildEval

Training

After sythetic training dataset is generated, main.py can be used to train a DeepSIF model. network.py contains the architecture used in the paper. loaders.py provides two ways to load the dataset. If the data is already saved in seperate input/output files , SpikeEEGLoad can be used. If training data is generated on the run, SpikeEEGBuild can be used to generate different types of training data. To train a model, use

python main.py --model_id 1

Parameters:

'--save', type=int, default=True, help='save each epoch or not'
'--workers', default=0, type=int, help='number of data loading workers'
'--batch_size', default=64, type=int, help='batch size'
'--device', default='cuda:0', type=str, help='device running the code'
'--arch', default='TemporalInverseNet', type=str, help='network achitecture class'
'--dat', default='SpikeEEGBuild', type=str, help='data loader class'
'--train', default='test_sample_source2.mat', type=str, help='train dataset name or directory'
'--test', default='test_sample_source2.mat', type=str, help='test dataset name or directory'
'--model_id', default=75, type=int, help='model id'
'--lr', default=3e-4, type=float, help='learning rate'
'--resume', default='1', type=str, help='epoch id to resume'
'--epoch', default=20, type=int, help='total number of epoch'
'--fwd', default='leadfield_75_20k.mat', type=str, help='forward matrix to use'
'--rnn_layer', default=3, type=int, help='number of rnn layer'
'--info', default='', type=str, help='other information regarding this model'

Evaluation

Simulation :

After a model is trained, eval_sim.py can be used to evaluate the trained model in simulations under different conditions. Some examples are:

python eval_sim.py --model_id 75

Additional tests: narrow-band input

python eval_sim.py --model_id 75 --lfreq 1 --hfreq 3

Additional tests: different noise type

python eval_sim.py --model_id 75 --snr_rsn_ratio 0.5

Additional tests: different head / conductivity value / electrode locations

python eval_sim.py --model_id 75 --fwd <the forward matrix file>

Real data :

Or use real data as the model input as shown in eval_real.py:

python eval_real.py

Default subject folder : VEP

Dependencies

deepsif's People

Contributors

rachel-sunrui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

deepsif's Issues

Unrecognized function or variable 'mynorm'

Error happened when trying to run generate_sythetic_source.m

Unrecognized function or variable 'mynorm'.
Error in generate_sythetic_source>get_direction (line 218)
v = v./mynorm(v,2);

Simulating EEG

Dear authors,

Thanks for sharing the code. I am trying to reproduce the model's training set, i.e. generating the synthetic tvb data - I am quite new to this field. Do you generate the single source activity for each one of 998 regions by calling:
python generate_tvb_data.py --a_start 0 --a_end 998
using the connectivity_998.zip or just the 10 regions you mention in the README.md:
python generate_tvb_data.py --a_start 0 --a_end 10 ?

Best,
Stef

process_raw_nmm error

Run in Matlab

process_raw_nmm

Parameters:

  • iter_list: same as the length of mean_and_std in generate_tvb_data.py
  • leadfield_name: the size need to be consistent with the connectivity profile used in generate_tvb_data.py. If using the 76-region connectivity profile, need to use the 76-region leadfield. The default leadfield size is 75 times 994.

process_raw_nmm()
函数或变量 'nmm' 无法识别。

出错 process_raw_nmm (第 60 行)
nmm(:,[8,326,922,950]) = nmm(:,[995,998,997,996]); % remove empty NMM row

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.