-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample_run_HybridSimulation.m
More file actions
executable file
·75 lines (55 loc) · 2.59 KB
/
Copy pathExample_run_HybridSimulation.m
File metadata and controls
executable file
·75 lines (55 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
%% Run a demo for the simulation of the Realistic Scenario
% Neural sources (D) [following [1]] and a speech-produced audio (A) [2] (in Data folder) are
% mixed to create noisy neural signal (H = D*A)
% You need to include the bml and filedtrip library in your path
%
% The function code_CUBN.c is a mex source code. You have to compile this routine in Matlab to generate the
% mex file (e.g.: code_CUBN.mexw64). Note that you have to include the functions ran1.c and gasdev.c in the
% compiling instruction in the Matlab workspace, in the following way:
% Go in utilites/sim-toolkit/CUBN
% run mex code_CUBN.c ran1.c gasdev.c
% WARNING: mex-files are optimized for Windows. It might not run in iOS
% operating systems.
%
% References:
% [1] S.Cavallari, S. Panzeri and A.Mazzoni (2014) Comparison of the
% dynamics of neural interactions between current-based and conductance-based
% integrate-and-fire recurrent networks, Frontiers in Neural Circuits
% 8:12. doi: 10.3389/fncir.2014.00012
% [2] Bush A, Chrabaszcz A, Peterson V, Saravanan V, Dastolfo-Hromack C,
% Lipski WJ, Richardson RM. Differentiation of speech-induced
% artifacts from physiological high gamma activity in intracranial
% recordings. Neuroimage. 2022 Apr 15;250:118962.
% see also CUBN folder in utilities (& https://senselab.med.yale.edu/ModelDB
% /showmodel.cshtml?model=152539&file=/CavallariEtAl2014__7_2015/LIF_COBN/
% for more information)
%
%author: mvissani
%last version: Jan 2023
%% Step 0: Set up the different folders
% include the folder (and subfolders) utilies in the path
addpath(genpath(['.' filesep 'utilities' filesep]))
% include the bml toolbox and run bml_defaults
bml_defaults;
% include the fieldtrip toolbox and run bml_defaults
ft_defaults;
% set random generator seed
randn('state',42);
% load exemplary audio
PATH_DATA = './Data';
%% Step 1: Simulate the neural signals (H = D*A)
% settings of simulation
n_sim = 3; % number of trials
n_sources = 99; % number of sources
n_channels = 60; % 100 number of channels
% get audio from ./Data folder
[audio, epochs] = get_audio(PATH_DATA);
% generate n_sources neural sources with n_sim trials of activity
[D, cfg_all] = generate_sources(n_sim, n_sources);
% parameters for mixing (A: noisy matrix & Agt: noiseless matrix)
A = generate_mixingmatrix(n_sources,n_channels);
% define (theoretical) SNR levels
SNR = -5:5; % -2:10
SNR_t = datasample(SNR,n_sim);
% mix neural sources and audio signals to create the (noisy) neural signals
H = create_mixedsources(D, audio, A, epochs, n_sim, n_channels, SNR_t);