forked from VincentToups/matlab-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.txt
110 lines (86 loc) · 3.04 KB
/
README.txt
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Matlab Utilities
----------------
Created after many years of graduate school in computational
neuroscience, and covering a wide range of tasks from data analysis,
to figure preparation with a large amount of system-connecting in
between.
I am mostly adding putting this up for the sake of the Mathoc
subfolder, which contains a relatively complete and functional bridge
between matlab and the NEURON simulation environment. Rather than
explain lugubriously, an example may instead be more illustrative of
how it works and what it does:
init_hoc;
tstop = 5;
hoc_variable(tstop);
dt = .0125;
hoc_variable(dt);
call('load_file', "utilities.hoc");
call('load_file', "savers.hoc");
hoc('create soma');
neurons = {};
nNeurons = 50;
inhPerc = .2;
inhibitoryFlag = (1:nNeurons)<(nNeurons.*inhPerc);
for i=1:nNeurons
neurons{i} = instantiate('IntFire4',.5)
end
connections = {};
for i=1:length(neurons)
for j=1:length(neurons)
if i~=j
if inhibitoryFlag(i)
w = -.03;
else
w = .01;
end
connections{i,j} = instantiate('NetCon',neurons{i},neurons{j},0,0,w);
end
end
end
for i=1:nNeurons
stim = instantiate('NetStim');
hoc_set(stim,'interval',1);
hoc_set(stim,'number',1000);
hoc_set(stim,'noise',1);
netcon = instantiate('NetCon',stim,neurons{i},1,0,5);
end
for i=1:nNeurons
recording1 = instantiate('VoltageTraceSaver',...
'a',...
-1,...
-1,...
code('utils.nil'),...
sprintf('/tmp/recording%d.data',i),neurons{i},'m');
end
simulation_loop(1);
for i=1:nNeurons
delete(sprintf('/tmp/recording%d.data',i));
end
do_hoc(1);
data = [];
for i=1:nNeurons
data = [data; load(sprintf('/tmp/recording%d.data',i))];
end
t = linspace(0,tstop,length(data));
close all
plot(t,data);
The above piece of code uses NEURON, via Matlab or Octave, to create a
dead stupid model of a micro-column-like neural network. Fifty
neurons are created, and around 20% are assigned inhibitory status.
Then synaptic connections are created between all neurons depending on
that status. Finally, excitatory input is created via a series of
NetStim objects connected to each neuron, and objects for recording
the voltages of the neurons are created. `do_hoc` initiates the
simulation, and then the data from it is loaded and plotted.
Documentation is sparse right now, but the above example shows you how
to do most everything you'd want to do. The system needs to know
where your Neuron executable (nrniv) is located. You tell it by
specifying the global variable `hoc_exe_name__`.
This whole system is based on Matlab compiling a hoc file describing
the simulation, and then running it when `do_hoc` is called. You can
check the file by looking at the global variable `hoc__`.
There is a lot of stuff going on behind the scenes with file names and
so forth, and a lot of utilities on the hoc side to make things
easier. I'll talk about them as I document them.
Finally, you can't use this package without having my whole matlab
repository on the path somewhere (including sub-directories).