-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathactivateInhibition.hoc
142 lines (124 loc) · 4.61 KB
/
activateInhibition.hoc
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// This function turns on a given number of inhibitory synapses contained within a
// given SectionList. !!NOTE!!: this function does not attempt to turn off
// all synapses before activating the desired synapses. It merely sets a
// subset of synapses to "on", agnostic to whether they were previously on
// or not. Note, however, that this function can be called twice to first
// turn all synapses off, and then turn on only the desired synapses. See
// notes below.
//
// This function can also be used to toggle off synapses in the following way:
// A) to shut off all synapses in a given SectionList, set $2<0.
// B) to shut off all synapses in all sections, set $2<0 and set $o2 to be
// the whole tree.
//
// Also, to activate all synapses in a given region, just set $2 to be a huge
// number; this will activate all of the synapses in the desired region.
//
// INPUT:
// $o1: SectionList instance. Sections to draw from.
// $2: variable. Number of synapses to active.
// $3: variable. The seed to assign.
// ($s4,$5 ; $s6,$7 ; ...): optional pairs of inhibitory driver line tags and logicals.
// $s4,6,8,... should be strdefs corresponding to genotypes (ie, "vgat",
// "sst","npy"). $5,7,9,... correspond to logicals
// as to whether these genotypes should be required (=1), should be
// not included at all (=0). If it doesn't matter for analysis, can
// leave these entries blank.
//
// OUTPUT:
// the .isOn flag is toggled as desired for the synapses selected.
//
// As an example, say one wanted to turn off all inhibitory synapses, except
// for 20 (VGAT+, SST-) interneurons in the tuft. The calls would be:
// activateInh(-1,cellList,1) // shuts of all inhibition, where cellList is a SectionList containing all sections.
// activateInh(tuftList,20,1,"vgat",1,"sst",0) // turn on 20 (VGAT+,SST-) synapses in the tuft.
//
strdef curGenStr
obfunc activateInhibition() {local numGen,i,ii,jj,curGenFlag localobj allSyns,theSec,passSyns,screenedSyns,finalSyns
allSyns = new Vector() // all (potential) synapses that qualify for activation
passSyns = new Vector() // binary vector representing whether each element
// in allSyns has passed the screening process for
// different genotypes.
screenedSyns = new Vector() // vector of synapse indices that pass screening process
finalSyns = new Vector() // vector of synapse indices that will be activated
numGen = int(numarg()/2 - 1) // number of genotypes being screened for or against
// interate over all synapses, adding those that are in the right
// domain.
for ii=0,totVgatAt-1{
synVgatAt[ii].get_loc()
theSec = new SectionRef()
if(sectionRefInList(theSec,$o1)){
allSyns.append(ii)
}
pop_section()
}
if($2<0){
// Want to shut off all synapses in the provided region.
for ii=0,allSyns.size()-1{
synVgatAt[allSyns.x[ii]].isOn = 0
}
return finalSyns
}else{
// for all synapses that are flagged, screen for/against, as set
// by desired arguments.
passSyns = new Vector(allSyns.size(),1) // originally, all start with one
for jj=1,numGen{
i = 2*(jj+1) // indices
curGenStr = $si // contains genotype flag
i = i + 1
curGenFlag = $i
for ii=0,allSyns.size()-1{
if(curGenFlag<0.1) {
// remove all synapses with this particular flag
if(abs(strcmp(curGenStr,"vgat"))<0.1){
if(abs(synVgatAt[allSyns.x[ii]].vgat-1)<0.1){
passSyns.x[ii] = 0
}
}
if(abs(strcmp(curGenStr,"sst"))<0.1){
if(abs(synVgatAt[allSyns.x[ii]].sst-1)<0.1){
passSyns.x[ii] = 0
}
}
if(abs(strcmp(curGenStr,"npy"))<0.1){
if(abs(synVgatAt[allSyns.x[ii]].npy-1)<0.1){
passSyns.x[ii] = 0
}
}
}else{
// remove synapses without this particular flag
if(abs(strcmp(curGenStr,"vgat"))<0.1){
if(abs(synVgatAt[allSyns.x[ii]].vgat-1)>0.1){
passSyns.x[ii] = 0
}
}
if(abs(strcmp(curGenStr,"sst"))<0.1){
if(abs(synVgatAt[allSyns.x[ii]].sst-1)>0.1){
passSyns.x[ii] = 0
}
}
if(abs(strcmp(curGenStr,"npy"))<0.1){
if(abs(synVgatAt[allSyns.x[ii]].npy-1)>0.1){
passSyns.x[ii] = 0
}
}
}
}
}
// Take only synapses that have passed the screening process.
for jj=0,allSyns.size()-1{
if(passSyns.x[jj]>0.1){
screenedSyns.append(allSyns.x[jj])
}
}
// Choose random indices from desired subset.
finalSyns = sampleNoReplace(screenedSyns,$2,$3) // supply a non-random seed
// Activate these synapses.
for ii=0,finalSyns.size()-1{
synVgatAt[finalSyns.x[ii]].isOn=1
}
// Give a final printout.
//print "Activated ",finalSyns.size,"inhibitory neurons"
return finalSyns
}
}