copying to personal repo
This commit is contained in:
955
examples/LC_bushy.hoc
Normal file
955
examples/LC_bushy.hoc
Normal file
@@ -0,0 +1,955 @@
|
||||
proc celldef() {
|
||||
topol()
|
||||
}
|
||||
|
||||
create hillock[1], initialsegment[1], unmyelinatedaxon[1], soma[1], primarydendrite[100]
|
||||
|
||||
proc topol() { local i
|
||||
connect soma(0), hillock(0)
|
||||
connect initialsegment(0), hillock(1)
|
||||
connect unmyelinatedaxon(0), initialsegment(1)
|
||||
connect primarydendrite(0), soma(1)
|
||||
for i = 1, 7 connect primarydendrite[i](0), primarydendrite[i-1](1)
|
||||
for i = 8, 9 connect primarydendrite[i](0), primarydendrite[i-8](1)
|
||||
for i = 10, 13 connect primarydendrite[i](0), primarydendrite[i-1](1)
|
||||
connect primarydendrite[14](0), primarydendrite[12](1)
|
||||
connect primarydendrite[15](0), primarydendrite[11](1)
|
||||
connect primarydendrite[16](0), primarydendrite[4](1)
|
||||
for i = 17, 18 connect primarydendrite[i](0), primarydendrite[i-1](1)
|
||||
for i = 19, 22 connect primarydendrite[i](0), primarydendrite[16](1)
|
||||
connect primarydendrite[23](0), primarydendrite[2](1)
|
||||
for i = 24, 25 connect primarydendrite[i](0), primarydendrite[23](1)
|
||||
connect primarydendrite[26](0), primarydendrite[17](1)
|
||||
for i = 27, 28 connect primarydendrite[i](0), primarydendrite[i-1](1)
|
||||
for i = 29, 30 connect primarydendrite[i](0), primarydendrite[27](1)
|
||||
connect primarydendrite[31](0), primarydendrite[26](1)
|
||||
connect primarydendrite[32](0), primarydendrite[2](1)
|
||||
for i = 33, 35 connect primarydendrite[i](0), primarydendrite[i-1](1)
|
||||
for i = 36, 37 connect primarydendrite[i](0), primarydendrite[i-3](1)
|
||||
for i = 38, 39 connect primarydendrite[i](0), primarydendrite[i-1](1)
|
||||
connect primarydendrite[40](0), primarydendrite[38](1)
|
||||
for i = 41, 42 connect primarydendrite[i](0), primarydendrite[40](1)
|
||||
for i = 43, 44 connect primarydendrite[i](0), primarydendrite[42](1)
|
||||
connect primarydendrite[45](0), primarydendrite[37](1)
|
||||
for i = 46, 47 connect primarydendrite[i](0), primarydendrite[i-1](1)
|
||||
connect primarydendrite[48](0), primarydendrite[46](1)
|
||||
connect primarydendrite[49](0), primarydendrite[45](1)
|
||||
connect primarydendrite[50](0), primarydendrite[32](1)
|
||||
for i = 51, 53 connect primarydendrite[i](0), primarydendrite[i-1](1)
|
||||
connect primarydendrite[54](0), primarydendrite[52](1)
|
||||
connect primarydendrite[55](0), primarydendrite[51](1)
|
||||
for i = 56, 57 connect primarydendrite[i](0), primarydendrite[55](1)
|
||||
connect primarydendrite[58](0), primarydendrite[50](1)
|
||||
for i = 59, 60 connect primarydendrite[i](0), primarydendrite[58](1)
|
||||
connect primarydendrite[61](0), primarydendrite[51](1)
|
||||
for i = 62, 63 connect primarydendrite[i](0), primarydendrite[61](1)
|
||||
connect primarydendrite[64](0), primarydendrite[3](1)
|
||||
for i = 65, 69 connect primarydendrite[i](0), primarydendrite[i-1](1)
|
||||
connect primarydendrite[70](0), primarydendrite[68](1)
|
||||
connect primarydendrite[71](0), primarydendrite[67](1)
|
||||
connect primarydendrite[72](0), primarydendrite[65](1)
|
||||
connect primarydendrite[73](0), primarydendrite[64](1)
|
||||
connect primarydendrite[74](0), primarydendrite[66](1)
|
||||
for i = 75, 76 connect primarydendrite[i](0), primarydendrite[74](1)
|
||||
for i = 77, 78 connect primarydendrite[i](0), primarydendrite[76](1)
|
||||
connect primarydendrite[79](0), primarydendrite[64](1)
|
||||
for i = 80, 81 connect primarydendrite[i](0), primarydendrite[5](1)
|
||||
for i = 82, 84 connect primarydendrite[i](0), primarydendrite[81](1)
|
||||
for i = 85, 87 connect primarydendrite[i](0), primarydendrite[i-1](1)
|
||||
connect primarydendrite[88](0), primarydendrite[86](1)
|
||||
for i = 89, 90 connect primarydendrite[i](0), primarydendrite[88](1)
|
||||
for i = 91, 92 connect primarydendrite[i](0), primarydendrite[i-7](1)
|
||||
for i = 93, 94 connect primarydendrite[i](0), primarydendrite[92](1)
|
||||
connect primarydendrite[95](0), primarydendrite[6](1)
|
||||
for i = 96, 97 connect primarydendrite[i](0), primarydendrite[95](1)
|
||||
for i = 98, 99 connect primarydendrite[i](0), primarydendrite[i-89](1)
|
||||
basic_shape()
|
||||
}
|
||||
proc shape3d_1() {
|
||||
hillock[0] {pt3dclear()
|
||||
pt3dadd(61.38639625, 55.43400875, 0.0, 3.51044933)
|
||||
pt3dadd(63.01466225, 55.28039875, 0.0, 1.23072332)
|
||||
pt3dadd(63.963204, 55.2919195, 0.0, 0.67265819)
|
||||
}
|
||||
initialsegment[0] {pt3dclear()
|
||||
pt3dadd(63.963204, 55.2919195, 0.0, 0.67265819)
|
||||
pt3dadd(64.65060875, 55.35720375, 0.0, 0.30722)
|
||||
}
|
||||
unmyelinatedaxon[0] {pt3dclear()
|
||||
pt3dadd(64.65060875, 55.35720375, 0.0, 0.30722)
|
||||
pt3dadd(65.18824375, 55.5069735, 0.0, 0.370461237)
|
||||
pt3dadd(66.24047225, 55.5991395, 0.0, 0.480123416)
|
||||
pt3dadd(67.9493835, 55.75658975, 0.0, 0.489724041)
|
||||
pt3dadd(69.13602075, 55.81803375, 0.0, 0.4211141345)
|
||||
pt3dadd(69.953994, 55.714347, 0.0, 0.6103002105)
|
||||
pt3dadd(71.83187625, 55.83339475, 0.0, 0.5677348795)
|
||||
pt3dadd(73.901771, 55.51081375, 0.0, 0.615115884)
|
||||
pt3dadd(75.50315525, 55.4301685, 0.0, 0.4713138825)
|
||||
pt3dadd(76.15599775, 55.1843925, 0.0, 0.5377194855)
|
||||
pt3dadd(77.03157475, 55.69514575, 0.0, 0.4454766805)
|
||||
pt3dadd(77.49240475, 56.41711275, 0.0, 0.5473201105)
|
||||
pt3dadd(77.7650625, 57.36949475, 0.0, 0.6737565015)
|
||||
pt3dadd(77.910992, 57.8111235, 0.0, 0.296375134)
|
||||
pt3dadd(78.54463325, 58.75198475, 0.0, 0.3572891795)
|
||||
pt3dadd(79.0707475, 59.8080535, 0.0, 0.3138943545)
|
||||
pt3dadd(79.50469575, 61.01773225, 0.0, 0.340922034)
|
||||
pt3dadd(80.0077685, 62.10836325, 0.0, 0.3778575585)
|
||||
pt3dadd(80.5300425, 63.10682825, 0.0, 0.3418667355)
|
||||
pt3dadd(81.167524, 64.25890325, 0.0, 0.3259988225)
|
||||
pt3dadd(81.67827725, 64.97318975, 0.0, 0.4713138825)
|
||||
pt3dadd(82.043101, 65.5684285, 0.0, 0.487465974)
|
||||
pt3dadd(82.442487, 66.37104075, 0.0, 0.489539709)
|
||||
pt3dadd(82.57689575, 67.296541, 0.0, 0.5703308885)
|
||||
pt3dadd(82.1583085, 67.6268025, 0.0, 0.4573200115)
|
||||
pt3dadd(82.165989, 68.12987525, 0.0, 0.62411743)
|
||||
pt3dadd(82.3119185, 68.64446875, 0.0, 0.7671513815)
|
||||
pt3dadd(82.31575875, 69.04385475, 0.0, 0.251275238)
|
||||
pt3dadd(82.5423335, 69.44324075, 0.0, 0.428172514)
|
||||
pt3dadd(83.2028565, 70.04231975, 0.0, 0.4665980555)
|
||||
pt3dadd(83.42175075, 70.983181, 0.0, 0.480891466)
|
||||
pt3dadd(83.179815, 71.981646, 0.0, 0.56251982)
|
||||
pt3dadd(82.396404, 72.75353625, 0.0, 0.5373815435)
|
||||
pt3dadd(81.3748975, 72.949389, 0.0, 0.413272344)
|
||||
pt3dadd(80.276586, 72.81498025, 0.0, 0.489724041)
|
||||
pt3dadd(79.4394115, 73.7097585, 0.0, 0.556667279)
|
||||
pt3dadd(78.8403325, 75.00392275, 0.0, 0.639509152)
|
||||
}
|
||||
soma[0] {pt3dclear()
|
||||
pt3dadd(61.38639625, 55.43400875, 0.0, 3.51044933)
|
||||
pt3dadd(59.3318625, 55.60682, 0.0, 8.66437205)
|
||||
pt3dadd(57.1813225, 55.81803375, 0.0, 13.06222635)
|
||||
pt3dadd(55.7220275, 56.144455, 0.0, 13.7619199)
|
||||
pt3dadd(53.3410725, 56.81649875, 0.0, 13.8325805)
|
||||
pt3dadd(50.84491, 58.16058625, 0.0, 13.90708135)
|
||||
pt3dadd(47.44628875, 58.448605, 0.0, 11.5038529)
|
||||
pt3dadd(44.56610125, 58.26811325, 0.0, 6.441097715)
|
||||
pt3dadd(42.37715875, 57.6421525, 0.0, 2.400693885)
|
||||
}
|
||||
primarydendrite[0] {pt3dclear()
|
||||
pt3dadd(42.37715875, 57.6421525, 0.0, 1.46344247)
|
||||
pt3dadd(40.8525795, 57.23892625, 0.0, 1.46344247)
|
||||
pt3dadd(39.68130325, 56.7204925, 0.0, 1.48648397)
|
||||
pt3dadd(37.864865, 55.5991395, 0.0, 2.855533095)
|
||||
pt3dadd(36.38636875, 54.62755625, 0.0, 3.01428903)
|
||||
}
|
||||
primarydendrite[1] {pt3dclear()
|
||||
pt3dadd(36.38636875, 54.62755625, 0.0, 3.01428903)
|
||||
pt3dadd(35.02308, 53.2949895, 0.0, 2.006223405)
|
||||
pt3dadd(32.57991295, 48.5177185, 0.0, 1.446929395)
|
||||
pt3dadd(32.286901875, 47.93784075, 0.0, 1.488557705)
|
||||
}
|
||||
primarydendrite[2] {pt3dclear()
|
||||
pt3dadd(32.286901875, 47.93784075, 0.0, 1.488557705)
|
||||
pt3dadd(31.634059375, 46.48622625, 0.0, 0.72381032)
|
||||
pt3dadd(30.827606875, 44.8925225, 0.0, 0.704194323)
|
||||
pt3dadd(30.405179375, 43.82877325, 0.0, 1.114670965)
|
||||
pt3dadd(29.886745625, 42.76118375, 0.0, 1.479955545)
|
||||
pt3dadd(29.445116875, 41.37101325, 0.0, 0.6679193215)
|
||||
}
|
||||
primarydendrite[3] {pt3dclear()
|
||||
pt3dadd(29.445116875, 41.37101325, 0.0, 0.6679193215)
|
||||
pt3dadd(28.6866675, 40.3610275, 0.0, 0.7336797625)
|
||||
pt3dadd(27.601796875, 39.76578875, 0.0, 0.5964753105)
|
||||
pt3dadd(26.57453, 38.970857, 0.0, 2.474273075)
|
||||
}
|
||||
primarydendrite[4] {pt3dclear()
|
||||
pt3dadd(26.57453, 38.970857, 0.0, 2.474273075)
|
||||
pt3dadd(26.17130375, 38.6713175, 0.0, 1.76528612)
|
||||
}
|
||||
primarydendrite[5] {pt3dclear()
|
||||
pt3dadd(26.17130375, 38.6713175, 0.0, 1.76528612)
|
||||
pt3dadd(25.912086875, 38.008874375, 0.0, 1.27742076)
|
||||
pt3dadd(24.8464175, 37.394434375, 0.0, 0.4675811595)
|
||||
}
|
||||
primarydendrite[6] {pt3dclear()
|
||||
pt3dadd(24.8464175, 37.394434375, 0.0, 0.4675811595)
|
||||
pt3dadd(24.0015625, 36.799195625, 0.0, 0.3461524545)
|
||||
pt3dadd(23.339119375, 36.472774375, 0.0, 1.634948035)
|
||||
pt3dadd(22.79188375, 35.819931875, 0.0, 0.686160509)
|
||||
pt3dadd(21.87022375, 35.243894375, 0.0, 0.3958452895)
|
||||
pt3dadd(21.21738125, 34.552649375, 0.0, 1.3794178)
|
||||
}
|
||||
primarydendrite[7] {pt3dclear()
|
||||
pt3dadd(21.21738125, 34.552649375, 0.0, 1.3794178)
|
||||
pt3dadd(20.266919375, 33.938209375, 0.0, 0.480415275)
|
||||
pt3dadd(19.095643125, 34.187825625, 0.0, 0.317834451)
|
||||
pt3dadd(17.81876, 34.629454375, 0.0, 0.5170128575)
|
||||
pt3dadd(17.05071, 34.96547625, 0.0, 0.4241709735)
|
||||
pt3dadd(15.370600625, 35.407105, 0.0, 0.771199005)
|
||||
pt3dadd(14.80416375, 35.282296875, 0.0, 1.237405355)
|
||||
pt3dadd(14.13212, 34.437441875, 0.0, 0.638280272)
|
||||
pt3dadd(13.2488625, 34.015014375, 0.0, 0.3688406515)
|
||||
pt3dadd(12.519215, 33.592586875, 0.0, 0.298080205)
|
||||
pt3dadd(11.61675625, 33.458178125, 0.0, 0.558157296)
|
||||
pt3dadd(11.15592625, 33.563785, 0.0, 0.1920125)
|
||||
}
|
||||
primarydendrite[8] {pt3dclear()
|
||||
pt3dadd(36.38636875, 54.62755625, 0.0, 3.01428903)
|
||||
pt3dadd(37.754649825, 52.4501345, 0.0, 0.96451719)
|
||||
pt3dadd(38.2058792, 50.7604245, 0.0, 0.30737361)
|
||||
pt3dadd(38.61371375, 49.3472125, 0.0, 0.4036793995)
|
||||
pt3dadd(39.1935915, 48.7634945, 0.0, 0.407435164)
|
||||
pt3dadd(41.62831, 45.65673225, 0.0, 0.6537564795)
|
||||
pt3dadd(43.0645635, 45.5376845, 0.0, 0.480123416)
|
||||
}
|
||||
primarydendrite[9] {pt3dclear()
|
||||
pt3dadd(32.286901875, 47.93784075, 0.0, 1.488557705)
|
||||
pt3dadd(33.64059, 46.5054275, 0.0, 0.384025)
|
||||
pt3dadd(35.02308, 45.7373775, 0.0, 0.537635)
|
||||
pt3dadd(36.09835, 45.8909875, 0.0, 0.7081036975)
|
||||
}
|
||||
primarydendrite[10] {pt3dclear()
|
||||
pt3dadd(36.09835, 45.8909875, 0.0, 0.7081036975)
|
||||
pt3dadd(37.096815, 46.467025, 0.0, 0.61444)
|
||||
pt3dadd(38.4409025, 46.4286225, 0.0, 0.584931519)
|
||||
pt3dadd(39.63138, 46.7358425, 0.0, 0.6192249515)
|
||||
pt3dadd(40.629845, 48.54076, 0.0, 0.89569991)
|
||||
pt3dadd(41.21740325, 48.9017435, 0.0, 0.6418056215)
|
||||
}
|
||||
primarydendrite[11] {pt3dclear()
|
||||
pt3dadd(41.21740325, 48.9017435, 0.0, 0.6418056215)
|
||||
pt3dadd(41.659032, 49.5008225, 0.0, 0.695761134)
|
||||
}
|
||||
primarydendrite[12] {pt3dclear()
|
||||
pt3dadd(41.659032, 49.5008225, 0.0, 0.695761134)
|
||||
pt3dadd(42.28499275, 50.092221, 0.0, 0.597558261)
|
||||
}
|
||||
primarydendrite[13] {pt3dclear()
|
||||
pt3dadd(42.28499275, 50.092221, 0.0, 0.597558261)
|
||||
pt3dadd(43.241215, 50.17286625, 0.0, 0.489539709)
|
||||
pt3dadd(44.7389125, 50.57225225, 0.0, 0.355223125)
|
||||
}
|
||||
primarydendrite[14] {pt3dclear()
|
||||
pt3dadd(42.28499275, 50.092221, 0.0, 0.597558261)
|
||||
pt3dadd(42.580692, 50.937076, 0.0, 0.347880567)
|
||||
pt3dadd(43.17593075, 51.41710725, 0.0, 0.401966648)
|
||||
pt3dadd(43.70588525, 51.96242275, 0.0, 0.4129420825)
|
||||
pt3dadd(44.070709, 52.626786, 0.0, 0.428710149)
|
||||
pt3dadd(44.38944975, 53.19130275, 0.0, 0.418264669)
|
||||
}
|
||||
primarydendrite[15] {pt3dclear()
|
||||
pt3dadd(41.659032, 49.5008225, 0.0, 0.695761134)
|
||||
pt3dadd(42.765024, 49.48162125, 0.0, 0.441736277)
|
||||
pt3dadd(45.222784, 49.477781, 0.0, 0.489724041)
|
||||
pt3dadd(45.83338375, 49.18976225, 0.0, 0.355223125)
|
||||
pt3dadd(46.77808525, 49.40481625, 0.0, 0.3085640875)
|
||||
pt3dadd(47.5038925, 48.94398625, 0.0, 0.399554971)
|
||||
pt3dadd(48.2719425, 49.0707145, 0.0, 0.5240942785)
|
||||
pt3dadd(49.861806, 49.324171, 0.0, 0.3553536935)
|
||||
}
|
||||
primarydendrite[16] {pt3dclear()
|
||||
pt3dadd(26.17130375, 38.6713175, 0.0, 1.76528612)
|
||||
pt3dadd(26.78574375, 37.548044375, 0.0, 0.6454615395)
|
||||
pt3dadd(27.467388125, 36.261560625, 0.0, 0.618326333)
|
||||
pt3dadd(28.1828267, 35.527304825, 0.0, 0.652980749)
|
||||
pt3dadd(28.57146, 34.792665, 0.0, 1.174886085)
|
||||
}
|
||||
primarydendrite[17] {pt3dclear()
|
||||
pt3dadd(28.57146, 34.792665, 0.0, 1.174886085)
|
||||
pt3dadd(28.72507, 33.65979125, 0.0, 0.4241709735)
|
||||
pt3dadd(29.03229, 32.41171, 0.0, 0.462427544)
|
||||
pt3dadd(29.3011075, 31.47084875, 0.0, 0.32811096)
|
||||
pt3dadd(29.51232125, 31.077223125, 0.0, 0.5240942785)
|
||||
pt3dadd(30.193965625, 29.560324375, 0.0, 0.631598237)
|
||||
pt3dadd(30.616393125, 29.03229, 0.0, 0.3102077145)
|
||||
pt3dadd(31.000418125, 28.427450625, 0.0, 0.455192513)
|
||||
}
|
||||
primarydendrite[18] {pt3dclear()
|
||||
pt3dadd(31.000418125, 28.427450625, 0.0, 0.455192513)
|
||||
pt3dadd(32.027685, 26.776143125, 0.0, 0.3418667355)
|
||||
}
|
||||
primarydendrite[19] {pt3dclear()
|
||||
pt3dadd(28.57146, 34.792665, 0.0, 1.174886085)
|
||||
pt3dadd(28.97468625, 35.915938125, 0.0, 0.618326333)
|
||||
pt3dadd(29.233903125, 36.338365625, 0.0, 0.518787053)
|
||||
pt3dadd(29.6851325, 37.2120225, 0.0, 0.485760903)
|
||||
}
|
||||
primarydendrite[20] {pt3dclear()
|
||||
pt3dadd(28.57146, 34.792665, 0.0, 1.174886085)
|
||||
pt3dadd(29.099494375, 34.25503, 0.0, 0.602627391)
|
||||
pt3dadd(29.32030875, 33.73659625, 0.0, 0.4640174075)
|
||||
pt3dadd(29.387513125, 33.266165625, 0.0, 0.2886562315)
|
||||
}
|
||||
primarydendrite[21] {pt3dclear()
|
||||
pt3dadd(28.57146, 34.792665, 0.0, 1.174886085)
|
||||
pt3dadd(27.928218125, 34.187825625, 0.0, 0.678864034)
|
||||
pt3dadd(27.870614375, 33.39097375, 0.0, 0.3728191505)
|
||||
pt3dadd(28.043425625, 32.651725625, 0.0, 0.256175397)
|
||||
pt3dadd(28.081828125, 31.806870625, 0.0, 0.3314673385)
|
||||
pt3dadd(28.033825, 30.942814375, 0.0, 0.4432954185)
|
||||
pt3dadd(27.524991875, 30.030755, 0.0, 0.5607917075)
|
||||
pt3dadd(27.313778125, 29.6083275, 0.0, 1.345854015)
|
||||
pt3dadd(26.968155625, 28.87868, 0.0, 1.073349875)
|
||||
pt3dadd(26.67053625, 28.16823375, 0.0, 0.570891565)
|
||||
pt3dadd(26.3825175, 27.74580625, 0.0, 0.4640174075)
|
||||
pt3dadd(26.161703125, 27.332979375, 0.0, 0.34024615)
|
||||
pt3dadd(25.969690625, 26.958555, 0.0, 0.261167722)
|
||||
pt3dadd(25.729675, 26.488124375, 0.0, 0.3125733085)
|
||||
pt3dadd(25.624068125, 26.28651125, 0.0, 0.1770278445)
|
||||
}
|
||||
primarydendrite[22] {pt3dclear()
|
||||
pt3dadd(28.57146, 34.792665, 0.0, 1.174886085)
|
||||
pt3dadd(27.55379375, 34.859869375, 0.0, 0.51843375)
|
||||
pt3dadd(27.025759375, 35.00387875, 0.0, 0.815745905)
|
||||
pt3dadd(26.6897375, 35.11908625, 0.0, 0.78325739)
|
||||
pt3dadd(26.57453, 34.667856875, 0.0, 0.406866807)
|
||||
pt3dadd(25.9984925, 34.2166275, 0.0, 0.899770575)
|
||||
pt3dadd(25.854483125, 33.62138875, 0.0, 0.40322625)
|
||||
pt3dadd(25.624068125, 32.632524375, 0.0, 0.498495172)
|
||||
pt3dadd(26.036895, 31.557254375, 0.0, 1.00015471)
|
||||
pt3dadd(26.05609625, 30.635594375, 0.0, 1.121737025)
|
||||
pt3dadd(25.662470625, 30.385978125, 0.0, 0.5101925735)
|
||||
pt3dadd(25.422455, 29.541123125, 0.0, 0.5240942785)
|
||||
pt3dadd(25.144036875, 29.291506875, 0.0, 0.81689798)
|
||||
pt3dadd(24.913621875, 28.465853125, 0.0, 0.335883626)
|
||||
pt3dadd(24.500795, 28.101029375, 0.0, 0.4753999085)
|
||||
pt3dadd(24.4193817, 27.81800295, 0.0, 0.5671665225)
|
||||
pt3dadd(24.42399, 25.638661075, 0.0, 0.3457530685)
|
||||
pt3dadd(25.0768325, 24.606401875, 0.0, 0.4648161795)
|
||||
pt3dadd(25.067231875, 23.051100625, 0.0, 0.3461524545)
|
||||
}
|
||||
primarydendrite[23] {pt3dclear()
|
||||
pt3dadd(29.445116875, 41.37101325, 0.0, 0.6679193215)
|
||||
pt3dadd(29.848343125, 40.48775575, 0.0, 0.515223301)
|
||||
pt3dadd(30.347575625, 39.3164795, 0.0, 0.489539709)
|
||||
pt3dadd(30.31877375, 38.311486075, 0.0, 0.45530004)
|
||||
pt3dadd(30.2995725, 38.085679375, 0.0, 0.542074329)
|
||||
}
|
||||
primarydendrite[24] {pt3dclear()
|
||||
pt3dadd(30.2995725, 38.085679375, 0.0, 0.542074329)
|
||||
pt3dadd(29.51232125, 38.87485075, 0.0, 0.4353230595)
|
||||
}
|
||||
primarydendrite[25] {pt3dclear()
|
||||
pt3dadd(30.2995725, 38.085679375, 0.0, 0.542074329)
|
||||
pt3dadd(30.405179375, 37.759258125, 0.0, 0.549171111)
|
||||
pt3dadd(30.789204375, 37.140209825, 0.0, 0.5485797125)
|
||||
pt3dadd(31.168621075, 36.525769825, 0.0, 0.476759357)
|
||||
pt3dadd(31.1444275, 35.253495, 0.0, 0.5198546425)
|
||||
}
|
||||
}
|
||||
proc shape3d_2() {
|
||||
primarydendrite[25] {pt3dclear()
|
||||
pt3dadd(30.962015625, 34.5960442, 0.0, 0.529078923)
|
||||
pt3dadd(30.904411875, 33.27115795, 0.0, 0.601475316)
|
||||
pt3dadd(30.50617795, 32.128683575, 0.0, 0.6625122495)
|
||||
pt3dadd(30.746193575, 31.730065625, 0.0, 0.528034375)
|
||||
pt3dadd(31.4516475, 31.518851875, 0.0, 0.558157296)
|
||||
pt3dadd(32.455104825, 30.707791075, 0.0, 0.5432648065)
|
||||
pt3dadd(32.939744375, 30.213166875, 0.0, 0.638280272)
|
||||
pt3dadd(33.73659625, 29.632521075, 0.0, 0.688372493)
|
||||
pt3dadd(34.029607325, 29.1474975, 0.0, 0.903149995)
|
||||
pt3dadd(34.164016075, 28.773073125, 0.0, 0.5725889555)
|
||||
}
|
||||
primarydendrite[26] {pt3dclear()
|
||||
pt3dadd(31.000418125, 28.427450625, 0.0, 0.455192513)
|
||||
pt3dadd(31.77806875, 28.41785, 0.0, 0.4687639565)
|
||||
}
|
||||
primarydendrite[27] {pt3dclear()
|
||||
pt3dadd(31.77806875, 28.41785, 0.0, 0.4687639565)
|
||||
pt3dadd(32.31570375, 27.78420875, 0.0, 0.5430958355)
|
||||
pt3dadd(32.786134375, 27.236973125, 0.0, 0.6567825965)
|
||||
pt3dadd(33.410175, 26.603331875, 0.0, 0.81029275)
|
||||
pt3dadd(33.6789925, 25.48005875, 0.0, 0.884102355)
|
||||
pt3dadd(33.81340125, 24.28958125, 0.0, 0.76805)
|
||||
pt3dadd(33.919008125, 23.569534375, 0.0, 0.63625262)
|
||||
pt3dadd(34.10142, 23.13750625, 0.0, 0.80737416)
|
||||
pt3dadd(34.85026875, 22.494264375, 0.0, 0.5647241235)
|
||||
pt3dadd(35.051881875, 21.98543125, 0.0, 0.5324660235)
|
||||
pt3dadd(35.301498125, 21.361390625, 0.0, 0.42503887)
|
||||
pt3dadd(35.762328125, 20.324523125, 0.0, 0.61981635)
|
||||
pt3dadd(36.04074625, 19.7772875, 0.0, 0.276928108)
|
||||
pt3dadd(36.77039375, 18.961234375, 0.0, 0.55683625)
|
||||
pt3dadd(37.240824375, 18.37559625, 0.0, 0.975500305)
|
||||
}
|
||||
primarydendrite[28] {pt3dclear()
|
||||
pt3dadd(37.240824375, 18.37559625, 0.0, 0.975500305)
|
||||
pt3dadd(37.336830625, 17.72275375, 0.0, 0.4936641375)
|
||||
pt3dadd(37.65365125, 16.7818925, 0.0, 0.5498393145)
|
||||
pt3dadd(38.277691875, 15.57221375, 0.0, 0.399554971)
|
||||
pt3dadd(38.72124075, 14.621751875, 0.0, 0.598019091)
|
||||
pt3dadd(39.0860645, 13.469676875, 0.0, 0.498495172)
|
||||
pt3dadd(39.247355, 12.13519, 0.0, 0.5760375)
|
||||
pt3dadd(39.60449825, 10.61829125, 0.0, 1.00599189)
|
||||
pt3dadd(39.80419125, 9.50461875, 0.0, 0.5051080825)
|
||||
pt3dadd(40.476235, 8.496553125, 0.0, 0.506928361)
|
||||
pt3dadd(41.4670195, 7.574893125, 0.0, 0.598019091)
|
||||
pt3dadd(42.734302, 6.3364125, 0.0, 0.6451696805)
|
||||
pt3dadd(44.009265, 4.91552, 0.0, 0.5457993715)
|
||||
pt3dadd(44.9232445, 3.273813125, 0.0, 0.5598086035)
|
||||
}
|
||||
primarydendrite[29] {pt3dclear()
|
||||
pt3dadd(37.240824375, 18.37559625, 0.0, 0.975500305)
|
||||
pt3dadd(37.92246875, 18.500404375, 0.0, 0.44162875)
|
||||
pt3dadd(38.52922825, 18.558008125, 0.0, 0.6102234055)
|
||||
pt3dadd(39.4700895, 18.817225, 0.0, 0.4263368745)
|
||||
pt3dadd(40.25734075, 18.730819375, 0.0, 0.6102234055)
|
||||
pt3dadd(40.68744875, 18.60601125, 0.0, 0.82903317)
|
||||
pt3dadd(41.3594925, 18.385196875, 0.0, 0.410476642)
|
||||
}
|
||||
primarydendrite[30] {pt3dclear()
|
||||
pt3dadd(37.240824375, 18.37559625, 0.0, 0.975500305)
|
||||
pt3dadd(36.626384375, 17.962769375, 0.0, 0.4353230595)
|
||||
pt3dadd(36.069548125, 18.154781875, 0.0, 0.535576626)
|
||||
pt3dadd(35.08068375, 18.7020175, 0.0, 0.500707156)
|
||||
pt3dadd(34.303033125, 19.690881875, 0.0, 0.862596955)
|
||||
pt3dadd(33.976611875, 21.37099125, 0.0, 0.3728191505)
|
||||
}
|
||||
primarydendrite[31] {pt3dclear()
|
||||
pt3dadd(31.77806875, 28.41785, 0.0, 0.4687639565)
|
||||
pt3dadd(32.632524375, 28.36024625, 0.0, 0.4228652885)
|
||||
pt3dadd(33.12215625, 28.465853125, 0.0, 0.4193629805)
|
||||
pt3dadd(33.6021875, 28.033825, 0.0, 0.462427544)
|
||||
pt3dadd(34.437441875, 27.13136625, 0.0, 0.4228652885)
|
||||
pt3dadd(35.109485625, 26.28651125, 0.0, 0.7258456525)
|
||||
pt3dadd(35.762328125, 25.278445625, 0.0, 1.11336528)
|
||||
pt3dadd(36.280761875, 24.63520375, 0.0, 0.2930955605)
|
||||
}
|
||||
primarydendrite[32] {pt3dclear()
|
||||
pt3dadd(29.445116875, 41.37101325, 0.0, 0.6679193215)
|
||||
pt3dadd(30.24196875, 40.890982, 0.0, 0.32642125)
|
||||
pt3dadd(31.365241875, 40.0538075, 0.0, 0.3958452895)
|
||||
pt3dadd(31.874075, 39.093745, 0.0, 0.5498393145)
|
||||
pt3dadd(33.400574375, 38.11448125, 0.0, 0.5170128575)
|
||||
pt3dadd(34.5238475, 37.548044375, 0.0, 0.506928361)
|
||||
pt3dadd(35.531913125, 36.55918, 0.0, 0.686160509)
|
||||
pt3dadd(36.357566875, 36.55918, 0.0, 0.931414235)
|
||||
}
|
||||
primarydendrite[33] {pt3dclear()
|
||||
pt3dadd(36.357566875, 36.55918, 0.0, 0.931414235)
|
||||
pt3dadd(37.9800725, 37.02001, 0.0, 0.5760375)
|
||||
pt3dadd(39.201272, 37.404035, 0.0, 0.6440329665)
|
||||
pt3dadd(40.41095075, 37.548044375, 0.0, 0.442043497)
|
||||
}
|
||||
primarydendrite[34] {pt3dclear()
|
||||
pt3dadd(40.41095075, 37.548044375, 0.0, 0.442043497)
|
||||
pt3dadd(41.63983075, 37.125616875, 0.0, 0.647742648)
|
||||
}
|
||||
primarydendrite[35] {pt3dclear()
|
||||
pt3dadd(41.63983075, 37.125616875, 0.0, 0.647742648)
|
||||
pt3dadd(42.4654845, 38.008874375, 0.0, 0.718956244)
|
||||
}
|
||||
primarydendrite[36] {pt3dclear()
|
||||
pt3dadd(40.41095075, 37.548044375, 0.0, 0.442043497)
|
||||
pt3dadd(40.4685545, 37.864865, 0.0, 0.3286716365)
|
||||
pt3dadd(40.41863125, 38.510027, 0.0, 0.499601164)
|
||||
pt3dadd(40.4685545, 39.14366825, 0.0, 0.751060734)
|
||||
pt3dadd(41.01387, 39.95780125, 0.0, 0.5223277635)
|
||||
pt3dadd(41.48622075, 40.67976825, 0.0, 0.6875045965)
|
||||
}
|
||||
primarydendrite[37] {pt3dclear()
|
||||
pt3dadd(41.63983075, 37.125616875, 0.0, 0.647742648)
|
||||
pt3dadd(42.6190945, 36.856799375, 0.0, 0.442043497)
|
||||
pt3dadd(43.02232075, 36.568780625, 0.0, 0.4519436615)
|
||||
}
|
||||
primarydendrite[38] {pt3dclear()
|
||||
pt3dadd(43.02232075, 36.568780625, 0.0, 0.4519436615)
|
||||
pt3dadd(43.702045, 36.607183125, 0.0, 0.5607917075)
|
||||
pt3dadd(44.577622, 36.607183125, 0.0, 0.572827051)
|
||||
}
|
||||
primarydendrite[39] {pt3dclear()
|
||||
pt3dadd(44.577622, 36.607183125, 0.0, 0.572827051)
|
||||
pt3dadd(45.82570325, 35.92553875, 0.0, 0.3418667355)
|
||||
pt3dadd(46.54383, 35.2918975, 0.0, 0.5430958355)
|
||||
pt3dadd(46.93937575, 34.77346375, 0.0, 0.99201338)
|
||||
pt3dadd(47.6882245, 34.264630625, 0.0, 0.489539709)
|
||||
}
|
||||
primarydendrite[40] {pt3dclear()
|
||||
pt3dadd(44.577622, 36.607183125, 0.0, 0.572827051)
|
||||
pt3dadd(45.1536595, 38.239289375, 0.0, 0.6102234055)
|
||||
pt3dadd(45.51848325, 39.093745, 0.0, 0.864901105)
|
||||
}
|
||||
primarydendrite[41] {pt3dclear()
|
||||
pt3dadd(45.51848325, 39.093745, 0.0, 0.864901105)
|
||||
pt3dadd(45.97931325, 39.42016625, 0.0, 0.4753999085)
|
||||
pt3dadd(46.5054275, 39.95780125, 0.0, 0.7603310975)
|
||||
pt3dadd(46.85105, 40.30342375, 0.0, 0.4344782045)
|
||||
}
|
||||
primarydendrite[42] {pt3dclear()
|
||||
pt3dadd(45.51848325, 39.093745, 0.0, 0.864901105)
|
||||
pt3dadd(44.777315, 39.41248575, 0.0, 0.3958452895)
|
||||
pt3dadd(44.22047875, 40.14981375, 0.0, 0.787942495)
|
||||
}
|
||||
primarydendrite[43] {pt3dclear()
|
||||
pt3dadd(44.22047875, 40.14981375, 0.0, 0.787942495)
|
||||
pt3dadd(43.62524, 40.87946125, 0.0, 0.4082262555)
|
||||
}
|
||||
primarydendrite[44] {pt3dclear()
|
||||
pt3dadd(44.22047875, 40.14981375, 0.0, 0.787942495)
|
||||
pt3dadd(43.963182, 39.56609575, 0.0, 0.4073199565)
|
||||
pt3dadd(43.5100325, 39.01694, 0.0, 0.896544765)
|
||||
pt3dadd(43.16441, 38.258490625, 0.0, 0.3418667355)
|
||||
}
|
||||
primarydendrite[45] {pt3dclear()
|
||||
pt3dadd(43.02232075, 36.568780625, 0.0, 0.4519436615)
|
||||
pt3dadd(43.3103395, 36.146353125, 0.0, 0.678864034)
|
||||
pt3dadd(43.36794325, 35.560715, 0.0, 0.7114831175)
|
||||
pt3dadd(42.933995, 35.253495, 0.0, 0.364316837)
|
||||
pt3dadd(43.13752825, 34.792665, 0.0, 0.78817291)
|
||||
pt3dadd(43.49083125, 34.6006525, 0.0, 1.08417938)
|
||||
pt3dadd(44.039987, 34.35103625, 0.0, 0.3418667355)
|
||||
pt3dadd(44.41249125, 33.938209375, 0.0, 0.6989331805)
|
||||
pt3dadd(45.4301575, 33.4485775, 0.0, 0.384025)
|
||||
pt3dadd(46.159805, 33.00694875, 0.0, 0.4992325)
|
||||
pt3dadd(47.3041995, 32.901341875, 0.0, 0.640876281)
|
||||
}
|
||||
primarydendrite[46] {pt3dclear()
|
||||
pt3dadd(47.3041995, 32.901341875, 0.0, 0.640876281)
|
||||
pt3dadd(48.01464575, 33.16055875, 0.0, 0.4332032415)
|
||||
}
|
||||
primarydendrite[47] {pt3dclear()
|
||||
pt3dadd(48.01464575, 33.16055875, 0.0, 0.4332032415)
|
||||
pt3dadd(48.16825575, 33.2181625, 0.0, 0.3102077145)
|
||||
pt3dadd(48.71357125, 33.362171875, 0.0, 0.4432954185)
|
||||
pt3dadd(49.44321875, 33.42937625, 0.0, 0.462427544)
|
||||
pt3dadd(50.184387, 33.256565, 0.0, 0.528295512)
|
||||
pt3dadd(51.30574, 32.96854625, 0.0, 0.3456225)
|
||||
}
|
||||
primarydendrite[48] {pt3dclear()
|
||||
pt3dadd(48.01464575, 33.16055875, 0.0, 0.4332032415)
|
||||
pt3dadd(48.28346325, 32.9109425, 0.0, 0.261167722)
|
||||
pt3dadd(48.47547575, 32.344505625, 0.0, 0.442043497)
|
||||
}
|
||||
primarydendrite[49] {pt3dclear()
|
||||
pt3dadd(47.3041995, 32.901341875, 0.0, 0.640876281)
|
||||
pt3dadd(47.5038925, 32.267700625, 0.0, 0.4432954185)
|
||||
pt3dadd(47.6882245, 31.720465, 0.0, 0.5324660235)
|
||||
pt3dadd(48.48315625, 31.12522625, 0.0, 0.6869669615)
|
||||
pt3dadd(49.6083495, 30.39557875, 0.0, 0.352488867)
|
||||
pt3dadd(50.31879575, 29.85794375, 0.0, 0.686160509)
|
||||
pt3dadd(51.44014875, 29.55072375, 0.0, 0.577312463)
|
||||
pt3dadd(52.24660125, 29.416315, 0.0, 0.2688175)
|
||||
}
|
||||
primarydendrite[50] {pt3dclear()
|
||||
pt3dadd(36.357566875, 36.55918, 0.0, 0.931414235)
|
||||
pt3dadd(36.453573125, 35.781529375, 0.0, 0.5216211575)
|
||||
pt3dadd(36.69358875, 35.147888125, 0.0, 0.7145860395)
|
||||
}
|
||||
primarydendrite[51] {pt3dclear()
|
||||
pt3dadd(36.69358875, 35.147888125, 0.0, 0.7145860395)
|
||||
pt3dadd(37.250425, 34.86947, 0.0, 0.4687639565)
|
||||
pt3dadd(38.6713175, 34.226228125, 0.0, 0.498126508)
|
||||
pt3dadd(39.30495875, 33.611788125, 0.0, 0.6230805625)
|
||||
pt3dadd(39.87331575, 33.33337, 0.0, 1.143242425)
|
||||
}
|
||||
primarydendrite[52] {pt3dclear()
|
||||
pt3dadd(39.87331575, 33.33337, 0.0, 1.143242425)
|
||||
pt3dadd(40.44935325, 33.02615, 0.0, 0.7031420945)
|
||||
pt3dadd(40.94858575, 32.478914375, 0.0, 0.381137132)
|
||||
}
|
||||
primarydendrite[53] {pt3dclear()
|
||||
pt3dadd(40.94858575, 32.478914375, 0.0, 0.381137132)
|
||||
pt3dadd(41.41709625, 32.2965025, 0.0, 0.2924657595)
|
||||
pt3dadd(42.22354875, 31.806870625, 0.0, 0.4228652885)
|
||||
pt3dadd(43.22201375, 30.731600625, 0.0, 0.4482570215)
|
||||
pt3dadd(43.502352, 29.569925, 0.0, 0.3353383105)
|
||||
pt3dadd(43.502352, 28.811475625, 0.0, 0.4036793995)
|
||||
}
|
||||
primarydendrite[54] {pt3dclear()
|
||||
pt3dadd(40.94858575, 32.478914375, 0.0, 0.381137132)
|
||||
pt3dadd(40.7757745, 31.81647125, 0.0, 0.3728191505)
|
||||
pt3dadd(41.18668125, 31.096424375, 0.0, 0.405054209)
|
||||
pt3dadd(41.4362975, 30.47238375, 0.0, 0.395376779)
|
||||
pt3dadd(41.9278495, 29.6083275, 0.0, 0.48156735)
|
||||
pt3dadd(42.06993875, 29.022689375, 0.0, 0.808526235)
|
||||
pt3dadd(42.196667, 28.3794475, 0.0, 0.32642125)
|
||||
}
|
||||
primarydendrite[55] {pt3dclear()
|
||||
pt3dadd(39.87331575, 33.33337, 0.0, 1.143242425)
|
||||
pt3dadd(39.56609575, 32.690128125, 0.0, 0.4742324725)
|
||||
pt3dadd(39.3932845, 32.2196975, 0.0, 0.9416293)
|
||||
pt3dadd(38.7481225, 32.056486875, 0.0, 0.5915137075)
|
||||
pt3dadd(38.7481225, 31.33644, 0.0, 0.46083)
|
||||
}
|
||||
primarydendrite[56] {pt3dclear()
|
||||
pt3dadd(38.7481225, 31.33644, 0.0, 0.46083)
|
||||
pt3dadd(38.92093375, 30.654795625, 0.0, 0.3958452895)
|
||||
pt3dadd(39.26655625, 30.059556875, 0.0, 0.4211141345)
|
||||
pt3dadd(39.57377625, 29.12829625, 0.0, 0.2924657595)
|
||||
pt3dadd(40.34182625, 28.39864875, 0.0, 0.4378576245)
|
||||
pt3dadd(40.7450525, 28.043425625, 0.0, 0.89339576)
|
||||
pt3dadd(41.0522725, 27.55379375, 0.0, 0.395376779)
|
||||
}
|
||||
primarydendrite[57] {pt3dclear()
|
||||
pt3dadd(38.7481225, 31.33644, 0.0, 0.46083)
|
||||
pt3dadd(38.2872925, 31.39404375, 0.0, 0.6528425)
|
||||
pt3dadd(37.80726125, 31.566855, 0.0, 0.581137352)
|
||||
}
|
||||
primarydendrite[58] {pt3dclear()
|
||||
pt3dadd(36.69358875, 35.147888125, 0.0, 0.7145860395)
|
||||
pt3dadd(36.511176875, 34.6774575, 0.0, 0.456406032)
|
||||
pt3dadd(36.280761875, 34.053416875, 0.0, 0.678864034)
|
||||
pt3dadd(35.9831425, 33.381373125, 0.0, 0.659862477)
|
||||
pt3dadd(36.04074625, 32.85333875, 0.0, 0.6539715335)
|
||||
pt3dadd(36.146353125, 32.2965025, 0.0, 0.32642125)
|
||||
}
|
||||
primarydendrite[59] {pt3dclear()
|
||||
pt3dadd(36.146353125, 32.2965025, 0.0, 0.32642125)
|
||||
pt3dadd(36.175155, 31.9124775, 0.0, 0.4241709735)
|
||||
pt3dadd(36.069548125, 31.346040625, 0.0, 1.01781986)
|
||||
pt3dadd(35.88713625, 30.81800625, 0.0, 0.3859374445)
|
||||
}
|
||||
primarydendrite[60] {pt3dclear()
|
||||
pt3dadd(36.146353125, 32.2965025, 0.0, 0.32642125)
|
||||
pt3dadd(35.608718125, 32.23889875, 0.0, 0.3125733085)
|
||||
pt3dadd(35.23429375, 32.2196975, 0.0, 0.5430958355)
|
||||
pt3dadd(34.821466875, 32.2196975, 0.0, 0.92027751)
|
||||
pt3dadd(34.648655625, 32.9877475, 0.0, 0.78817291)
|
||||
}
|
||||
primarydendrite[61] {pt3dclear()
|
||||
pt3dadd(39.87331575, 33.33337, 0.0, 1.143242425)
|
||||
pt3dadd(40.37254825, 33.92860875, 0.0, 0.399554971)
|
||||
pt3dadd(40.5914425, 34.2934325, 0.0, 0.4750158835)
|
||||
pt3dadd(41.10219575, 33.7942, 0.0, 0.697880952)
|
||||
pt3dadd(41.3594925, 33.48698, 0.0, 0.4153844815)
|
||||
}
|
||||
}
|
||||
proc shape3d_3() {
|
||||
primarydendrite[61] { }
|
||||
primarydendrite[62] {pt3dclear()
|
||||
pt3dadd(41.3594925, 33.48698, 0.0, 0.4153844815)
|
||||
pt3dadd(42.319555, 34.19742625, 0.0, 0.4241709735)
|
||||
}
|
||||
primarydendrite[63] {pt3dclear()
|
||||
pt3dadd(41.3594925, 33.48698, 0.0, 0.4153844815)
|
||||
pt3dadd(41.858725, 32.93014375, 0.0, 0.6629269965)
|
||||
pt3dadd(42.3579575, 33.1413575, 0.0, 0.79170594)
|
||||
pt3dadd(42.9263145, 32.728530625, 0.0, 0.489539709)
|
||||
pt3dadd(44.02846625, 32.334905, 0.0, 0.384025)
|
||||
pt3dadd(44.90404325, 31.8356725, 0.0, 0.3688406515)
|
||||
pt3dadd(45.62217, 31.2980375, 0.0, 0.4344782045)
|
||||
pt3dadd(46.5822325, 30.750801875, 0.0, 0.4228652885)
|
||||
pt3dadd(47.36948375, 30.04995625, 0.0, 0.3801617085)
|
||||
pt3dadd(48.20665825, 29.464318125, 0.0, 0.4036793995)
|
||||
pt3dadd(48.63676625, 29.176299375, 0.0, 0.82657541)
|
||||
pt3dadd(49.078395, 29.58912625, 0.0, 0.2999312055)
|
||||
}
|
||||
primarydendrite[64] {pt3dclear()
|
||||
pt3dadd(26.57453, 38.970857, 0.0, 2.474273075)
|
||||
pt3dadd(25.28804625, 40.09221, 0.0, 0.6606996515)
|
||||
pt3dadd(24.039965, 40.967787, 0.0, 0.831874955)
|
||||
pt3dadd(23.71354375, 41.0522725, 0.0, 1.306222635)
|
||||
}
|
||||
primarydendrite[65] {pt3dclear()
|
||||
pt3dadd(23.71354375, 41.0522725, 0.0, 1.306222635)
|
||||
pt3dadd(22.98389625, 41.07147375, 0.0, 1.3963149)
|
||||
pt3dadd(22.0814375, 41.79344075, 0.0, 1.167512805)
|
||||
pt3dadd(21.207780625, 42.64597625, 0.0, 0.470722484)
|
||||
}
|
||||
primarydendrite[66] {pt3dclear()
|
||||
pt3dadd(21.207780625, 42.64597625, 0.0, 0.470722484)
|
||||
pt3dadd(19.498869375, 43.33722125, 0.0, 0.6135413815)
|
||||
}
|
||||
primarydendrite[67] {pt3dclear()
|
||||
pt3dadd(19.498869375, 43.33722125, 0.0, 0.6135413815)
|
||||
pt3dadd(18.3179925, 43.10680625, 0.0, 0.46083)
|
||||
}
|
||||
primarydendrite[68] {pt3dclear()
|
||||
pt3dadd(18.3179925, 43.10680625, 0.0, 0.46083)
|
||||
pt3dadd(17.45393625, 43.0108, 0.0, 0.325852893)
|
||||
pt3dadd(16.0138425, 42.3579575, 0.0, 0.4750158835)
|
||||
}
|
||||
primarydendrite[69] {pt3dclear()
|
||||
pt3dadd(16.0138425, 42.3579575, 0.0, 0.4750158835)
|
||||
pt3dadd(15.101783125, 42.9263145, 0.0, 0.489539709)
|
||||
pt3dadd(14.0169125, 43.83645375, 0.0, 0.462427544)
|
||||
pt3dadd(12.663224375, 44.70051, 0.0, 0.719724294)
|
||||
pt3dadd(11.443945, 45.5837675, 0.0, 0.577312463)
|
||||
pt3dadd(10.92551125, 45.499282, 0.0, 1.05606875)
|
||||
pt3dadd(10.42627875, 45.545365, 0.0, 0.3456225)
|
||||
}
|
||||
primarydendrite[70] {pt3dclear()
|
||||
pt3dadd(16.0138425, 42.3579575, 0.0, 0.4750158835)
|
||||
pt3dadd(15.6298175, 41.3134095, 0.0, 0.456406032)
|
||||
pt3dadd(15.1689875, 40.8218575, 0.0, 0.429355311)
|
||||
pt3dadd(15.274594375, 39.354882, 0.0, 0.365330663)
|
||||
}
|
||||
primarydendrite[71] {pt3dclear()
|
||||
pt3dadd(18.3179925, 43.10680625, 0.0, 0.46083)
|
||||
pt3dadd(17.97237, 43.59835825, 0.0, 0.81029275)
|
||||
pt3dadd(16.964304375, 44.3088045, 0.0, 0.442043497)
|
||||
pt3dadd(15.601015625, 45.56456625, 0.0, 0.4846165085)
|
||||
pt3dadd(14.468141875, 46.98545875, 0.0, 0.5170128575)
|
||||
pt3dadd(14.372135625, 47.9954445, 0.0, 0.438694799)
|
||||
}
|
||||
primarydendrite[72] {pt3dclear()
|
||||
pt3dadd(21.207780625, 42.64597625, 0.0, 0.470722484)
|
||||
pt3dadd(21.361390625, 43.48315075, 0.0, 0.63625262)
|
||||
pt3dadd(20.727749375, 44.28960325, 0.0, 0.3314673385)
|
||||
pt3dadd(20.209315625, 44.52769875, 0.0, 0.3708375815)
|
||||
pt3dadd(19.806089375, 44.316485, 0.0, 1.05253572)
|
||||
pt3dadd(19.83489125, 43.72124625, 0.0, 0.4378576245)
|
||||
}
|
||||
primarydendrite[73] {pt3dclear()
|
||||
pt3dadd(23.71354375, 41.0522725, 0.0, 1.306222635)
|
||||
pt3dadd(23.886355, 41.8971275, 0.0, 0.4241709735)
|
||||
pt3dadd(23.895955625, 44.116792, 0.0, 0.5216211575)
|
||||
pt3dadd(23.454326875, 44.623705, 0.0, 0.5839868175)
|
||||
pt3dadd(22.705478125, 44.6928295, 0.0, 0.518787053)
|
||||
}
|
||||
primarydendrite[74] {pt3dclear()
|
||||
pt3dadd(19.498869375, 43.33722125, 0.0, 0.6135413815)
|
||||
pt3dadd(18.385196875, 45.24966575, 0.0, 0.317834451)
|
||||
pt3dadd(17.9339675, 45.74889825, 0.0, 0.399554971)
|
||||
}
|
||||
primarydendrite[75] {pt3dclear()
|
||||
pt3dadd(17.9339675, 45.74889825, 0.0, 0.399554971)
|
||||
pt3dadd(18.173983125, 46.190527, 0.0, 0.4955228185)
|
||||
pt3dadd(18.922831875, 46.25581125, 0.0, 0.554178797)
|
||||
pt3dadd(19.729284375, 46.13292325, 0.0, 0.442043497)
|
||||
pt3dadd(20.132510625, 45.78730075, 0.0, 0.751060734)
|
||||
pt3dadd(20.353325, 45.74889825, 0.0, 0.32642125)
|
||||
}
|
||||
primarydendrite[76] {pt3dclear()
|
||||
pt3dadd(17.9339675, 45.74889825, 0.0, 0.399554971)
|
||||
pt3dadd(17.137115625, 46.37101875, 0.0, 0.48003125)
|
||||
pt3dadd(16.657084375, 46.927855, 0.0, 0.91781975)
|
||||
pt3dadd(15.9370375, 47.2734775, 0.0, 0.4378576245)
|
||||
}
|
||||
primarydendrite[77] {pt3dclear()
|
||||
pt3dadd(15.9370375, 47.2734775, 0.0, 0.4378576245)
|
||||
pt3dadd(15.03457875, 47.7650295, 0.0, 0.3149235415)
|
||||
pt3dadd(14.1705225, 48.44475375, 0.0, 0.384025)
|
||||
pt3dadd(13.51768, 48.82109825, 0.0, 0.51843375)
|
||||
pt3dadd(12.490413125, 49.28960875, 0.0, 0.384501191)
|
||||
pt3dadd(11.96237875, 49.13599875, 0.0, 0.820968645)
|
||||
pt3dadd(11.36714, 49.6851545, 0.0, 0.4644167935)
|
||||
pt3dadd(9.9462475, 50.17286625, 0.0, 0.2924657595)
|
||||
pt3dadd(8.707766875, 50.53769, 0.0, 0.2749234975)
|
||||
pt3dadd(7.5652925, 50.7604245, 0.0, 1.17695982)
|
||||
pt3dadd(6.691635625, 50.89483325, 0.0, 0.5598086035)
|
||||
}
|
||||
primarydendrite[78] {pt3dclear()
|
||||
pt3dadd(15.9370375, 47.2734775, 0.0, 0.4378576245)
|
||||
pt3dadd(16.0906475, 48.0722495, 0.0, 0.307819079)
|
||||
pt3dadd(15.581814375, 48.63676625, 0.0, 0.321874394)
|
||||
pt3dadd(15.389801875, 49.74275825, 0.0, 0.5072893445)
|
||||
pt3dadd(15.101783125, 50.12678325, 0.0, 0.918818215)
|
||||
pt3dadd(14.76576125, 50.51848875, 0.0, 0.378218542)
|
||||
pt3dadd(14.516145, 51.09452625, 0.0, 0.77757382)
|
||||
pt3dadd(14.160921875, 51.6513625, 0.0, 0.3607607655)
|
||||
pt3dadd(13.757695625, 52.6037445, 0.0, 0.82765068)
|
||||
pt3dadd(13.872903125, 53.5714875, 0.0, 0.3728191505)
|
||||
pt3dadd(13.53688125, 54.27425325, 0.0, 0.3125733085)
|
||||
pt3dadd(13.047249375, 55.81803375, 0.0, 0.3688406515)
|
||||
}
|
||||
primarydendrite[79] {pt3dclear()
|
||||
pt3dadd(23.71354375, 41.0522725, 0.0, 1.306222635)
|
||||
pt3dadd(23.1567075, 40.26502125, 0.0, 0.4640174075)
|
||||
pt3dadd(23.02229875, 39.585297, 0.0, 0.3005456455)
|
||||
pt3dadd(21.841421875, 38.2872925, 0.0, 0.319570244)
|
||||
pt3dadd(21.37099125, 37.07761375, 0.0, 0.625146617)
|
||||
pt3dadd(21.0829725, 36.760793125, 0.0, 0.841552385)
|
||||
pt3dadd(20.766151875, 36.511176875, 0.0, 0.455192513)
|
||||
pt3dadd(20.2381175, 35.992743125, 0.0, 0.399554971)
|
||||
pt3dadd(20.48773375, 37.15441875, 0.0, 0.4687639565)
|
||||
pt3dadd(20.44933125, 38.354496875, 0.0, 0.4211141345)
|
||||
pt3dadd(20.247718125, 39.3625625, 0.0, 0.635960761)
|
||||
pt3dadd(20.074906875, 39.95780125, 0.0, 0.96175221)
|
||||
pt3dadd(19.738885, 41.0829945, 0.0, 0.87004704)
|
||||
pt3dadd(19.710083125, 41.41709625, 0.0, 0.4675811595)
|
||||
}
|
||||
primarydendrite[80] {pt3dclear()
|
||||
pt3dadd(24.8464175, 37.394434375, 0.0, 0.4675811595)
|
||||
pt3dadd(24.529596875, 37.567245625, 0.0, 0.5437717195)
|
||||
pt3dadd(24.395188125, 37.96087125, 0.0, 0.845085415)
|
||||
pt3dadd(24.414389375, 38.335295625, 0.0, 0.5216211575)
|
||||
}
|
||||
primarydendrite[81] {pt3dclear()
|
||||
pt3dadd(24.8464175, 37.394434375, 0.0, 0.4675811595)
|
||||
pt3dadd(24.90402125, 36.549579375, 0.0, 0.6989331805)
|
||||
pt3dadd(24.500795, 35.96394125, 0.0, 0.876575465)
|
||||
pt3dadd(24.02076375, 35.147888125, 0.0, 0.5434337775)
|
||||
pt3dadd(23.473528125, 34.46624375, 0.0, 0.5501772565)
|
||||
pt3dadd(22.897490625, 33.5253825, 0.0, 0.98602259)
|
||||
pt3dadd(23.13750625, 32.2581, 0.0, 0.998465)
|
||||
pt3dadd(22.2350475, 31.35564125, 0.0, 0.6517134665)
|
||||
pt3dadd(21.5054, 30.0691575, 0.0, 0.512350794)
|
||||
pt3dadd(21.35179, 28.59066125, 0.0, 0.4224275)
|
||||
pt3dadd(21.169378125, 26.372916875, 0.0, 0.787481665)
|
||||
pt3dadd(21.073371875, 25.182439375, 0.0, 0.365330663)
|
||||
pt3dadd(21.169378125, 23.550333125, 0.0, 0.442043497)
|
||||
}
|
||||
primarydendrite[82] {pt3dclear()
|
||||
pt3dadd(21.169378125, 23.550333125, 0.0, 0.442043497)
|
||||
pt3dadd(21.111774375, 22.033434375, 0.0, 0.4036793995)
|
||||
pt3dadd(21.0061675, 20.60294125, 0.0, 0.3166746955)
|
||||
pt3dadd(20.036504375, 18.817225, 0.0, 0.3461524545)
|
||||
pt3dadd(19.60447625, 17.425134375, 0.0, 1.241552825)
|
||||
pt3dadd(17.905165625, 16.8586975, 0.0, 1.007451185)
|
||||
pt3dadd(16.119449375, 17.26192375, 0.0, 0.95330366)
|
||||
pt3dadd(15.898635, 17.99157125, 0.0, 0.4992325)
|
||||
pt3dadd(15.898635, 19.825290625, 0.0, 0.456406032)
|
||||
pt3dadd(17.002706875, 21.246183125, 0.0, 0.598019091)
|
||||
pt3dadd(17.91476625, 22.455861875, 0.0, 0.6654308395)
|
||||
pt3dadd(19.767686875, 22.878289375, 0.0, 0.602934611)
|
||||
}
|
||||
primarydendrite[83] {pt3dclear()
|
||||
pt3dadd(21.169378125, 23.550333125, 0.0, 0.442043497)
|
||||
pt3dadd(20.64134375, 23.67514125, 0.0, 0.516651874)
|
||||
pt3dadd(20.33412375, 23.09910375, 0.0, 0.5760375)
|
||||
pt3dadd(20.58374, 22.398258125, 0.0, 0.5338485135)
|
||||
}
|
||||
primarydendrite[84] {pt3dclear()
|
||||
pt3dadd(21.169378125, 23.550333125, 0.0, 0.442043497)
|
||||
pt3dadd(21.60140625, 23.0030975, 0.0, 0.570891565)
|
||||
pt3dadd(22.263849375, 22.86868875, 0.0, 0.7299009565)
|
||||
}
|
||||
primarydendrite[85] {pt3dclear()
|
||||
pt3dadd(22.263849375, 22.86868875, 0.0, 0.7299009565)
|
||||
pt3dadd(22.974295625, 22.043035, 0.0, 0.5310835335)
|
||||
}
|
||||
primarydendrite[86] {pt3dclear()
|
||||
pt3dadd(22.974295625, 22.043035, 0.0, 0.5310835335)
|
||||
pt3dadd(24.0015625, 20.670145625, 0.0, 0.386421316)
|
||||
pt3dadd(24.241578125, 19.134045625, 0.0, 0.2937253615)
|
||||
pt3dadd(24.433590625, 17.9339675, 0.0, 0.290568676)
|
||||
pt3dadd(24.98082625, 16.983505625, 0.0, 0.456406032)
|
||||
pt3dadd(25.278445625, 16.196254375, 0.0, 1.118664825)
|
||||
pt3dadd(25.604866875, 15.409003125, 0.0, 0.7530192615)
|
||||
pt3dadd(26.44012125, 13.488878125, 0.0, 0.5338485135)
|
||||
pt3dadd(26.756941875, 12.80723375, 0.0, 1.157988985)
|
||||
pt3dadd(26.929753125, 12.03918375, 0.0, 0.4466133945)
|
||||
pt3dadd(27.86101375, 9.437414375, 0.0, 0.5927579485)
|
||||
pt3dadd(28.446651875, 8.92858125, 0.0, 1.24454822)
|
||||
pt3dadd(28.93628375, 8.054924375, 0.0, 0.6497318975)
|
||||
pt3dadd(29.310708125, 6.7204375, 0.0, 0.638280272)
|
||||
pt3dadd(30.385978125, 5.28034375, 0.0, 0.4769513695)
|
||||
pt3dadd(31.250034375, 4.5698975, 0.0, 1.26451752)
|
||||
}
|
||||
primarydendrite[87] {pt3dclear()
|
||||
pt3dadd(31.250034375, 4.5698975, 0.0, 1.26451752)
|
||||
pt3dadd(32.363706875, 4.329881875, 0.0, 0.489539709)
|
||||
pt3dadd(33.630989375, 3.888253125, 0.0, 0.5754000185)
|
||||
pt3dadd(35.474309375, 2.160140625, 0.0, 0.5804998705)
|
||||
pt3dadd(36.328765, 1.814518125, 0.0, 0.3353383105)
|
||||
}
|
||||
primarydendrite[88] {pt3dclear()
|
||||
pt3dadd(31.250034375, 4.5698975, 0.0, 1.26451752)
|
||||
pt3dadd(31.12522625, 3.6482375, 0.0, 0.4224275)
|
||||
pt3dadd(31.259635, 3.0337975, 0.0, 0.5760375)
|
||||
}
|
||||
primarydendrite[89] {pt3dclear()
|
||||
pt3dadd(31.259635, 3.0337975, 0.0, 0.5760375)
|
||||
pt3dadd(31.49005, 2.236945625, 0.0, 0.768280415)
|
||||
pt3dadd(31.614858125, -0.067204375, 0.0, 0.7230499505)
|
||||
}
|
||||
primarydendrite[90] {pt3dclear()
|
||||
pt3dadd(31.259635, 3.0337975, 0.0, 0.5760375)
|
||||
pt3dadd(32.16209375, 2.947391875, 0.0, 0.3286716365)
|
||||
pt3dadd(33.227763125, 2.4193575, 0.0, 0.528295512)
|
||||
pt3dadd(34.226228125, 2.09293625, 0.0, 0.4906687425)
|
||||
pt3dadd(35.704724375, 1.008065625, 0.0, 0.5437717195)
|
||||
}
|
||||
primarydendrite[91] {pt3dclear()
|
||||
pt3dadd(22.263849375, 22.86868875, 0.0, 0.7299009565)
|
||||
pt3dadd(22.33105375, 23.425525, 0.0, 0.384025)
|
||||
pt3dadd(22.3118525, 24.087968125, 0.0, 0.352488867)
|
||||
pt3dadd(21.96623, 24.63520375, 0.0, 0.462427544)
|
||||
}
|
||||
primarydendrite[92] {pt3dclear()
|
||||
pt3dadd(22.974295625, 22.043035, 0.0, 0.5310835335)
|
||||
pt3dadd(23.435125625, 22.475063125, 0.0, 0.81505466)
|
||||
pt3dadd(24.241578125, 22.17744375, 0.0, 0.712519985)
|
||||
pt3dadd(24.808015, 22.014233125, 0.0, 0.7145860395)
|
||||
pt3dadd(25.44165625, 21.553403125, 0.0, 1.29447147)
|
||||
pt3dadd(25.78727875, 21.14057625, 0.0, 0.5223277635)
|
||||
pt3dadd(27.006558125, 20.190114375, 0.0, 0.4036793995)
|
||||
pt3dadd(27.448186875, 19.498869375, 0.0, 0.461628772)
|
||||
}
|
||||
primarydendrite[93] {pt3dclear()
|
||||
pt3dadd(27.448186875, 19.498869375, 0.0, 0.461628772)
|
||||
pt3dadd(27.659400625, 18.9324325, 0.0, 0.298080205)
|
||||
pt3dadd(28.648265, 17.386731875, 0.0, 0.406866807)
|
||||
pt3dadd(29.1474975, 16.580279375, 0.0, 0.4332032415)
|
||||
pt3dadd(29.445116875, 14.76576125, 0.0, 0.36482375)
|
||||
pt3dadd(29.790739375, 13.49847875, 0.0, 0.558157296)
|
||||
}
|
||||
primarydendrite[94] {pt3dclear()
|
||||
pt3dadd(27.448186875, 19.498869375, 0.0, 0.461628772)
|
||||
pt3dadd(28.09142875, 19.498869375, 0.0, 0.48156735)
|
||||
pt3dadd(28.792274375, 18.942033125, 0.0, 0.4036793995)
|
||||
pt3dadd(29.33951, 18.500404375, 0.0, 0.224746791)
|
||||
pt3dadd(29.74273625, 18.3179925, 0.0, 0.2999312055)
|
||||
}
|
||||
}
|
||||
proc shape3d_4() {
|
||||
primarydendrite[94] {pt3dclear()
|
||||
pt3dadd(31.077223125, 17.3963325, 0.0, 0.4753999085)
|
||||
}
|
||||
primarydendrite[95] {pt3dclear()
|
||||
pt3dadd(21.21738125, 34.552649375, 0.0, 1.3794178)
|
||||
pt3dadd(21.0061675, 33.6789925, 0.0, 1.38464054)
|
||||
pt3dadd(21.04457, 32.50771625, 0.0, 0.5430958355)
|
||||
pt3dadd(21.207780625, 31.326839375, 0.0, 0.34024615)
|
||||
pt3dadd(20.727749375, 30.70279875, 0.0, 0.85975517)
|
||||
pt3dadd(20.506935, 29.675531875, 0.0, 0.5170128575)
|
||||
pt3dadd(20.420529375, 28.715469375, 0.0, 0.256175397)
|
||||
pt3dadd(19.81569, 27.851413125, 0.0, 0.921890415)
|
||||
pt3dadd(19.364460625, 27.24657375, 0.0, 0.393978928)
|
||||
pt3dadd(18.961234375, 26.958555, 0.0, 0.352488867)
|
||||
pt3dadd(18.1643825, 26.651335, 0.0, 0.81013914)
|
||||
pt3dadd(17.72275375, 27.20817125, 0.0, 0.500707156)
|
||||
pt3dadd(17.14671625, 27.544193125, 0.0, 0.4122661985)
|
||||
}
|
||||
primarydendrite[96] {pt3dclear()
|
||||
pt3dadd(17.14671625, 27.544193125, 0.0, 0.4122661985)
|
||||
pt3dadd(16.513075, 27.9186175, 0.0, 0.447849955)
|
||||
pt3dadd(15.946638125, 28.235438125, 0.0, 0.480415275)
|
||||
pt3dadd(13.88250375, 28.16823375, 0.0, 0.625146617)
|
||||
}
|
||||
primarydendrite[97] {pt3dclear()
|
||||
pt3dadd(17.14671625, 27.544193125, 0.0, 0.4122661985)
|
||||
pt3dadd(16.868298125, 27.18897, 0.0, 0.4122661985)
|
||||
pt3dadd(16.68588625, 26.814545625, 0.0, 0.7145860395)
|
||||
pt3dadd(16.465071875, 26.47852375, 0.0, 0.366836041)
|
||||
}
|
||||
primarydendrite[98] {pt3dclear()
|
||||
pt3dadd(36.09835, 45.8909875, 0.0, 0.7081036975)
|
||||
pt3dadd(36.482375, 45.41095625, 0.0, 0.3461524545)
|
||||
pt3dadd(36.876000625, 45.1536595, 0.0, 0.353011141)
|
||||
pt3dadd(37.413635625, 44.8003565, 0.0, 0.985484955)
|
||||
pt3dadd(37.620241075, 44.63522575, 0.0, 0.631383183)
|
||||
pt3dadd(37.92246875, 44.14367375, 0.0, 0.5457993715)
|
||||
pt3dadd(38.463944, 43.6021985, 0.0, 0.3490710445)
|
||||
}
|
||||
primarydendrite[99] {pt3dclear()
|
||||
pt3dadd(41.21740325, 48.9017435, 0.0, 0.6418056215)
|
||||
pt3dadd(41.54766475, 48.3794695, 0.0, 0.373441271)
|
||||
pt3dadd(42.227389, 47.8418345, 0.0, 0.340922034)
|
||||
pt3dadd(42.8802315, 47.53845475, 0.0, 0.4261218205)
|
||||
pt3dadd(43.2642565, 47.3041995, 0.0, 0.607573633)
|
||||
pt3dadd(43.963182, 46.989299, 0.0, 0.586897727)
|
||||
pt3dadd(44.32032525, 46.90865375, 0.0, 0.4060757155)
|
||||
pt3dadd(44.78115525, 46.9048135, 0.0, 0.3918667905)
|
||||
pt3dadd(44.946286, 47.5653365, 0.0, 0.3405149675)
|
||||
pt3dadd(45.21894375, 47.79191125, 0.0, 0.499601164)
|
||||
pt3dadd(45.54920525, 47.6191, 0.0, 0.468863803)
|
||||
pt3dadd(45.8295435, 47.3041995, 0.0, 0.3629266665)
|
||||
pt3dadd(46.1214025, 46.943216, 0.0, 0.48433233)
|
||||
pt3dadd(46.7972865, 46.3825395, 0.0, 0.458925236)
|
||||
pt3dadd(47.4885315, 46.05611825, 0.0, 0.518525916)
|
||||
pt3dadd(48.294984, 45.4147965, 0.0, 0.4488714615)
|
||||
pt3dadd(48.709731, 44.82723825, 0.0, 0.3870127145)
|
||||
pt3dadd(49.2704075, 43.42938725, 0.0, 0.452857641)
|
||||
pt3dadd(50.000055, 42.503887, 0.0, 0.6517134665)
|
||||
pt3dadd(50.952437, 41.62446975, 0.0, 0.3462907035)
|
||||
pt3dadd(51.720487, 39.17055, 0.0, 0.4466133945)
|
||||
pt3dadd(52.97624875, 37.048811875, 0.0, 0.6654308395)
|
||||
pt3dadd(54.6467575, 35.647120625, 0.0, 0.85806546)
|
||||
pt3dadd(56.605285, 33.074153125, 0.0, 0.97096881)
|
||||
pt3dadd(57.12371875, 32.16209375, 0.0, 0.876575465)
|
||||
pt3dadd(57.96857375, 31.4516475, 0.0, 0.7143249025)
|
||||
pt3dadd(58.479327, 30.16055545, 0.0, 0.4540788405)
|
||||
pt3dadd(58.75198475, 29.464318125, 0.0, 1.239248675)
|
||||
pt3dadd(59.02080225, 28.77806545, 0.0, 0.7408072665)
|
||||
}
|
||||
}
|
||||
proc basic_shape() {
|
||||
shape3d_1()
|
||||
shape3d_2()
|
||||
shape3d_3()
|
||||
shape3d_4()
|
||||
}
|
||||
access soma
|
||||
|
||||
celldef()
|
||||
1
examples/__init__.py
Normal file
1
examples/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# empty init to make examples importable (for sphinx)
|
||||
64
examples/figures.py
Normal file
64
examples/figures.py
Normal file
@@ -0,0 +1,64 @@
|
||||
from __future__ import print_function
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
if len(sys.argv) < 2: # if no argument, print helpful message
|
||||
print(
|
||||
"Plot selected figures from paper, Manis and Campagnola, Hearing Research. 2018"
|
||||
)
|
||||
print("Usage: figures.py [2a | 2b | 2c | 3 | 4 | 5 | 6a | 6d | 7]")
|
||||
exit(1)
|
||||
|
||||
arg = sys.argv[1] # get argument, check that it is valid
|
||||
if arg not in ["2a", "2b", "2c", "3", "4", "5", "6a", "6d", "7"]:
|
||||
print("Usage: figures.py [2a | 2b | 2c | 3 | 4 | 5 | 6a | 6d | 7]")
|
||||
exit(1)
|
||||
|
||||
if arg == "2a":
|
||||
proc = subprocess.Popen(
|
||||
["python", "examples/test_mechanisms.py", "klt"],
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
proc.wait()
|
||||
print(proc.stdout.read())
|
||||
# ;;
|
||||
# 2b)
|
||||
# python examples/test_mechanisms.py kht
|
||||
# ;;
|
||||
# 2c)
|
||||
# python examples/test_mechanisms.py ka
|
||||
# ;;
|
||||
# 3)
|
||||
# python examples/toy_model.py
|
||||
# ;;
|
||||
# 4)
|
||||
# python examples/test_synapses.py sgc bushy
|
||||
# ;;
|
||||
# 5)
|
||||
# python examples/test_decorator.py
|
||||
# ;;
|
||||
# 6a)
|
||||
# python examples/test_bushy_variation.py a
|
||||
# ;;
|
||||
# 6d)
|
||||
# python examples/test_bushy_variation.py d
|
||||
# ;;
|
||||
#
|
||||
# 7)
|
||||
# while true; do
|
||||
# echo "This figure may take hours to generate!"
|
||||
# read -p "Are you sure you want to run the script?" yn
|
||||
# case $yn in
|
||||
# [Yy]* ) python examples/test_physiology.py; break;;
|
||||
# [Nn]* ) exit;;
|
||||
# * ) echo "Please answer yes or no.";;
|
||||
# esac
|
||||
# done
|
||||
# ;;
|
||||
#
|
||||
44
examples/figures.sh
Executable file
44
examples/figures.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
case $1 in
|
||||
2a)
|
||||
python examples/test_mechanisms.py klt
|
||||
;;
|
||||
2b)
|
||||
python examples/test_mechanisms.py kht
|
||||
;;
|
||||
2c)
|
||||
python examples/test_mechanisms.py ka
|
||||
;;
|
||||
3)
|
||||
python examples/toy_model.py
|
||||
;;
|
||||
4)
|
||||
python examples/test_synapses.py sgc bushy
|
||||
;;
|
||||
5)
|
||||
python examples/test_decorator.py
|
||||
;;
|
||||
6a)
|
||||
python examples/test_bushy_variation.py a
|
||||
;;
|
||||
6d)
|
||||
python examples/test_bushy_variation.py d
|
||||
;;
|
||||
|
||||
7)
|
||||
while true; do
|
||||
echo "This figure may take hours to generate!"
|
||||
read -p "Are you sure you want to run the script?" yn
|
||||
case $yn in
|
||||
[Yy]* ) python examples/test_physiology.py; break;;
|
||||
[Nn]* ) exit;;
|
||||
* ) echo "Please answer yes or no.";;
|
||||
esac
|
||||
done
|
||||
;;
|
||||
|
||||
*)
|
||||
echo $"Plot selected figures from paper"
|
||||
echo $"Usage: $0 {2a | 2b | 2c | 3 | 4 | 5 | 6a | 6d | 7}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
1
examples/gif
Executable file
1
examples/gif
Executable file
@@ -0,0 +1 @@
|
||||
/Users/pbmanis/Desktop/Python/GIFFittingToolbox/src
|
||||
146
examples/play_test_sounds.py
Normal file
146
examples/play_test_sounds.py
Normal file
@@ -0,0 +1,146 @@
|
||||
"""
|
||||
Test sounds and plot waveforms.
|
||||
|
||||
This script tests the sound waveform generator for a variety of sounds
|
||||
|
||||
"""
|
||||
import numpy as np
|
||||
import pyqtgraph as pg
|
||||
from cnmodel.util import sound
|
||||
from collections import OrderedDict
|
||||
import scipy.signal
|
||||
import sys
|
||||
|
||||
try:
|
||||
import PySounds
|
||||
|
||||
HAVE_PYSOUNDS = True
|
||||
except ImportError:
|
||||
HAVE_PYSOUNDS = False
|
||||
|
||||
|
||||
def play():
|
||||
if len(sys.argv) >= 2:
|
||||
stimarg = sys.argv[1]
|
||||
else:
|
||||
exit()
|
||||
|
||||
plots = True
|
||||
|
||||
if HAVE_PYSOUNDS:
|
||||
PS = PySounds.PySounds()
|
||||
|
||||
cf = 2e3
|
||||
Fs = 44100 # sample frequency
|
||||
level = 80.0
|
||||
seed = 34978
|
||||
fmod = 20.0
|
||||
dmod = 20.0
|
||||
|
||||
if plots:
|
||||
# waveforms
|
||||
win = pg.GraphicsWindow()
|
||||
pipwin = win.addPlot(title="sound pip", row=0, col=0)
|
||||
pipmodwin = win.addPlot(title="100 \% SAM modulated pip", row=1, col=0)
|
||||
noisewin = win.addPlot(title="WB noise", row=2, col=0)
|
||||
noisemodwin = win.addPlot(title="100 \% SAM Modulated WB Noise", row=3, col=0)
|
||||
clickwin = win.addPlot(title="clicks", row=4, col=0)
|
||||
fmwin = win.addPlot(title="fmsweep", row=5, col=0)
|
||||
# spectra
|
||||
pipwins = win.addPlot(title="sound pip Spec", row=0, col=1)
|
||||
pipmodwins = win.addPlot(title="100 \% SAM modulated pip", row=1, col=1)
|
||||
noisewins = win.addPlot(title="WB noise", row=2, col=1)
|
||||
noisemodwins = win.addPlot(title="100 \% SAM Modulated WB Noise", row=3, col=1)
|
||||
clickwins = win.addPlot(title="click spec", row=4, col=1)
|
||||
fmwins = win.addPlot(title="fmsweep spec", row=5, col=1)
|
||||
else:
|
||||
pipwin = None
|
||||
pipmodwin = None
|
||||
noisewin = None
|
||||
noisemodwin = None
|
||||
clickwin = None
|
||||
pipwins = None
|
||||
pipmodwins = None
|
||||
noisewins = None
|
||||
noisemodwins = None
|
||||
clickwins = None
|
||||
fmwins = None
|
||||
|
||||
stims = OrderedDict(
|
||||
[
|
||||
("pip", (pipwin, sound.TonePip)),
|
||||
("pipmod", (pipmodwin, sound.SAMTone)),
|
||||
("noise", (noisewin, sound.NoisePip)),
|
||||
("noisemod", (noisemodwin, sound.SAMNoise)),
|
||||
("clicks", (clickwin, sound.ClickTrain)),
|
||||
("fmsweep", (fmwins, sound.FMSweep)),
|
||||
]
|
||||
)
|
||||
|
||||
specs = OrderedDict(
|
||||
[
|
||||
("pip", (pipwins, sound.TonePip)),
|
||||
("pipmod", (pipmodwins, sound.SAMTone)),
|
||||
("noise", (noisewins, sound.NoisePip)),
|
||||
("noisemod", (noisemodwins, sound.SAMNoise)),
|
||||
("clicks", (clickwins, sound.ClickTrain)),
|
||||
("fmsweep", (fmwins, sound.FMSweep)),
|
||||
]
|
||||
)
|
||||
if stimarg == "all":
|
||||
stimlist = list(stims.keys())
|
||||
else:
|
||||
stimlist = [stimarg]
|
||||
for stim in stimlist:
|
||||
print(stim)
|
||||
if stim in ["clicks"]:
|
||||
wave = stims[stim][1](
|
||||
rate=Fs,
|
||||
duration=1.0,
|
||||
dbspl=level,
|
||||
click_duration=1e-4,
|
||||
click_starts=1e-3 * np.linspace(10, 500, 10),
|
||||
)
|
||||
elif stim in ["fmsweep"]:
|
||||
wave = stims[stim][1](
|
||||
rate=Fs,
|
||||
duration=0.5,
|
||||
dbspl=level,
|
||||
start=0.0,
|
||||
ramp="linear",
|
||||
freqs=[16000, 200],
|
||||
)
|
||||
elif stim in ["pip", "pipmod", "noise", "noisemod"]:
|
||||
wave = stims[stim][1](
|
||||
rate=Fs,
|
||||
duration=2.0,
|
||||
f0=cf,
|
||||
dbspl=level,
|
||||
pip_duration=1.8,
|
||||
pip_start=[10e-3],
|
||||
ramp_duration=2.5e-3,
|
||||
fmod=fmod,
|
||||
dmod=dmod,
|
||||
seed=seed,
|
||||
)
|
||||
if plots:
|
||||
stims[stim][0].plot(wave.time, wave.sound)
|
||||
f, Pxx_spec = scipy.signal.periodogram(
|
||||
wave.sound, Fs
|
||||
) # , window='flattop', nperseg=8192,
|
||||
# noverlap=512, scaling='spectrum')
|
||||
specs[stim][0].plot(f, np.sqrt(Pxx_spec))
|
||||
if HAVE_PYSOUNDS:
|
||||
|
||||
print("Playing %s" % stim)
|
||||
|
||||
PS.playSound(wave.sound, wave.sound, Fs)
|
||||
|
||||
if plots and sys.flags.interactive == 0:
|
||||
pg.QtGui.QApplication.exec_()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if not HAVE_PYSOUNDS:
|
||||
print("Could not import PySounds; will not play audio.")
|
||||
play()
|
||||
81
examples/plot_hcno_kinetics.py
Executable file
81
examples/plot_hcno_kinetics.py
Executable file
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/python
|
||||
"""
|
||||
test and plot hcno stuff
|
||||
|
||||
"""
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# Parameters#
|
||||
gbar = 0.0005 # (mho/cm2)
|
||||
|
||||
vhalf1 = -50 # (mV) # v 1/2 for forward
|
||||
vhalf2 = -84 # (mV) # v 1/2 for backward
|
||||
gm1 = 0.3 ## (mV) # slope for forward
|
||||
gm2 = 0.6 # # (mV) # slope for backward
|
||||
zeta1 = 3 # (/ms)
|
||||
# zeta2 = 3 # (/ms)
|
||||
a01 = 0.008 # (/ms)
|
||||
a02 = 0.0029 # (/ms)
|
||||
frac = 0.0
|
||||
c0 = 273.16 # (degC)
|
||||
thinf = -66 # (mV) # inact inf slope
|
||||
qinf = 7 # (mV) # inact inf slope
|
||||
q10tau = 4.5 # from Magee (1998)
|
||||
# v # (mV)
|
||||
q10g = 4.5 # Cao and Oertel
|
||||
celsius = 35.0
|
||||
|
||||
F = 9.648e4
|
||||
R = 8.314
|
||||
|
||||
ct = 1e-3 * zeta1 * F / (R * (c0 + celsius))
|
||||
|
||||
q10 = q10tau ** (
|
||||
(celsius - 33.0) / 10.0
|
||||
) # (degC)) : if you don't like room temp, it can be changed!
|
||||
|
||||
|
||||
def rates(v): # (mV)) {
|
||||
tau1 = bet1(v) / (q10 * a01 * (1.0 + alp1(v)))
|
||||
tau2 = bet2(v) / (q10 * a02 * (1.0 + alp2(v)))
|
||||
hinf = 1.0 / (1.0 + np.exp((v - thinf) / qinf))
|
||||
return tau1, tau2, hinf
|
||||
|
||||
|
||||
def alp1(v): # (mV)) {
|
||||
alp1 = np.exp((v - vhalf1) * ct)
|
||||
return alp1
|
||||
|
||||
|
||||
def bet1(v): # (mV)) {
|
||||
bet1 = np.exp(gm1 * (v - vhalf1) * ct)
|
||||
return bet1
|
||||
|
||||
|
||||
def alp2(v): # (mV)) {
|
||||
alp2 = np.exp((v - vhalf2) * ct)
|
||||
return alp2
|
||||
|
||||
|
||||
def bet2(v): # (mV)) {
|
||||
bet2 = np.exp(gm2 * (v - vhalf2) * ct)
|
||||
return bet2
|
||||
|
||||
|
||||
def plots():
|
||||
v = np.linspace(-120.0, 0.0, 120)
|
||||
|
||||
t1, t2, hi = rates(v)
|
||||
# print(v)
|
||||
plt.figure(1)
|
||||
plt.plot(v, t1)
|
||||
plt.plot(v, t2)
|
||||
plt.figure(2)
|
||||
plt.plot(v, hi)
|
||||
plt.show()
|
||||
|
||||
|
||||
# prevent sphinx from running this script at first build
|
||||
if __name__ == "__main__":
|
||||
plots()
|
||||
BIN
examples/stim172_geese.wav
Executable file
BIN
examples/stim172_geese.wav
Executable file
Binary file not shown.
340
examples/test_adex.py
Executable file
340
examples/test_adex.py
Executable file
@@ -0,0 +1,340 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
|
||||
"""
|
||||
Test adex model
|
||||
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
from neuron import h
|
||||
import neuron
|
||||
import matplotlib.pyplot as plt
|
||||
from collections import OrderedDict
|
||||
import weave
|
||||
from .gif.Filter_Rect_LogSpaced import *
|
||||
|
||||
|
||||
class AdEx:
|
||||
def __init__(self):
|
||||
pass
|
||||
self.dt = 0.025
|
||||
self.tstop = 250.0
|
||||
self.eta = (
|
||||
Filter_Rect_LogSpaced()
|
||||
) # nA, spike-triggered current (must be instance of class Filter)
|
||||
self.gamma = (
|
||||
Filter_Rect_LogSpaced()
|
||||
) # mV, spike-triggered movement of the firing threshold (must be instance of class Filter)
|
||||
|
||||
def runone(self, pars, dt=0.025, tstop=250):
|
||||
|
||||
self.cell = self.create_Adex_model(pars)
|
||||
self.dt = 0.025
|
||||
self.tstop = tstop
|
||||
|
||||
# for inj in np.linspace(pars['I']*0.5, pars['I']*2.0, 3):
|
||||
inj = pars["I"]
|
||||
stim = h.Vector()
|
||||
self.Vm = h.Vector()
|
||||
self.Vm.record(self.cell(0.5)._ref_Vm_AdEx, sec=self.cell)
|
||||
istim = h.iStim(0.5, sec=self.cell)
|
||||
istim.delay = 5.0
|
||||
istim.dur = 1e9 # these actually do not matter...
|
||||
istim.iMax = 0.0
|
||||
stim = np.zeros(int(tstop / h.dt))
|
||||
stim[int(20 / h.dt) : int(220 / h.dt)] = inj
|
||||
cmd = h.Vector(stim)
|
||||
# cmd.play(istim._ref_i, h.dt, 0, sec=cell)
|
||||
cmd.play(self.cell(0.5)._ref_is_AdEx, h.dt, 0, sec=self.cell)
|
||||
|
||||
rtime = h.Vector()
|
||||
rtime.record(h._ref_t)
|
||||
h.finitialize()
|
||||
h.t = 0.0
|
||||
h.dt = self.dt
|
||||
while h.t < self.tstop:
|
||||
h.fadvance()
|
||||
|
||||
tb = np.array(rtime)
|
||||
vcell = self.Vm.to_python()
|
||||
|
||||
return (tb, vcell)
|
||||
|
||||
def run_gifAI(self, pars, dt=0.025, tstep=250.0):
|
||||
# Model parameters
|
||||
self.simulate(pars["I"], -65.0, pars)
|
||||
|
||||
def plot_trace(self, i, panel, tb, vcell):
|
||||
axi = self.ax[i]
|
||||
axi.plot(tb, vcell)
|
||||
axi.set_ylim([-100, 10])
|
||||
axi.set_title(panel)
|
||||
|
||||
def create_Adex_model(self, pars):
|
||||
cell = h.Section()
|
||||
cell.L = 50
|
||||
|
||||
cell.insert("AdEx")
|
||||
|
||||
cell(0.5).cm_AdEx = pars["cm"]
|
||||
cell(0.5).gl_AdEx = pars["gl"]
|
||||
cell(0.5).el_AdEx = pars["el"]
|
||||
cell(0.5).vt_AdEx = pars["Vt"]
|
||||
cell(0.5).delt_AdEx = pars["dt"]
|
||||
cell(0.5).a_AdEx = pars["a"]
|
||||
cell(0.5).tauw_AdEx = pars["tauw"]
|
||||
cell(0.5).b_AdEx = pars["b"]
|
||||
cell(0.5).vr_AdEx = pars["Vr"]
|
||||
cell(0.5).refract_AdEx = 0.025
|
||||
return cell
|
||||
|
||||
def create_GIF_model(self, pars):
|
||||
cell = h.Section()
|
||||
cell.L = 50
|
||||
cell.insert("GIF")
|
||||
cell(0.5).cm_GIF = pars["cm"]
|
||||
cell(0.5).gl_GIF = pars["gl"]
|
||||
cell(0.5).el_GIF = pars["el"]
|
||||
cell(0.5).vt_GIF = pars["Vt_star"]
|
||||
cell(0.5).vr_GIF = pars["Vr"]
|
||||
cell(0.5).refract_GIF = pars["Tref"]
|
||||
cell(0.5).DV_GIF = pars["DV"]
|
||||
cell(0.5).lambda0_GIF = pars["lambda0"]
|
||||
cell(0.5).b_GIF = pars["b"]
|
||||
return cell
|
||||
|
||||
#
|
||||
# The following are from Gif.py...
|
||||
def simulate(self, I, V0, pars):
|
||||
|
||||
"""
|
||||
Simulate the spiking response of the GIF model to an input current I (nA) with time step dt.
|
||||
V0 indicate the initial condition V(0)=V0.
|
||||
The function returns:
|
||||
- time : ms, support for V, eta_sum, V_T, spks
|
||||
- V : mV, membrane potential
|
||||
- eta_sum : nA, adaptation current
|
||||
- V_T : mV, firing threshold
|
||||
- spks : ms, list of spike times
|
||||
"""
|
||||
|
||||
# Input parameters
|
||||
p_T = len(I)
|
||||
p_dt = self.dt
|
||||
|
||||
# Model parameters
|
||||
p_gl = pars["gl"]
|
||||
p_C = pars["cm"]
|
||||
p_El = pars["el"]
|
||||
p_Vr = pars["Vr"]
|
||||
p_Tref = pars["Tref"]
|
||||
p_Vt_star = pars["Vt_star"]
|
||||
p_DV = pars["DV"]
|
||||
p_lambda0 = pars["lambda0"]
|
||||
|
||||
# Model kernels
|
||||
(p_eta_support, p_eta) = self.eta.getInterpolatedFilter(self.dt)
|
||||
p_eta = p_eta.astype("double")
|
||||
p_eta_l = len(p_eta)
|
||||
|
||||
(p_gamma_support, p_gamma) = self.gamma.getInterpolatedFilter(self.dt)
|
||||
p_gamma = p_gamma.astype("double")
|
||||
p_gamma_l = len(p_gamma)
|
||||
|
||||
# Define arrays
|
||||
V = np.array(np.zeros(p_T), dtype="double")
|
||||
I = np.array(I, dtype="double")
|
||||
spks = np.array(np.zeros(p_T), dtype="double")
|
||||
eta_sum = np.array(np.zeros(p_T + 2 * p_eta_l), dtype="double")
|
||||
gamma_sum = np.array(np.zeros(p_T + 2 * p_gamma_l), dtype="double")
|
||||
|
||||
# Set initial condition
|
||||
V[0] = V0
|
||||
|
||||
code = """
|
||||
#include <math.h>
|
||||
|
||||
int T_ind = int(p_T);
|
||||
float dt = float(p_dt);
|
||||
|
||||
float gl = float(p_gl);
|
||||
float C = float(p_C);
|
||||
float El = float(p_El);
|
||||
float Vr = float(p_Vr);
|
||||
int Tref_ind = int(float(p_Tref)/dt);
|
||||
float Vt_star = float(p_Vt_star);
|
||||
float DeltaV = float(p_DV);
|
||||
float lambda0 = float(p_lambda0);
|
||||
|
||||
int eta_l = int(p_eta_l);
|
||||
int gamma_l = int(p_gamma_l);
|
||||
|
||||
|
||||
float rand_max = float(RAND_MAX);
|
||||
float p_dontspike = 0.0 ;
|
||||
float lambda = 0.0 ;
|
||||
float r = 0.0;
|
||||
|
||||
|
||||
for (int t=0; t<T_ind-1; t++) {
|
||||
|
||||
|
||||
// INTEGRATE VOLTAGE
|
||||
V[t+1] = V[t] + dt/C*( -gl*(V[t] - El) + I[t] - eta_sum[t] );
|
||||
|
||||
|
||||
// COMPUTE PROBABILITY OF EMITTING ACTION POTENTIAL
|
||||
lambda = lambda0*exp( (V[t+1]-Vt_star-gamma_sum[t])/DeltaV );
|
||||
p_dontspike = exp(-lambda*(dt/1000.0)); // since lambda0 is in Hz, dt must also be in 1/Hz (this is why dt/1000.0)
|
||||
|
||||
|
||||
// PRODUCE SPIKE STOCHASTICALLY
|
||||
r = rand()/rand_max;
|
||||
if (r > p_dontspike) {
|
||||
|
||||
if (t+1 < T_ind-1)
|
||||
spks[t+1] = 1.0;
|
||||
|
||||
t = t + Tref_ind;
|
||||
|
||||
if (t+1 < T_ind-1)
|
||||
V[t+1] = Vr;
|
||||
|
||||
|
||||
// UPDATE ADAPTATION PROCESSES
|
||||
for(int j=0; j<eta_l; j++)
|
||||
eta_sum[t+1+j] += p_eta[j];
|
||||
|
||||
for(int j=0; j<gamma_l; j++)
|
||||
gamma_sum[t+1+j] += p_gamma[j] ;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
vars = [
|
||||
"p_T",
|
||||
"p_dt",
|
||||
"p_gl",
|
||||
"p_C",
|
||||
"p_El",
|
||||
"p_Vr",
|
||||
"p_Tref",
|
||||
"p_Vt_star",
|
||||
"p_DV",
|
||||
"p_lambda0",
|
||||
"V",
|
||||
"I",
|
||||
"p_eta",
|
||||
"p_eta_l",
|
||||
"eta_sum",
|
||||
"p_gamma",
|
||||
"gamma_sum",
|
||||
"p_gamma_l",
|
||||
"spks",
|
||||
]
|
||||
|
||||
v = weave.inline(code, vars)
|
||||
|
||||
time = np.arange(p_T) * self.dt
|
||||
|
||||
eta_sum = eta_sum[:p_T]
|
||||
V_T = gamma_sum[:p_T] + p_Vt_star
|
||||
|
||||
spks = (np.where(spks == 1)[0]) * self.dt
|
||||
|
||||
return (time, V, eta_sum, V_T, spks)
|
||||
|
||||
# Type C (pF) gL (nS) EL (mV) VT (mV) dT (mV) a (nS) tauw (ms) b (pA) Vr (mV) I (pA)
|
||||
# Values in the I column are hand-picked to try to reproduce the traces shown in Naud et al.,
|
||||
# 2008. The values in Ims are the ones from the manuscript.
|
||||
|
||||
def fromfigure(self):
|
||||
|
||||
tab = r"""Ty cm gl el Vt dt a tauw b Vr I Ims
|
||||
4a 200 10 -70 -50 2 2 30 0 -58 300 500
|
||||
4b 200 12 -70 -50 2 2 300 60 -58 360 500
|
||||
4c 130 18 -58 -50 2 4 150 120 -50 250 400
|
||||
4d 200 10 -58 -50 2 2 120 100 -46 150 210
|
||||
4e 200 12 -70 -50 2 -10 300 0 -58 120 300
|
||||
4f 100 10 -65 -50 2 -10 90 30 -47 90 350
|
||||
4g 100 20 -70 -45 2 50 20 0 -64 900 110
|
||||
4h 100 12 -60 -50 2 -11 130 30 -48 120 160
|
||||
"""
|
||||
lx = tab.splitlines()
|
||||
keys = lx[0].split()
|
||||
d = OrderedDict()
|
||||
for i in range(1, len(lx)):
|
||||
dline = lx[i].split()
|
||||
print(dline)
|
||||
if len(dline) == 0:
|
||||
continue
|
||||
fk = dline[0]
|
||||
d[fk] = {}
|
||||
for j, k in enumerate(keys[1:]):
|
||||
d[fk][k] = float(dline[j + 1])
|
||||
|
||||
f, self.ax = plt.subplots(len(list(d.keys())) / 2, 2)
|
||||
self.ax = self.ax.ravel()
|
||||
for i, fig in enumerate(d.keys()):
|
||||
(tb, v) = self.runone(d[fig], self.ax[i])
|
||||
self.plot_trace(i, fig, tb, v)
|
||||
|
||||
# Type C (pF) gL (nS) EL (mV) VT (mV) dT (mV) a (nS) tauw (ms) b (pA) Vr (mV) I (pA)
|
||||
# Values in the I column are hand-picked to try to reproduce the traces shown in Naud et al.,
|
||||
# 2008. The values in Ims are the ones from the manuscript.
|
||||
# -------------------------
|
||||
# GIF model parameters:
|
||||
# -------------------------
|
||||
# tau_m (ms): 21.237
|
||||
# R (MOhm): 128.630
|
||||
# C (nF): 0.165
|
||||
# gl (nS): 0.007774
|
||||
# El (mV): -58.987
|
||||
# Tref (ms): 4.000
|
||||
# Vr (mV): -32.586
|
||||
# Vt* (mV): -45.367
|
||||
# DV (mV): 1.158
|
||||
# -------------------------
|
||||
#
|
||||
def showGIF(self):
|
||||
|
||||
f, self.ax = plt.subplots(1, 3)
|
||||
self.ax = self.ax.ravel()
|
||||
pars = {
|
||||
"gl": 7.77, # nS
|
||||
"cm": 165.0, # nF
|
||||
"el": -58.98, # mV
|
||||
"Vr": -70, # mV
|
||||
"Tref": 4.0, # ms
|
||||
"Vt_star": -45.3, # mV
|
||||
"DV": 1.158,
|
||||
"lambda0": 1.0,
|
||||
"Istim": 1000.0, # pA
|
||||
"dt": self.dt, # msec integration step
|
||||
}
|
||||
tstop = 250.0
|
||||
npts = int(self.tstop / self.dt)
|
||||
pars["I"] = np.zeros(npts)
|
||||
pars["I"][int(npts * 0.25) : int(0.75 * npts)] = pars["Istim"]
|
||||
(time, V, eta_sum, V_T, spks) = self.simulate(pars["I"], pars["el"], pars)
|
||||
self.plot_trace(0, "GIFAI", time, V)
|
||||
print(
|
||||
"Array lengths: time = {0:d}, etasum = {1:d}, V_T = {2:d}".format(
|
||||
len(time), len(eta_sum), len(V_T)
|
||||
)
|
||||
)
|
||||
self.ax[1].plot(time[: len(eta_sum)], eta_sum, "b")
|
||||
self.ax[2].plot(time[: len(V_T)], V_T, "c")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
M = AdEx()
|
||||
# M.fromfigure()
|
||||
|
||||
M.showGIF()
|
||||
|
||||
plt.show()
|
||||
102
examples/test_an_model.py
Normal file
102
examples/test_an_model.py
Normal file
@@ -0,0 +1,102 @@
|
||||
"""
|
||||
Test the embedded auditory nerve model with a set of tone pips.
|
||||
(Zilany et al. 2014; requires MATLAB)
|
||||
|
||||
This demonstrates the lowest-level access to the auditory nerve model that is
|
||||
available in the cnmodel API. For higher-level tools, see test_sound_stim.py
|
||||
(which uses an_model.get_spiketrain) and test_sgc_input.py (which uses
|
||||
cells.DummySGC).
|
||||
|
||||
Usage:
|
||||
python test_an_model.py
|
||||
(no arguments)
|
||||
|
||||
(Adapted from makeANF_CF_RI.m)
|
||||
"""
|
||||
import time
|
||||
import numpy as np
|
||||
import pyqtgraph as pg
|
||||
from cnmodel import an_model
|
||||
from cnmodel.util import sound
|
||||
|
||||
|
||||
def test_an_model():
|
||||
# model fiber parameters
|
||||
CF = 1.5e3 # CF in Hz
|
||||
cohc = 1.0 # normal ohc function
|
||||
cihc = 1.0 # normal ihc function
|
||||
species = (
|
||||
1
|
||||
) # 1 for cat (2 for human with Shera et al. tuning 3 for human with Glasberg & Moore tuning)
|
||||
noiseType = 1 # 1 for variable fGn (0 for fixed fGn)
|
||||
fiberType = (
|
||||
3
|
||||
) # spontaneous rate (in spikes/s) of the fiber BEFORE refractory effects "1" = Low "2" = Medium "3" = High
|
||||
implnt = (
|
||||
0
|
||||
) # "0" for approximate or "1" for actual implementation of the power-law functions in the Synapse
|
||||
|
||||
# stimulus parameters
|
||||
F0 = CF # stimulus frequency in Hz
|
||||
Fs = 100e3 # sampling rate in Hz (must be 100, 200 or 500 kHz)
|
||||
T = 150e-3 # stimulus duration in seconds
|
||||
pdur = 0.02 # pip duration
|
||||
pstart = [0.01, 0.035] # pip start times
|
||||
rt = 2.5e-3 # rise/fall time in seconds
|
||||
stimdb = 65 # stimulus intensity in dB SPL
|
||||
|
||||
# PSTH parameters
|
||||
nrep = 50 # number of stimulus repetitions (e.g., 50)
|
||||
psthbinwidth = 0.5e-3 # binwidth in seconds
|
||||
|
||||
stim = sound.TonePip(
|
||||
rate=Fs,
|
||||
duration=T,
|
||||
f0=F0,
|
||||
dbspl=stimdb,
|
||||
pip_duration=pdur,
|
||||
pip_start=pstart,
|
||||
ramp_duration=rt,
|
||||
)
|
||||
t = stim.time
|
||||
pin = stim.sound
|
||||
db = stim.measure_dbspl(rt, T - rt)
|
||||
|
||||
an_model.seed_rng(34978)
|
||||
start = time.time()
|
||||
vihc = an_model.model_ihc(
|
||||
pin, CF, nrep, 1 / Fs, T + 1e-3, cohc, cihc, species
|
||||
) # , _transfer=False)
|
||||
print("IHC time:", time.time() - start)
|
||||
start = time.time()
|
||||
m, v, psth = an_model.model_synapse(
|
||||
vihc, CF, nrep, 1 / Fs, fiberType, noiseType, implnt
|
||||
)
|
||||
print("Syn time:", time.time() - start)
|
||||
|
||||
win = pg.GraphicsWindow()
|
||||
p1 = win.addPlot(title="Input Stimulus (%0.1f dBSPL)" % db)
|
||||
p1.plot(t, pin)
|
||||
|
||||
p2 = win.addPlot(col=0, row=1, title="IHC voltage")
|
||||
p2.setXLink(p1)
|
||||
# vihc = vihc.get()[0]
|
||||
vihc = vihc[: len(vihc) // nrep]
|
||||
t = np.arange(len(vihc)) * 1e-5
|
||||
p2.plot(t, vihc)
|
||||
|
||||
p3 = win.addPlot(col=0, row=2, title="ANF PSTH")
|
||||
p3.setXLink(p2)
|
||||
ds = 100
|
||||
size = psth.size // ds
|
||||
psth = psth[: size * ds].reshape(size, ds).sum(axis=1)
|
||||
t = np.arange(len(psth)) * 1e-5 * ds
|
||||
p3.plot(t, psth[:-1], stepMode=True, fillLevel=0, fillBrush="w")
|
||||
if sys.flags.interactive == 0:
|
||||
pg.QtGui.QApplication.exec_()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
|
||||
test_an_model()
|
||||
1047
examples/test_bushy_variation.py
Normal file
1047
examples/test_bushy_variation.py
Normal file
File diff suppressed because it is too large
Load Diff
77
examples/test_ccstim.py
Normal file
77
examples/test_ccstim.py
Normal file
@@ -0,0 +1,77 @@
|
||||
"""
|
||||
Test the ccstim generator.
|
||||
|
||||
Usage: python test_ccstim.py
|
||||
|
||||
This script runs ccstim for each of it's potential inputs, and plots the resulting waveforms.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
from cnmodel.util import ccstim
|
||||
import pyqtgraph as pg
|
||||
|
||||
pulsetypes = ["square", "hyp", "timedSpikes", "exp"]
|
||||
|
||||
|
||||
def test_cc_stim():
|
||||
"""
|
||||
stim: a dictionary with keys [required]
|
||||
delay (delay to start of pulse train, msec [all]
|
||||
duration: duration of pulses in train, msec [all]
|
||||
Sfreq: stimulus train frequency (Hz) [timedSpikes]
|
||||
PT: post-train test delay [all]
|
||||
NP: number of pulses in the train [timedSpikes, exp]
|
||||
amp: amplitude of the pulses in the train [all]
|
||||
hypamp: amplitude of prehyperpolarizing pulse [hyp]
|
||||
hypdur: duration of prehyperpolarizing pulse [hyp]
|
||||
spikeTimes" times of spikes [timedSpikes]
|
||||
"""
|
||||
stim = {
|
||||
"square": {
|
||||
"delay": 10,
|
||||
"duration": 100,
|
||||
"Sfreq": 10,
|
||||
"PT": 0,
|
||||
"NP": 1,
|
||||
"amp": 100.0,
|
||||
},
|
||||
"hyp": {
|
||||
"delay": 10,
|
||||
"duration": 100,
|
||||
"Sfreq": 10,
|
||||
"PT": 0,
|
||||
"NP": 1,
|
||||
"amp": 100.0,
|
||||
"hypamp": -50,
|
||||
"hypdur": 50,
|
||||
},
|
||||
"timedSpikes": {
|
||||
"delay": 10,
|
||||
"duration": 1,
|
||||
"PT": 0,
|
||||
"amp": 100.0,
|
||||
"spikeTimes": [10.0, 20, 30, 40.0, 50.0],
|
||||
},
|
||||
"exp": {
|
||||
"delay": 10,
|
||||
"duration": 3,
|
||||
"Sfreq": 20,
|
||||
"PT": 0,
|
||||
"NP": 4,
|
||||
"amp": 100.0,
|
||||
},
|
||||
}
|
||||
|
||||
dt = 0.1
|
||||
|
||||
for p in pulsetypes:
|
||||
(w, tmax, ts) = ccstim.ccstim(stim[p], dt, pulsetype=p)
|
||||
tb = np.arange(0, w.shape[0] * dt, dt)
|
||||
pg.plot(tb, w, title=p)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_cc_stim()
|
||||
if sys.flags.interactive == 0:
|
||||
pg.QtGui.QApplication.exec_()
|
||||
515
examples/test_cells.py
Executable file
515
examples/test_cells.py
Executable file
@@ -0,0 +1,515 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
"""
|
||||
Test the basic membrane physiology of cell types.
|
||||
|
||||
Basic Usage: python test_cells.py celltype species [--cc | --vc]
|
||||
|
||||
This script generates a cell of the specified type and species, then tests the
|
||||
cell with a series of current/voltage pulses to produce I/V, F/I, and spike
|
||||
latency analyses.
|
||||
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os, sys
|
||||
from neuron import h
|
||||
import pyqtgraph as pg
|
||||
import cnmodel
|
||||
import cnmodel.cells as cells
|
||||
from cnmodel.protocols import IVCurve, VCCurve
|
||||
|
||||
debugFlag = True
|
||||
ax = None
|
||||
h.celsius = 22
|
||||
default_durs = [10.0, 100.0, 20.0]
|
||||
cclamp = False
|
||||
|
||||
cellinfo = {
|
||||
"types": [
|
||||
"bushy",
|
||||
"bushycoop",
|
||||
"tstellate",
|
||||
"tstellatenav11",
|
||||
"dstellate",
|
||||
"dstellateeager",
|
||||
"sgc",
|
||||
"cartwheel",
|
||||
"pyramidal",
|
||||
"octopus",
|
||||
"tuberculoventral",
|
||||
"mso",
|
||||
],
|
||||
"morphology": ["point", "waxon", "stick"],
|
||||
"nav": ["std", "jsrna", "nav11", "nacncoop"],
|
||||
"species": ["guineapig", "cat", "rat", "mouse"],
|
||||
"pulse": ["step", "pulse"],
|
||||
}
|
||||
|
||||
# Format for ivranges is list of tuples. This allows finer increments in selected ranges, such as close to rest
|
||||
ccivrange = {
|
||||
"mouse": {
|
||||
"bushy": {"pulse": [(-1, 1.2, 0.05)]},
|
||||
"bushycoop": {"pulse": [(-0.5, 0.7, 0.02)]},
|
||||
"tstellate": {"pulse": [(-1.0, 1.01, 0.05), (-0.015, 0, 0.005)]},
|
||||
"tstellatenav11": {"pulse": [(-1, 1.0, 0.1)]},
|
||||
"dstellate": {"pulse": [(-0.3, 0.301, 0.015)]},
|
||||
"octopus": {"pulse": [(-1.0, 1.0, 0.05)]},
|
||||
"sgc": {"pulse": [(-0.3, 0.6, 0.02)]},
|
||||
"cartwheel": {"pulse": [(-0.5, 0.5, 0.05)]},
|
||||
"pyramidal": {
|
||||
"pulse": [(-0.3, 0.3, 0.025), (-0.040, 0.025, 0.005)]
|
||||
}, # , 'prepulse': [(-0.25, -0.25, 0.25)]},
|
||||
"tuberculoventral": {"pulse": [(-0.35, 1.0, 0.05), (-0.040, 0.01, 0.005)]},
|
||||
},
|
||||
"guineapig": {
|
||||
"bushy": {"pulse": [(-1, 1.2, 0.05)]},
|
||||
"tstellate": {"pulse": [(-0.15, 0.15, 0.01)]},
|
||||
"dstellate": {"pulse": [(-0.25, 0.25, 0.025)]},
|
||||
"dstellateeager": {"pulse": [(-0.6, 1.0, 0.025)]},
|
||||
"octopus": {"pulse": [(-2.0, 6.0, 0.2)]},
|
||||
"sgc": {"pulse": [(-0.3, 0.6, 0.02)]},
|
||||
"mso": {"pulse": [(-1, 1.2, 0.05)]},
|
||||
},
|
||||
"rat": {
|
||||
"pyramidal": {
|
||||
"pulse": [(-0.3, 0.3, 0.025), (-0.040, 0.025, 0.005)]
|
||||
} # 'prepulse': [(-0.25, -0.25, 0.25)]},
|
||||
},
|
||||
}
|
||||
|
||||
# scales holds some default scaling to use in the cciv plots
|
||||
# argument is {cellname: (xmin, xmax, IVymin, IVymax, FIspikemax,
|
||||
# offset(for spikes), crossing (for IV) )}
|
||||
## the "offset" refers to setting the axes back a bit
|
||||
scale = {
|
||||
"bushy": (-1.0, -160.0, 1.0, -40, 0, 40, "offset", 5, "crossing", [0, -60]),
|
||||
"bushycoop": (-1.0, -160.0, 1.0, -40, 0, 40, "offset", 5, "crossing", [0, -60]),
|
||||
"tstellate": (-1.0, -160.0, 1.0, -40, 0, 40, "offset", 5, "crossing", [0, -60]),
|
||||
"tstellatenav11": (
|
||||
-1.0,
|
||||
-160.0,
|
||||
1.0,
|
||||
-40,
|
||||
0,
|
||||
40,
|
||||
"offset",
|
||||
5,
|
||||
"crossing",
|
||||
[0, -60],
|
||||
),
|
||||
"tstellatedend": (-1.0, -160.0, 1.0, -40, 0, 40, "offset", 5, "crossing", [0, -60]),
|
||||
"dstellate": (-1.0, -160.0, 1.0, -40, 0, 40, "offset", 5, "crossing", [0, -60]),
|
||||
"dstellateeager": (
|
||||
-1.0,
|
||||
-160.0,
|
||||
1.0,
|
||||
-40,
|
||||
0,
|
||||
40,
|
||||
"offset",
|
||||
5,
|
||||
"crossing",
|
||||
[0, -60],
|
||||
),
|
||||
"sgc:": (-1.0, -160.0, 1.0, -40, 0, 40, "offset", 5, "crossing", [0, -60]),
|
||||
"cartwheel": (-1.0, -160.0, 1.0, -40, 0, 40, "offset", 5, "crossing", [0, -60]),
|
||||
"pyramidal": (-1.0, -160.0, 1.0, -40, 0, 40, "offset", 5, "crossing", [0, -60]),
|
||||
"tuberculoventral": (
|
||||
-1.0,
|
||||
-160.0,
|
||||
1.0,
|
||||
-40,
|
||||
0,
|
||||
40,
|
||||
"offset",
|
||||
5,
|
||||
"crossing",
|
||||
[0, -60],
|
||||
),
|
||||
"octopus": (-1.0, -160.0, 1.0, -40, 0, 40, "offset", 5, "crossing", [0, -60]),
|
||||
"mso": (-1.0, -160.0, 1.0, -40, 0, 40, "offset", 5, "crossing", [0, -60]),
|
||||
}
|
||||
|
||||
|
||||
class Tests:
|
||||
"""
|
||||
Class to select cells for tests
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def selectCell(self, args):
|
||||
"""
|
||||
Parameters
|
||||
----------
|
||||
args : argparse args from command line
|
||||
|
||||
Returns
|
||||
-------
|
||||
cell
|
||||
Instantiated cell of the selected celltype
|
||||
"""
|
||||
h.celsius = float(args.temp)
|
||||
#
|
||||
# Spiral Ganglion cell tests
|
||||
#
|
||||
if args.celltype == "sgc": # morphology is always "point" for SGCs
|
||||
cell = cells.SGC.create(
|
||||
debug=debugFlag,
|
||||
species=args.species,
|
||||
nach=args.nav,
|
||||
ttx=args.ttx,
|
||||
modelType=args.type,
|
||||
)
|
||||
|
||||
#
|
||||
# Bushy tests
|
||||
#
|
||||
elif args.celltype == "bushy" and args.morphology == "point":
|
||||
cell = cells.Bushy.create(
|
||||
model="RM03",
|
||||
species=args.species,
|
||||
modelType=args.type,
|
||||
ttx=args.ttx,
|
||||
nach=args.nav,
|
||||
debug=debugFlag,
|
||||
)
|
||||
# cell.soma().klt.gbar = 0.0003
|
||||
|
||||
elif args.celltype == "bushy" and args.morphology == "waxon":
|
||||
cell = cells.Bushy.create(
|
||||
model="RM03",
|
||||
species=args.species,
|
||||
modelType=args.type,
|
||||
nach=args.nav,
|
||||
ttx=args.ttx,
|
||||
debug=debugFlag,
|
||||
)
|
||||
cell.add_axon()
|
||||
|
||||
elif args.celltype == "bushy" and args.morphology == "stick":
|
||||
cell = cells.Bushy.create(
|
||||
model="RM03",
|
||||
species=args.species,
|
||||
modelType=args.type,
|
||||
morphology="cnmodel/morphology/bushy_stick.hoc",
|
||||
decorator=True,
|
||||
nach=args.nav,
|
||||
ttx=args.ttx,
|
||||
debug=debugFlag,
|
||||
)
|
||||
h.topology()
|
||||
|
||||
elif args.celltype == "bushycoop" and args.morphology == "point":
|
||||
cell = cells.Bushy.create(
|
||||
model="RM03",
|
||||
species=args.species,
|
||||
modelType=args.type,
|
||||
ttx=args.ttx,
|
||||
nach=args.nav,
|
||||
debug=debugFlag,
|
||||
)
|
||||
|
||||
#
|
||||
# T-stellate tests
|
||||
#
|
||||
elif args.celltype == "tstellate" and args.morphology == "point":
|
||||
cell = cells.TStellate.create(
|
||||
model="RM03",
|
||||
species=args.species,
|
||||
modelType=args.type,
|
||||
nach=args.nav,
|
||||
ttx=args.ttx,
|
||||
debug=debugFlag,
|
||||
)
|
||||
|
||||
elif args.celltype == "tstellate" and args.morphology == "stick":
|
||||
cell = cells.TStellate.create(
|
||||
model="RM03",
|
||||
species=args.species,
|
||||
modelType=args.type,
|
||||
nach=args.nav,
|
||||
ttx=args.ttx,
|
||||
debug=debugFlag,
|
||||
morphology="cnmodel/morphology/tstellate_stick.hoc",
|
||||
decorator=True,
|
||||
)
|
||||
|
||||
elif (
|
||||
args.celltype == "tstellatenav11" and args.morphology == "point"
|
||||
): # note this uses a different model...
|
||||
print("test_cells: Stellate NAV11")
|
||||
cell = cells.TStellateNav11.create(
|
||||
model="Nav11",
|
||||
species=args.species,
|
||||
modelType=None,
|
||||
ttx=args.ttx,
|
||||
debug=debugFlag,
|
||||
)
|
||||
|
||||
elif (
|
||||
args.celltype == "tstellatenav11" and args.morphology == "stick"
|
||||
): # note this uses a different model...
|
||||
cell = cells.TStellateNav11.create(
|
||||
model="Nav11",
|
||||
species=args.species,
|
||||
modelType=None,
|
||||
morphology="cnmodel/morphology/tstellate_stick.hoc",
|
||||
decorator=True,
|
||||
ttx=args.ttx,
|
||||
debug=debugFlag,
|
||||
)
|
||||
h.topology()
|
||||
|
||||
#
|
||||
# Octopus cell tests
|
||||
#
|
||||
elif args.celltype == "octopus" and args.morphology == "point":
|
||||
cell = cells.Octopus.create(
|
||||
species=args.species,
|
||||
modelType="RM03", # args.type,
|
||||
nach=args.nav,
|
||||
ttx=args.ttx,
|
||||
debug=debugFlag,
|
||||
)
|
||||
|
||||
elif (
|
||||
args.celltype == "octopus" and args.morphology == "stick"
|
||||
): # Go to spencer et al. model
|
||||
cell = cells.Octopus.create(
|
||||
modelType="Spencer",
|
||||
species=args.species,
|
||||
morphology="cnmodel/morphology/octopus_spencer_stick.hoc",
|
||||
decorator=True,
|
||||
nach=args.nav,
|
||||
ttx=args.ttx,
|
||||
debug=debugFlag,
|
||||
)
|
||||
h.topology()
|
||||
|
||||
#
|
||||
# D-stellate tests
|
||||
#
|
||||
elif args.celltype == "dstellate":
|
||||
cell = cells.DStellate.create(
|
||||
debug=debugFlag, species=args.species, ttx=args.ttx, modelType=args.type
|
||||
)
|
||||
|
||||
elif args.celltype == "dstellateeager":
|
||||
cell = cells.DStellateEager.create(
|
||||
debug=debugFlag, ttx=args.ttx, modelType=args.type
|
||||
)
|
||||
|
||||
#
|
||||
# DCN pyramidal cell tests
|
||||
#
|
||||
elif args.celltype == "pyramidal":
|
||||
cell = cells.Pyramidal.create(
|
||||
modelType=args.type, ttx=args.ttx, debug=debugFlag
|
||||
)
|
||||
|
||||
#
|
||||
# DCN tuberculoventral cell tests
|
||||
#
|
||||
elif args.celltype == "tuberculoventral" and args.morphology == "point":
|
||||
cell = cells.Tuberculoventral.create(
|
||||
species="mouse",
|
||||
modelType="TVmouse",
|
||||
ttx=args.ttx,
|
||||
nach=args.nav,
|
||||
debug=debugFlag,
|
||||
)
|
||||
|
||||
elif args.celltype == "tuberculoventral" and args.morphology == "stick":
|
||||
cell = cells.Tuberculoventral.create(
|
||||
species="mouse",
|
||||
modelType="TVmouse",
|
||||
morphology="cnmodel/morphology/tv_stick.hoc",
|
||||
decorator=True,
|
||||
ttx=args.ttx,
|
||||
debug=debugFlag,
|
||||
)
|
||||
h.topology()
|
||||
|
||||
#
|
||||
# DCN cartwheel cell tests
|
||||
#
|
||||
elif args.celltype == "cartwheel":
|
||||
cell = cells.Cartwheel.create(
|
||||
modelType=args.type, ttx=args.ttx, debug=debugFlag
|
||||
)
|
||||
|
||||
#
|
||||
# MSO principal neuron tests
|
||||
#
|
||||
elif args.celltype == "mso" and args.morphology == "point":
|
||||
cell = cells.MSO.create(
|
||||
model="RM03",
|
||||
species=args.species,
|
||||
modelType=args.type,
|
||||
ttx=args.ttx,
|
||||
nach=args.nav,
|
||||
debug=debugFlag,
|
||||
)
|
||||
|
||||
else:
|
||||
raise ValueError(
|
||||
"Cell Type %s and configurations nav=%s or config=%s are not available"
|
||||
% (args.celltype, args.nav, args.morphology)
|
||||
)
|
||||
|
||||
print(cell.__doc__)
|
||||
self.cell = cell
|
||||
|
||||
def run_test(self, sites, ptype, args):
|
||||
"""
|
||||
Run either vc or cc test, and plot the result
|
||||
|
||||
Parameters
|
||||
----------
|
||||
args : argparse args from command line
|
||||
|
||||
"""
|
||||
self.cell.set_temperature(float(args.temp))
|
||||
print(self.cell.status)
|
||||
V0 = self.cell.find_i0(showinfo=True)
|
||||
# self.cell.cell_initialize()
|
||||
print(
|
||||
"Currents at nominal Vrest= %.2f I = 0: I = %g "
|
||||
% (V0, self.cell.i_currents(V=V0))
|
||||
)
|
||||
self.cell.print_mechs(self.cell.soma)
|
||||
instant = self.cell.compute_rmrintau(auto_initialize=False, vrange=None)
|
||||
print(
|
||||
" From Inst: Rin = {:7.1f} Tau = {:7.1f} Vm = {:7.1f}".format(
|
||||
instant["Rin"], instant["tau"], instant["v"]
|
||||
)
|
||||
)
|
||||
if args.cc is True:
|
||||
# define the current clamp electrode and default settings
|
||||
self.iv = IVCurve()
|
||||
self.iv.run(
|
||||
ccivrange[args.species][args.celltype],
|
||||
self.cell,
|
||||
durs=default_durs,
|
||||
sites=sites,
|
||||
reppulse=ptype,
|
||||
temp=float(args.temp),
|
||||
)
|
||||
ret = self.iv.input_resistance_tau()
|
||||
print(
|
||||
" From IV: Rin = {:7.1f} Tau = {:7.1f} Vm = {:7.1f}".format(
|
||||
ret["slope"], ret["tau"], ret["intercept"]
|
||||
)
|
||||
)
|
||||
self.iv.show(cell=self.cell)
|
||||
|
||||
elif args.rmp is True:
|
||||
print("temperature: ", self.cell.status["temperature"])
|
||||
self.iv = IVCurve()
|
||||
self.iv.run(
|
||||
{"pulse": (0, 0, 1)},
|
||||
self.cell,
|
||||
durs=default_durs,
|
||||
sites=sites,
|
||||
reppulse=ptype,
|
||||
temp=float(args.temp),
|
||||
)
|
||||
self.iv.show(cell=self.cell, rmponly=True)
|
||||
|
||||
elif args.vc is True:
|
||||
# define the voltage clamp electrode and default settings
|
||||
self.vc = VCCurve()
|
||||
self.vc.run((-120, 40, 5), self.cell)
|
||||
self.vc.show(cell=self.cell)
|
||||
|
||||
else:
|
||||
raise ValueError("Nothing to run. Specify one of --cc, --vc, --rmp.")
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description=(
|
||||
"test_cells.py:",
|
||||
" Biophysical representations of neurons (mostly auditory), test file",
|
||||
)
|
||||
)
|
||||
parser.add_argument("celltype", action="store")
|
||||
parser.add_argument("species", action="store", default="guineapig")
|
||||
parser.add_argument("--type", action="store", default=None)
|
||||
parser.add_argument(
|
||||
"--temp", action="store", default=22.0, help=("Temp DegC (22 default)")
|
||||
)
|
||||
# species is an optional option....
|
||||
parser.add_argument(
|
||||
"-m",
|
||||
action="store",
|
||||
dest="morphology",
|
||||
default="point",
|
||||
help=("Set morphology: %s " % [morph for morph in cellinfo["morphology"]]),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--nav",
|
||||
action="store",
|
||||
dest="nav",
|
||||
default=None,
|
||||
help=("Choose sodium channel: %s " % [ch for ch in cellinfo["nav"]]),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--ttx",
|
||||
action="store_true",
|
||||
dest="ttx",
|
||||
default=False,
|
||||
help=("Use TTX (no sodium current"),
|
||||
)
|
||||
parser.add_argument(
|
||||
"-p",
|
||||
action="store",
|
||||
dest="pulsetype",
|
||||
default="step",
|
||||
help=("Set CCIV pulse to step or repeated pulse"),
|
||||
)
|
||||
clampgroup = parser.add_mutually_exclusive_group()
|
||||
clampgroup.add_argument(
|
||||
"--vc", action="store_true", help="Run in voltage clamp mode"
|
||||
)
|
||||
clampgroup.add_argument(
|
||||
"--cc", action="store_true", help="Run in current clamp mode"
|
||||
)
|
||||
clampgroup.add_argument(
|
||||
"--rmp", action="store_true", help="Run to get RMP in current clamp mode"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
if args.celltype not in cellinfo["types"]:
|
||||
print("cell: %s is not in our list of cell types" % (args.celltype))
|
||||
print("celltypes: ", cellinfo["types"])
|
||||
sys.exit(1)
|
||||
|
||||
path = os.path.dirname(cnmodel.__file__)
|
||||
# h.load_file("stdrun.hoc")
|
||||
# h.load_file(os.path.join(path, "custom_init.hoc")) # replace init with one that gets closer to steady state
|
||||
|
||||
# print 'Species: ', args.species
|
||||
# print 'Morphology configuration: ', args.morphology
|
||||
sites = None
|
||||
if args.pulsetype == "step":
|
||||
ptype = None
|
||||
else:
|
||||
ptype = "pulses"
|
||||
if args.morphology in cellinfo["morphology"]:
|
||||
print("Morphological configuration %s is ok" % args.morphology)
|
||||
|
||||
t = Tests()
|
||||
t.selectCell(args)
|
||||
app = pg.mkQApp()
|
||||
t.run_test(sites, ptype, args)
|
||||
|
||||
if sys.flags.interactive == 0:
|
||||
pg.QtGui.QApplication.exec_()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
60
examples/test_circuit.py
Normal file
60
examples/test_circuit.py
Normal file
@@ -0,0 +1,60 @@
|
||||
"""
|
||||
Test construction of a complete circuit build from cell populations.
|
||||
|
||||
This script:
|
||||
|
||||
1. Creates populations of sgc, bushy, and stellate cells.
|
||||
2. Connects the populations together.
|
||||
3. Instantiates 10 bushy and 10 t-stellate cells near 16kHz.
|
||||
4. Resolves all required synaptic dependencies.
|
||||
|
||||
No simulation is executed; this is meant to be run interactively to allow
|
||||
introspection of the circuit that was generated.
|
||||
"""
|
||||
|
||||
from cnmodel import populations
|
||||
|
||||
|
||||
def testcircuit():
|
||||
# Create cell populations.
|
||||
# This creates a complete set of _virtual_ cells for each population. No
|
||||
# cells are instantiated at this point.
|
||||
sgc = populations.SGC()
|
||||
bushy = populations.Bushy()
|
||||
dstellate = populations.DStellate()
|
||||
tstellate = populations.TStellate()
|
||||
|
||||
# Connect populations.
|
||||
# This only records the connections between populations; no synapses are
|
||||
# created at this stage.
|
||||
sgc.connect(bushy, tstellate, dstellate)
|
||||
dstellate.connect(tstellate, bushy)
|
||||
# tstellate.connect(bushy) # this will fail - we don't know about this connection yet.
|
||||
|
||||
# Select cells to record from.
|
||||
# At this time, we actually instantiate the selected cells.
|
||||
# select 10 bushy cells closest to 16kHz
|
||||
bushy_cell_ids = bushy.select(10, cf=16e3, create=True)
|
||||
# select 10 stellate cells closest to 16kHz
|
||||
tstel_cell_ids = tstellate.select(10, cf=16e3, create=True)
|
||||
|
||||
# Now create the supporting circuitry needed to drive the cells we selected.
|
||||
# At this time, cells are created in all populations and automatically
|
||||
# connected with synapses.
|
||||
bushy.resolve_inputs(depth=2)
|
||||
tstellate.resolve_inputs(depth=2)
|
||||
# Note that using depth=2 indicates the level of recursion to use when
|
||||
# resolving inputs. For example, resolving inputs for the bushy cell population
|
||||
# (level 1) creates presynaptic cells in the dstellate population, and resolving
|
||||
# inputs for the dstellate population (level 2) creates presynaptic cells in the
|
||||
# sgc population.
|
||||
|
||||
# TODO:
|
||||
# - specify which parameters to record (Vm, spike times, per-synapse currents, etc)
|
||||
# - run simulation and display / analyze results
|
||||
# - add examples of modifying circuitry to search parameter spaces, test
|
||||
# hypotheses, etc.
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
testcircuit()
|
||||
151
examples/test_decorator.py
Executable file
151
examples/test_decorator.py
Executable file
@@ -0,0 +1,151 @@
|
||||
#!/usr/bin/python
|
||||
"""
|
||||
Basic test of cnmodel decorator on simple cell
|
||||
Users LC_bushy.hoc and XM13 mechanisms.
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
__author__ = "pbmanis"
|
||||
|
||||
|
||||
__author__ = "pbmanis"
|
||||
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
import cnmodel.cells as cells
|
||||
import cnmodel.decorator as Decorator
|
||||
from cnmodel.util import pyqtgraphPlotHelpers as PH
|
||||
from cnmodel.protocols import IVCurve
|
||||
import pyqtgraph as pg
|
||||
import timeit
|
||||
|
||||
|
||||
class F5:
|
||||
def __init__(self, filename):
|
||||
# build plotting area
|
||||
#
|
||||
self.filename = filename
|
||||
self.iv = IVCurve() # use standard IVCurve here...
|
||||
self.temperature = 34
|
||||
self.initdelay = 150.0
|
||||
|
||||
def run(self):
|
||||
self.post_cell = cells.Bushy.create(
|
||||
morphology=self.filename,
|
||||
decorator=Decorator,
|
||||
species="mouse",
|
||||
modelName="XM13",
|
||||
modelType="II",
|
||||
)
|
||||
self.post_cell.set_temperature(float(self.temperature))
|
||||
self.post_cell.set_d_lambda(
|
||||
freq=2000.0
|
||||
) # necessary to ensure appropriate spatial
|
||||
self.iv.reset()
|
||||
irange = self.post_cell.i_test_range
|
||||
# irange = {'pulse': (-0.6, 1.1, 0.2)} for Figure 5 of paper
|
||||
irange = {"pulse": (-0.5, 1.5, 0.25)}
|
||||
self.durs = (self.initdelay + 20.0, 100.0, 50.0)
|
||||
self.iv.run(
|
||||
irange,
|
||||
self.post_cell,
|
||||
durs=self.durs,
|
||||
temp=float(self.temperature),
|
||||
initdelay=self.initdelay,
|
||||
)
|
||||
|
||||
def plot(self):
|
||||
pg.setConfigOption("background", "w") # set background to white
|
||||
pg.setConfigOption("foreground", "k")
|
||||
self.app = pg.mkQApp()
|
||||
|
||||
wintitle = "test_decorator"
|
||||
self.view = pg.GraphicsView()
|
||||
self.layout = pg.GraphicsLayout() # (border=(100,100,100))
|
||||
self.view.setCentralItem(self.layout)
|
||||
self.view.resize(800, 600)
|
||||
self.view.show()
|
||||
self.plots = {}
|
||||
nr1 = 6
|
||||
nc = 10
|
||||
for i in range(1, nr1):
|
||||
self.plots["p%d" % i] = None
|
||||
for i in range(1, nr1 + 1):
|
||||
self.layout.addLayout(row=i, col=nc)
|
||||
for i in range(1, nc + 1):
|
||||
self.layout.addLayout(row=nr1 + 2, col=i)
|
||||
|
||||
self.plots["p1"] = self.layout.addPlot(
|
||||
row=1,
|
||||
col=1,
|
||||
rowspan=6,
|
||||
colspan=9,
|
||||
labels={"left": "V (mV)", "bottom": "Time (ms)"},
|
||||
)
|
||||
self.plots["p2"] = self.layout.addPlot(
|
||||
row=7,
|
||||
col=1,
|
||||
rowspan=1,
|
||||
colspan=9,
|
||||
labels={"left": "I (nA)", "bottom": "Time (ms)"},
|
||||
)
|
||||
|
||||
for k in range(len(self.iv.voltage_traces)):
|
||||
self.plots["p1"].plot(
|
||||
self.iv.time_values,
|
||||
np.array(self.iv.voltage_traces[k]),
|
||||
pen=pg.mkPen("k", width=0.75),
|
||||
)
|
||||
self.plots["p2"].plot(
|
||||
self.iv.time_values,
|
||||
np.array(self.iv.current_traces[k]),
|
||||
pen=pg.mkPen("k", width=0.75),
|
||||
)
|
||||
self.plots["p1"].setRange(
|
||||
xRange=(0.0, np.sum(self.durs) - self.initdelay), yRange=(-160.0, 40.0)
|
||||
)
|
||||
self.plots["p2"].setRange(
|
||||
xRange=(0.0, np.sum(self.durs) - self.initdelay), yRange=(-1, 1)
|
||||
)
|
||||
PH.noaxes(self.plots["p1"])
|
||||
PH.calbar(
|
||||
self.plots["p1"],
|
||||
calbar=[125.0, -120.0, 10.0, 20.0],
|
||||
unitNames={"x": "ms", "y": "mV"},
|
||||
)
|
||||
PH.noaxes(self.plots["p2"])
|
||||
PH.calbar(
|
||||
self.plots["p2"],
|
||||
calbar=[125, 0.1, 0.0, 0.5],
|
||||
unitNames={"x": "ms", "y": "nA"},
|
||||
)
|
||||
|
||||
text = "{0:2d}\u00b0C {1:.2f}-{2:.2f} nA".format(
|
||||
int(self.temperature),
|
||||
np.min(self.iv.current_cmd),
|
||||
np.max(self.iv.current_cmd),
|
||||
)
|
||||
ti = pg.TextItem(text, anchor=(1, 0))
|
||||
ti.setFont(pg.QtGui.QFont("Arial", 9))
|
||||
ti.setPos(120.0, -120.0)
|
||||
self.plots["p1"].addItem(ti)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) == 1:
|
||||
fig5 = F5("examples/LC_bushy.hoc")
|
||||
else:
|
||||
fn = "/Users/pbmanis/Desktop/Python/VCNModel/VCN_Cells/VCN_c{0:02d}/Morphology/VCN_c{0:02d}.hoc".format(
|
||||
int(sys.argv[1])
|
||||
)
|
||||
fig5 = F5(fn)
|
||||
start_time = timeit.default_timer()
|
||||
fig5.run()
|
||||
elapsed = timeit.default_timer() - start_time
|
||||
print("Elapsed time for simulation: %f" % (elapsed))
|
||||
fig5.plot()
|
||||
if sys.flags.interactive == 0:
|
||||
pg.QtGui.QApplication.exec_()
|
||||
317
examples/test_mechanisms.py
Normal file
317
examples/test_mechanisms.py
Normal file
@@ -0,0 +1,317 @@
|
||||
"""
|
||||
test_mechanisms.py
|
||||
|
||||
This program displays the results of inserting NEURON mechaanisms from .mod files
|
||||
into a point cell to voltage steps in voltage clamp.
|
||||
This code is primarily for visual verification of model function.
|
||||
|
||||
Usage: python test_mechanisms.py <mechname>
|
||||
|
||||
Available mechanisms::
|
||||
|
||||
CaPCalyx bkpkj hcno hcnobo hpkj
|
||||
ihpyr ihsgcApical ihsgcBasalMiddle ihvcn jsrna
|
||||
ka kcnq kdpyr kht kif
|
||||
kis klt kpkj kpkj2 kpkjslow
|
||||
kpksk leak lkpkj na naRsg
|
||||
nacn nacncoop nap napyr nav11
|
||||
|
||||
Note: only modfiles that implement voltage-dependent ion channel models make sense to run
|
||||
with this routine. the list "nottestablemechs" in the file defines mechanisms provided
|
||||
with cnmodel that cannot be run with this program.
|
||||
|
||||
"""
|
||||
import sys
|
||||
from neuron import h
|
||||
from neuron import nrn
|
||||
|
||||
import gc
|
||||
import numpy as np
|
||||
|
||||
# import scipy as sp
|
||||
import cnmodel.util
|
||||
import pyqtgraph as pg
|
||||
import pyqtgraph.exporters
|
||||
from pyqtgraph.Qt import QtCore, QtGui
|
||||
import cnmodel.util.pynrnutilities as Util
|
||||
|
||||
nottestablemechs = [
|
||||
"cadyn",
|
||||
"ca_ion",
|
||||
"cadiff",
|
||||
"cadifpmp",
|
||||
"Mechanism",
|
||||
"capmp",
|
||||
"capump",
|
||||
"cl_ion",
|
||||
"extracellular",
|
||||
"fastpas",
|
||||
"k_ion",
|
||||
"KIR",
|
||||
"hh",
|
||||
"na_ion",
|
||||
"narsg",
|
||||
"pas",
|
||||
"cap",
|
||||
] # cap uses "pcabar"
|
||||
|
||||
|
||||
class ChannelKinetics:
|
||||
def __init__(self, args, export=False):
|
||||
modfile = []
|
||||
if isinstance(args, list):
|
||||
for arg in args:
|
||||
modfile.append(arg) # must be string, not list...
|
||||
else:
|
||||
modfile.append(args) # 'CaPCalyx'
|
||||
print("modfile: ", modfile)
|
||||
colors = ["b", "r", "g", "y", "c", "m", "w"]
|
||||
if len(modfile) > len(colors):
|
||||
print("Too many modfiles... keep it simple!")
|
||||
exit()
|
||||
# if isinstance(args, list) and len(args) > 1:
|
||||
# modfile2 = args[1]
|
||||
doKinetics = False
|
||||
self.app = pg.mkQApp()
|
||||
self.win = pg.GraphicsWindow()
|
||||
self.win.setWindowTitle("VC Plots")
|
||||
self.win.resize(600, 800)
|
||||
# cw = QtGui.QWidget()
|
||||
# self.win.setCentralWidget(cw)
|
||||
# self.gridLayout = QtGui.QGridLayout()
|
||||
# cw.setLayout(self.gridLayout)
|
||||
# self.gridLayout.setContentsMargins(9, 9, 4, 4)
|
||||
# self.gridLayout.setSpacing(1)
|
||||
self.p1 = self.win.addPlot(title="I (VC)")
|
||||
# self.gridLayout.addWidget(self.p1, 0, 0, 1, 1)
|
||||
self.p2 = self.win.addPlot(title="I_ss, I_max")
|
||||
# self.gridLayout.addWidget(self.p2, 0, 1, 1, 1)
|
||||
self.win.nextRow()
|
||||
self.p3 = self.win.addPlot(title="V command")
|
||||
# self.gridLayout.addWidget(self.p3, 1, 0, 1, 1)
|
||||
self.p5 = self.win.addPlot(title="I_min")
|
||||
# self.gridLayout.addWidget(self.p5, 1, 1, 1, 1)
|
||||
self.win.show()
|
||||
QtGui.QApplication.processEvents()
|
||||
#
|
||||
# self.tdur is a table of durations for the pulse and post-pulse for each channel type (best to highlight features
|
||||
# on appropriate time scales)
|
||||
#
|
||||
self.tdur = {
|
||||
"CaPCalyx": [20.0, 10.0],
|
||||
"nav11": [10.0, 5.0],
|
||||
"jsrna": [10.0, 5.0],
|
||||
"ichanWT2005": [10.0, 5.0],
|
||||
"nacn": [10.0, 5.0],
|
||||
"nacncoop": [10.0, 5.0],
|
||||
"nabu": [10.0, 5.0],
|
||||
"kht": [200.0, 20.0],
|
||||
"klt": [200.0, 20.0],
|
||||
"ka": [25.0, 5.0],
|
||||
"hcno": [1000.0, 200.0],
|
||||
"ih": [1000.0, 200.0],
|
||||
"ihvcn": [1000.0, 200.0],
|
||||
"hcnobo": [1000.0, 200.0],
|
||||
"ihsgcBasalMiddle": [1000.0, 200.0],
|
||||
"ihsgcApical": [1000.0, 200.0],
|
||||
"kif": [100.0, 100.0],
|
||||
"kis": [100.0, 10.0],
|
||||
"napyr": [10, 5.0],
|
||||
"ihpyr": [1000.0, 200.0],
|
||||
"kdpyr": [200.0, 20.0],
|
||||
"kcnq": [200, 20],
|
||||
"nap": [200.0, 100.0],
|
||||
}
|
||||
for i, mfile in enumerate(modfile):
|
||||
self.run(modfile=mfile, color=colors[i], export=export)
|
||||
s = ""
|
||||
# self.win.setWindowTitle('VC Plots: ' + [s+sn+'; ' for sn in modfile])
|
||||
gc.collect()
|
||||
|
||||
if doKinetics:
|
||||
self.win2 = pg.GraphicsWindow(title="KineticPlots")
|
||||
self.win2.resize(800, 600)
|
||||
self.kp1 = self.win.addPlot(title="htau")
|
||||
self.computeKinetics("nav11")
|
||||
|
||||
# self.win.show()
|
||||
|
||||
def run(self, modfile="CaPCalyx", color="r", export=False):
|
||||
if isinstance(modfile, list):
|
||||
modfile = modfile[0]
|
||||
|
||||
if modfile in self.tdur:
|
||||
tstep = self.tdur[modfile]
|
||||
else:
|
||||
tstep = [200.0, 50.0]
|
||||
tdelay = 5.0
|
||||
Channel = cnmodel.util.Mechanism(modfile)
|
||||
leak = cnmodel.util.Mechanism("leak")
|
||||
Channel.set_parameters({"gbar": 1})
|
||||
leak.set_parameters({"gbar": 1e-12})
|
||||
# if modfile == 'nacncoop':
|
||||
# self.soma().nacncoop.p = 0.
|
||||
# self.soma().nacncoop.KJ = 0.
|
||||
# # Channel.set_parameters({'p': 0., 'KJ': 000.})
|
||||
|
||||
self.soma = cnmodel.util.Section(L=10, diam=10, mechanisms=[Channel, leak])
|
||||
if modfile == "bkpjk":
|
||||
ca_init = 100e-6
|
||||
self.soma().cai = ca_init
|
||||
else:
|
||||
ca_init = 70e-6
|
||||
if modfile == "nacncoop":
|
||||
self.soma().nacncoop.p = 0.1
|
||||
self.soma().nacncoop.KJ = 1000.0
|
||||
# Channel.set_parameters({'p': 0., 'KJ': 000.})
|
||||
h.celsius = 37.0 # set the temperature.
|
||||
self.vec = {}
|
||||
for var in ["time", "V", "IChan", "Vcmd"]:
|
||||
self.vec[var] = h.Vector()
|
||||
|
||||
h.dt = 0.025
|
||||
v_init = -65.0
|
||||
|
||||
clampV = v_init
|
||||
self.vcPost = h.SEClamp(0.5, sec=self.soma)
|
||||
self.vcPost.dur1 = tdelay
|
||||
self.vcPost.amp1 = clampV
|
||||
self.vcPost.dur2 = tstep[0]
|
||||
self.vcPost.amp2 = clampV - 0.0 # just a tiny step to keep the system honest
|
||||
self.vcPost.dur3 = tstep[1]
|
||||
self.vcPost.amp3 = clampV
|
||||
self.vcPost.rs = 1e-9
|
||||
print("soma: ", self.soma, end=" ")
|
||||
# print(dir(self.vcPost))
|
||||
# print(' vcpost sec: ', self.vcPost.Section())
|
||||
|
||||
if modfile[0:2] == "ih":
|
||||
stimamp = np.linspace(-140, -40, num=21, endpoint=True)
|
||||
else:
|
||||
stimamp = np.linspace(-100, 60, num=35, endpoint=True)
|
||||
self.ivss = np.zeros((2, stimamp.shape[0]))
|
||||
self.ivmin = np.zeros((2, stimamp.shape[0]))
|
||||
self.ivmax = np.zeros((2, stimamp.shape[0]))
|
||||
print(
|
||||
(
|
||||
"I range = %6.1f-%6.1f, T = %4.1f"
|
||||
% (np.min(stimamp), np.max(stimamp), h.celsius)
|
||||
)
|
||||
)
|
||||
|
||||
for i, V in enumerate(stimamp):
|
||||
stim = {}
|
||||
stim["NP"] = 1
|
||||
stim["Sfreq"] = 1 # stimulus frequency
|
||||
stim["delay"] = 5
|
||||
stim["dur"] = 100
|
||||
stim["amp"] = V
|
||||
stim["PT"] = 0.0
|
||||
self.vcPost.amp2 = V
|
||||
self.vec["IChan"].record(self.vcPost._ref_i, sec=self.soma)
|
||||
self.vec["V"].record(self.soma()._ref_v, sec=self.soma)
|
||||
self.vec["time"].record(h._ref_t)
|
||||
# print
|
||||
h.tstop = self.vcPost.dur1 + self.vcPost.dur2 + self.vcPost.dur3
|
||||
h.finitialize(v_init)
|
||||
h.run()
|
||||
self.t = np.array(self.vec["time"])
|
||||
self.ichan = np.array(self.vec["IChan"])
|
||||
self.v = np.array(self.vec["V"])
|
||||
self.p1.plot(self.t, self.ichan, pen=pg.mkPen((i, len(stimamp) * 1.5)))
|
||||
self.p3.plot(self.t, self.v, pen=pg.mkPen((i, len(stimamp) * 1.5)))
|
||||
(self.ivss[1, i], r2) = Util.measure(
|
||||
"mean", self.t, self.ichan, tdelay + tstep[0] - 10.0, tdelay + tstep[0]
|
||||
)
|
||||
(self.ivmin[1, i], r2) = Util.measure(
|
||||
"min", self.t, self.ichan, tdelay + 0.1, tdelay + tstep[0] / 5.0
|
||||
)
|
||||
(self.ivmax[1, i], r2) = Util.measure(
|
||||
"max", self.t, self.ichan, tdelay + 0.1, tdelay + tstep[0] / 5.0
|
||||
)
|
||||
self.ivss[0, i] = V
|
||||
self.ivmin[0, i] = V
|
||||
self.ivmax[0, i] = V
|
||||
self.p2.plot(
|
||||
self.ivss[0, :],
|
||||
self.ivss[1, :],
|
||||
symbol="o",
|
||||
symbolSize=4.0,
|
||||
pen=pg.mkPen(color),
|
||||
)
|
||||
self.p2.plot(
|
||||
self.ivmax[0, :],
|
||||
self.ivmax[1, :],
|
||||
symbol="t",
|
||||
symbolSize=4.0,
|
||||
pen=pg.mkPen(color),
|
||||
)
|
||||
self.p5.plot(
|
||||
self.ivmin[0, :],
|
||||
self.ivmin[1, :],
|
||||
symbol="s",
|
||||
symbolSize=4.0,
|
||||
pen=pg.mkPen(color),
|
||||
)
|
||||
|
||||
print(export)
|
||||
if export:
|
||||
exporter = pg.exporters.MatplotlibExporter(self.p1)
|
||||
print("exporting: " + "%s_traces.svg" % modfile)
|
||||
exporter.export(fileName="%s_traces.pdf" % modfile)
|
||||
exporter = pg.exporters.MatplotlibExporter(self.p3)
|
||||
exporter.export("%s_command.pdf" % modfile)
|
||||
exporter = pg.exporters.MatplotlibExporter(self.p2)
|
||||
exporter.export("%s_IV.pdf" % modfile)
|
||||
|
||||
def computeKinetics(self, ch):
|
||||
pass
|
||||
|
||||
|
||||
def getmechs():
|
||||
mechs = []
|
||||
for n in dir(nrn):
|
||||
o = getattr(nrn, n)
|
||||
if str(o) == str(nrn.Mechanism):
|
||||
mechs.append(n)
|
||||
return mechs
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
mechs = getmechs()
|
||||
if len(sys.argv) < 2:
|
||||
|
||||
print("\n\nUsage: python test_mechanisms.py <mechname>")
|
||||
print(" Available mechanisms:")
|
||||
|
||||
linelen = 0
|
||||
for i, n in enumerate(mechs):
|
||||
if n in nottestablemechs: # 'Mechanism':
|
||||
continue
|
||||
print("%20s" % n, end=" ")
|
||||
linelen += 20
|
||||
if linelen > 80:
|
||||
print("")
|
||||
|
||||
linelen = 0
|
||||
sys.exit(1)
|
||||
|
||||
if sys.argv[1:] in nottestablemechs:
|
||||
exit()
|
||||
export = False
|
||||
if len(sys.argv) > 2:
|
||||
if sys.argv[2] == "export":
|
||||
export = True
|
||||
|
||||
if sys.argv[1] == "all":
|
||||
for n in mechs:
|
||||
if n in nottestablemechs:
|
||||
print(("Skipping %s" % n))
|
||||
continue
|
||||
else:
|
||||
ck = ChannelKinetics(n)
|
||||
else:
|
||||
ck = ChannelKinetics(sys.argv[1], export=export)
|
||||
|
||||
if sys.flags.interactive == 0:
|
||||
pg.QtGui.QApplication.exec_()
|
||||
208
examples/test_mso_inputs.py
Normal file
208
examples/test_mso_inputs.py
Normal file
@@ -0,0 +1,208 @@
|
||||
"""
|
||||
Test generating a series of EPSPs in a MSO cell in response to tone pip. This
|
||||
test demonstrates how a binaural circuit can be constructed.
|
||||
|
||||
This script:
|
||||
|
||||
1. Creates multiple SGCs (base instance has 3) converging onto two bushy cells.
|
||||
The 2 bushy cells then converge onto one MSO cell
|
||||
2. Connects the group of sgc cells from one ear to one bushy cell, and the
|
||||
other sgcs from the other ear to the
|
||||
other bushy cell.
|
||||
3. Specifies the CFs of the SGC cells individually. Also specifies the frequency of
|
||||
and stimuli by ear allowing for "binaural beats"
|
||||
4. Records the bushy and MSO cell membrane voltages, sgc spike time, and calculates
|
||||
vector strengths.
|
||||
|
||||
The auditory nerve spike train is generated automatically by the DummySGC class
|
||||
using the tone pip. For lower-level access to the auditory nerve model, see the
|
||||
test_an_model.py and test_sound_stim.py examples.
|
||||
|
||||
|
||||
Usage:
|
||||
python examples/test_mso_inputs.py [cochlea | matlab]
|
||||
|
||||
The AN simulator that is run depends on what is available and how the script is called.
|
||||
python examples/test_mso_inputs.py [cochlea | matlab] will try to use the specified
|
||||
simulator. If no simulator is specified, it will try to use cochlea or matlab, in
|
||||
that order.
|
||||
|
||||
"""
|
||||
import sys
|
||||
import numpy as np
|
||||
import pyqtgraph as pg
|
||||
from neuron import h
|
||||
from cnmodel.protocols import Protocol
|
||||
from cnmodel import cells
|
||||
from cnmodel.util import sound
|
||||
from cnmodel.util import custom_init
|
||||
import cnmodel.util.pynrnutilities as PU
|
||||
|
||||
|
||||
class MSOBinauralTest(Protocol):
|
||||
def run(self, temp=38.0, dt=0.025, seed=575982035, simulator=None):
|
||||
ears = {"left": [500.0, 502, 498], "right": [500.0, 502.0, 498]}
|
||||
|
||||
self.beatfreq = 0.0
|
||||
self.f0 = 500.0
|
||||
f0 = {"left": self.f0, "right": self.f0 + self.beatfreq}
|
||||
nsgc = len(list(ears.keys()))
|
||||
sgcCell = {}
|
||||
bushyCell = {}
|
||||
msoCell = {}
|
||||
synapse = {}
|
||||
self.stim = {}
|
||||
self.ears = ears
|
||||
self.stimdur = 0.2
|
||||
self.stimdelay = 0.02
|
||||
self.rundur = self.stimdelay + self.stimdur + 0.02
|
||||
|
||||
for i, ear in enumerate(ears.keys()):
|
||||
nsgc = len(ears[ear]) # how many sgcs are specified for this ear
|
||||
sgcCell[ear] = [cells.DummySGC(cf=ears[ear][k], sr=2) for k in range(nsgc)]
|
||||
bushyCell[ear] = [cells.Bushy.create(temperature=temp)]
|
||||
synapse[ear] = [
|
||||
sgcCell[ear][k].connect(bushyCell[ear][0]) for k in range(nsgc)
|
||||
]
|
||||
self.stim[ear] = [
|
||||
sound.TonePip(
|
||||
rate=100e3,
|
||||
duration=self.stimdur + 0.1,
|
||||
f0=f0[ear],
|
||||
dbspl=80,
|
||||
ramp_duration=2.5e-3,
|
||||
pip_duration=self.stimdur,
|
||||
pip_start=[self.stimdelay],
|
||||
)
|
||||
for k in range(nsgc)
|
||||
]
|
||||
for k in range(len(self.stim[ear])):
|
||||
sgcCell[ear][k].set_sound_stim(
|
||||
self.stim[ear][k], seed=seed + i * seed + k, simulator=simulator
|
||||
)
|
||||
self["vm_bu_%s" % ear] = bushyCell[ear][0].soma(0.5)._ref_v
|
||||
for k in range(30):
|
||||
self["xmtr%d_%s" % (k, ear)] = synapse[ear][
|
||||
0
|
||||
].terminal.relsite._ref_XMTR[k]
|
||||
for k in range(len(synapse[ear])):
|
||||
synapse[ear][k].terminal.relsite.Dep_Flag = False # turn off depression
|
||||
|
||||
msoCell = cells.MSO.create(temperature=temp) # one target MSO cell
|
||||
msosyn = {}
|
||||
for ear in ears:
|
||||
msosyn[ear] = bushyCell[ear][0].connect(msoCell)
|
||||
self.sgc_cells = sgcCell
|
||||
self.bushy_cells = bushyCell
|
||||
self.synapses = synapse
|
||||
self.msyns = msosyn
|
||||
self.msoCell = msoCell
|
||||
self.all_cells = [] # hold all "real" cells (DummySGC does not have mechanisms)
|
||||
for ear in list(ears.keys()):
|
||||
self.all_cells.append([c for c in self.bushy_cells[ear]])
|
||||
self.all_cells.append([self.msoCell])
|
||||
|
||||
self["vm_mso"] = self.msoCell.soma(0.5)._ref_v
|
||||
for k, ear in enumerate(ears.keys()):
|
||||
for i in range(30):
|
||||
self["mso_xmtr%d_%s" % (i, ear)] = msosyn[
|
||||
ear
|
||||
].terminal.relsite._ref_XMTR[i]
|
||||
msosyn[ear].terminal.relsite.Dep_Flag = False # turn off depression
|
||||
|
||||
self["t"] = h._ref_t
|
||||
|
||||
h.tstop = self.rundur * 1e3 # duration of a run
|
||||
h.celsius = temp
|
||||
h.dt = dt
|
||||
|
||||
custom_init()
|
||||
# confirm that all cells are ok
|
||||
for cg in self.all_cells:
|
||||
for c in cg:
|
||||
c.check_all_mechs()
|
||||
while h.t < h.tstop:
|
||||
h.fadvance()
|
||||
|
||||
def show(self):
|
||||
self.win = pg.GraphicsWindow()
|
||||
|
||||
p5 = self.win.addPlot(title="stim")
|
||||
p5.plot(self.stim["left"][0].time * 1000.0, self.stim["left"][0].sound)
|
||||
|
||||
p1 = self.win.addPlot(title="Bushy Vm", row=1, col=0)
|
||||
for k, ear in enumerate(self.ears.keys()):
|
||||
p1.plot(self["t"], self["vm_bu_%s" % ear], pen=(k, 15))
|
||||
|
||||
p2 = self.win.addPlot(title="SGC-BU xmtr left", row=0, col=1)
|
||||
for i in range(30):
|
||||
p2.plot(self["t"], self["xmtr%d_left" % i], pen=(i, 15))
|
||||
p2.setXLink(p1)
|
||||
p2r = self.win.addPlot(title="SGC-BU xmtr right", row=1, col=1)
|
||||
for i in range(30):
|
||||
p2r.plot(self["t"], self["xmtr%d_right" % i], pen=(i, 15))
|
||||
p2r.setXLink(p1)
|
||||
|
||||
p3 = self.win.addPlot(title="MSO Vm", row=2, col=0)
|
||||
p3.plot(self["t"], self["vm_mso"])
|
||||
p3.setXLink(p1)
|
||||
|
||||
p4 = self.win.addPlot(title="BU-MSO xmtr", row=2, col=1)
|
||||
for k, ear in enumerate(self.ears.keys()):
|
||||
for i in range(30):
|
||||
p2.plot(self["t"], self["mso_xmtr%d_%s" % (i, ear)], pen=(i, 15))
|
||||
p4.setXLink(p1)
|
||||
|
||||
p4 = self.win.addPlot(title="AN spikes", row=3, col=0)
|
||||
ntrain = len(self.sgc_cells["left"])
|
||||
for k in range(ntrain):
|
||||
yr = [k / float(ntrain), (k + 0.8) / float(ntrain)]
|
||||
vt = pg.VTickGroup(
|
||||
self.sgc_cells["left"][k]._spiketrain, yrange=yr, pen=(k, 15)
|
||||
)
|
||||
p4.addItem(vt)
|
||||
p4.setXLink(p1)
|
||||
p5.setXLink(p1)
|
||||
|
||||
# phaselocking calculations
|
||||
phasewin = [self.stimdelay + 0.2 * self.stimdur, self.stimdelay + self.stimdur]
|
||||
msospk = PU.findspikes(self["t"], self["vm_mso"], -30.0)
|
||||
|
||||
spkin = msospk[np.where(msospk > phasewin[0] * 1e3)]
|
||||
spikesinwin = spkin[np.where(spkin <= phasewin[1] * 1e3)[0]]
|
||||
|
||||
# set freq for VS calculation
|
||||
f0 = self.f0
|
||||
fb = self.beatfreq
|
||||
vs = PU.vector_strength(spikesinwin, f0)
|
||||
|
||||
print(
|
||||
"MSO Vector Strength at %.1f: %7.3f, d=%.2f (us) Rayleigh: %7.3f p = %.3e n = %d"
|
||||
% (f0, vs["r"], vs["d"] * 1e6, vs["R"], vs["p"], vs["n"])
|
||||
)
|
||||
if fb > 0:
|
||||
vsb = PU.vector_strength(spikesinwin, fb)
|
||||
print(
|
||||
"MSO Vector Strength to beat at %.1f: %7.3f, d=%.2f (us) Rayleigh: %7.3f p = %.3e n = %d"
|
||||
% (fb, vsb["r"], vsb["d"] * 1e6, vsb["R"], vsb["p"], vsb["n"])
|
||||
)
|
||||
(hist, binedges) = np.histogram(vs["ph"])
|
||||
p6 = self.win.addPlot(title="VS", row=3, col=1)
|
||||
p6.plot(
|
||||
binedges, hist, stepMode=True, fillBrush=(100, 100, 255, 150), fillLevel=0
|
||||
)
|
||||
p6.setXRange(0.0, 2 * np.pi)
|
||||
|
||||
self.win.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
simulator = None
|
||||
if len(sys.argv) > 1:
|
||||
simulator = sys.argv[1]
|
||||
prot = MSOBinauralTest()
|
||||
prot.run(simulator=simulator)
|
||||
prot.show()
|
||||
|
||||
if sys.flags.interactive == 0:
|
||||
pg.QtGui.QApplication.exec_()
|
||||
704
examples/test_physiology.py
Normal file
704
examples/test_physiology.py
Normal file
@@ -0,0 +1,704 @@
|
||||
"""
|
||||
Test principal cell responses to tone pips of varying frequency and intensity.
|
||||
|
||||
This is an example of model construction from a very high level--we specify
|
||||
only which populations of cells are present and which ones should be connected.
|
||||
The population and cell classes take care of all the details of generating the
|
||||
network needed to support a small number of output cells.
|
||||
|
||||
Note: run time for this example can be very long. To speed things up, reduce
|
||||
n_frequencies or n_levels, or reduce the number of selected output cells (see
|
||||
cells_per_band).
|
||||
|
||||
"""
|
||||
|
||||
import os, sys, time
|
||||
from collections import OrderedDict
|
||||
import numpy as np
|
||||
import scipy.stats
|
||||
from neuron import h
|
||||
import pyqtgraph as pg
|
||||
import pyqtgraph.multiprocess as mp
|
||||
from pyqtgraph.Qt import QtGui, QtCore
|
||||
from cnmodel import populations
|
||||
from cnmodel.util import sound, random_seed
|
||||
from cnmodel.protocols import Protocol
|
||||
import timeit
|
||||
|
||||
|
||||
class CNSoundStim(Protocol):
|
||||
def __init__(self, seed, temp=34.0, dt=0.025, synapsetype="simple"):
|
||||
Protocol.__init__(self)
|
||||
|
||||
self.seed = seed
|
||||
self.temp = temp
|
||||
self.dt = dt
|
||||
# self.synapsetype = synapsetype # simple or multisite
|
||||
|
||||
# Seed now to ensure network generation is stable
|
||||
random_seed.set_seed(seed)
|
||||
# Create cell populations.
|
||||
# This creates a complete set of _virtual_ cells for each population. No
|
||||
# cells are instantiated at this point.
|
||||
self.sgc = populations.SGC(model="dummy")
|
||||
self.bushy = populations.Bushy()
|
||||
self.dstellate = populations.DStellate()
|
||||
self.tstellate = populations.TStellate()
|
||||
self.tuberculoventral = populations.Tuberculoventral()
|
||||
|
||||
pops = [
|
||||
self.sgc,
|
||||
self.dstellate,
|
||||
self.tuberculoventral,
|
||||
self.tstellate,
|
||||
self.bushy,
|
||||
]
|
||||
self.populations = OrderedDict([(pop.type, pop) for pop in pops])
|
||||
|
||||
# set synapse type to use in the sgc population - simple is fast, multisite is slower
|
||||
# (eventually, we could do this for all synapse types..)
|
||||
self.sgc._synapsetype = synapsetype
|
||||
|
||||
# Connect populations.
|
||||
# This only defines the connections between populations; no synapses are
|
||||
# created at this stage.
|
||||
self.sgc.connect(
|
||||
self.bushy, self.dstellate, self.tuberculoventral, self.tstellate
|
||||
)
|
||||
self.dstellate.connect(
|
||||
self.bushy, self.tstellate
|
||||
) # should connect to dstellate as well?
|
||||
self.tuberculoventral.connect(self.bushy, self.tstellate)
|
||||
self.tstellate.connect(self.bushy)
|
||||
|
||||
# Select cells to record from.
|
||||
# At this time, we actually instantiate the selected cells.
|
||||
|
||||
# Pick a single bushy cell near 16kHz, with medium-SR inputs
|
||||
bc = self.bushy.cells
|
||||
msr_cells = bc[bc["sgc_sr"] == 1] # filter for msr cells
|
||||
ind = np.argmin(np.abs(msr_cells["cf"] - 16e3)) # find the one closest to 16kHz
|
||||
cell_id = msr_cells[ind]["id"]
|
||||
self.bushy.create_cells([cell_id]) # instantiate just one cell
|
||||
|
||||
# Now create the supporting circuitry needed to drive the cells we selected.
|
||||
# At this time, cells are created in all populations and automatically
|
||||
# connected with synapses.
|
||||
self.bushy.resolve_inputs(depth=2)
|
||||
# self.tstellate.resolve_inputs(depth=2)
|
||||
# Note that using depth=2 indicates the level of recursion to use when
|
||||
# resolving inputs. For example, resolving inputs for the bushy cell population
|
||||
# (level 1) creates presynaptic cells in the dstellate population, and resolving
|
||||
# inputs for the dstellate population (level 2) creates presynaptic cells in the
|
||||
# sgc population.
|
||||
|
||||
def run(self, stim, seed):
|
||||
"""Run the network simulation with *stim* as the sound source and a unique
|
||||
*seed* used to configure the random number generators.
|
||||
"""
|
||||
self.reset()
|
||||
|
||||
# Generate 2 new seeds for the SGC spike generator and for the NEURON simulation
|
||||
rs = np.random.RandomState()
|
||||
rs.seed(self.seed ^ seed)
|
||||
seed1, seed2 = rs.randint(0, 2 ** 32, 2)
|
||||
random_seed.set_seed(seed1)
|
||||
self.sgc.set_seed(seed2)
|
||||
|
||||
self.sgc.set_sound_stim(stim, parallel=False)
|
||||
|
||||
# set up recording vectors
|
||||
for pop in self.bushy, self.dstellate, self.tstellate, self.tuberculoventral:
|
||||
for ind in pop.real_cells():
|
||||
cell = pop.get_cell(ind)
|
||||
self[cell] = cell.soma(0.5)._ref_v
|
||||
self["t"] = h._ref_t
|
||||
|
||||
h.tstop = stim.duration * 1000
|
||||
h.celsius = self.temp
|
||||
h.dt = self.dt
|
||||
|
||||
print("init..")
|
||||
self.custom_init()
|
||||
print("start..")
|
||||
last_update = time.time()
|
||||
while h.t < h.tstop:
|
||||
h.fadvance()
|
||||
now = time.time()
|
||||
if now - last_update > 1.0:
|
||||
print("%0.2f / %0.2f" % (h.t, h.tstop))
|
||||
last_update = now
|
||||
|
||||
# record vsoma and spike times for all cells
|
||||
vec = {}
|
||||
for k in self._vectors:
|
||||
v = self[k].copy()
|
||||
if k == "t":
|
||||
vec[k] = v
|
||||
continue
|
||||
spike_inds = np.argwhere((v[1:] > -20) & (v[:-1] <= -20))[:, 0]
|
||||
spikes = self["t"][spike_inds]
|
||||
pop = k.type
|
||||
cell_ind = getattr(self, pop).get_cell_index(k)
|
||||
vec[(pop, cell_ind)] = [v, spikes]
|
||||
|
||||
# record SGC spike trains
|
||||
for ind in self.sgc.real_cells():
|
||||
cell = self.sgc.get_cell(ind)
|
||||
vec[("sgc", ind)] = [None, cell._spiketrain]
|
||||
|
||||
return vec
|
||||
|
||||
|
||||
class NetworkSimDisplay(pg.QtGui.QSplitter):
|
||||
def __init__(self, prot, results, baseline, response):
|
||||
pg.QtGui.QSplitter.__init__(self, QtCore.Qt.Horizontal)
|
||||
self.selected_cell = None
|
||||
|
||||
self.prot = prot
|
||||
self.baseline = baseline # (start, stop)
|
||||
self.response = response # (start, stop)
|
||||
|
||||
self.ctrl = QtGui.QWidget()
|
||||
self.layout = pg.QtGui.QVBoxLayout()
|
||||
self.layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.ctrl.setLayout(self.layout)
|
||||
self.addWidget(self.ctrl)
|
||||
|
||||
self.nv = NetworkVisualizer(prot.populations)
|
||||
self.layout.addWidget(self.nv)
|
||||
self.nv.cell_selected.connect(self.nv_cell_selected)
|
||||
|
||||
self.stim_combo = pg.QtGui.QComboBox()
|
||||
self.layout.addWidget(self.stim_combo)
|
||||
self.trial_combo = pg.QtGui.QComboBox()
|
||||
self.layout.addWidget(self.trial_combo)
|
||||
self.results = OrderedDict()
|
||||
self.stim_order = []
|
||||
freqs = set()
|
||||
levels = set()
|
||||
max_iter = 0
|
||||
for k, v in list(results.items()):
|
||||
f0, dbspl, iteration = k
|
||||
max_iter = max(max_iter, iteration)
|
||||
stim, result = v
|
||||
key = "f0: %0.0f dBspl: %0.0f" % (f0, dbspl)
|
||||
self.results.setdefault(key, [stim, {}])
|
||||
self.results[key][1][iteration] = result
|
||||
self.stim_order.append((f0, dbspl))
|
||||
freqs.add(f0)
|
||||
levels.add(dbspl)
|
||||
self.stim_combo.addItem(key)
|
||||
self.freqs = sorted(list(freqs))
|
||||
self.levels = sorted(list(levels))
|
||||
self.iterations = max_iter + 1
|
||||
self.trial_combo.addItem("all trials")
|
||||
for i in range(self.iterations):
|
||||
self.trial_combo.addItem(str(i))
|
||||
|
||||
self.stim_combo.currentIndexChanged.connect(self.stim_selected)
|
||||
self.trial_combo.currentIndexChanged.connect(self.trial_selected)
|
||||
|
||||
self.tuning_plot = pg.PlotWidget()
|
||||
self.tuning_plot.setLogMode(x=True, y=False)
|
||||
self.tuning_plot.scene().sigMouseClicked.connect(self.tuning_plot_clicked)
|
||||
self.layout.addWidget(self.tuning_plot)
|
||||
|
||||
self.tuning_img = pg.ImageItem()
|
||||
self.tuning_plot.addItem(self.tuning_img)
|
||||
|
||||
df = np.log10(self.freqs[1]) - np.log10(self.freqs[0])
|
||||
dl = self.levels[1] - self.levels[0]
|
||||
self.stim_rect = QtGui.QGraphicsRectItem(QtCore.QRectF(0, 0, df, dl))
|
||||
self.stim_rect.setPen(pg.mkPen("c"))
|
||||
self.stim_rect.setZValue(20)
|
||||
self.tuning_plot.addItem(self.stim_rect)
|
||||
|
||||
# self.network_tree = NetworkTree(self.prot)
|
||||
# self.layout.addWidget(self.network_tree)
|
||||
|
||||
self.pw = pg.GraphicsLayoutWidget()
|
||||
self.addWidget(self.pw)
|
||||
|
||||
self.stim_plot = self.pw.addPlot()
|
||||
self.pw.ci.layout.setRowFixedHeight(0, 100)
|
||||
|
||||
self.pw.nextRow()
|
||||
self.cell_plot = self.pw.addPlot(labels={"left": "Vm"})
|
||||
|
||||
self.pw.nextRow()
|
||||
self.input_plot = self.pw.addPlot(
|
||||
labels={"left": "input #", "bottom": "time"}, title="Input spike times"
|
||||
)
|
||||
self.input_plot.setXLink(self.cell_plot)
|
||||
self.stim_plot.setXLink(self.cell_plot)
|
||||
|
||||
self.stim_selected()
|
||||
|
||||
def update_stim_plot(self):
|
||||
stim = self.selected_stim
|
||||
self.stim_plot.plot(stim.time * 1000, stim.sound, clear=True, antialias=True)
|
||||
|
||||
def update_raster_plot(self):
|
||||
self.input_plot.clear()
|
||||
if self.selected_cell is None:
|
||||
return
|
||||
pop, ind = self.selected_cell
|
||||
|
||||
rec = pop._cells[ind]
|
||||
i = 0
|
||||
plots = []
|
||||
# plot spike times for all presynaptic cells
|
||||
labels = []
|
||||
if rec["connections"] == 0:
|
||||
return
|
||||
|
||||
pop_colors = {
|
||||
"dstellate": "y",
|
||||
"tuberculoventral": "r",
|
||||
"sgc": "g",
|
||||
"tstellate": "b",
|
||||
}
|
||||
pop_symbols = {
|
||||
"dstellate": "x",
|
||||
"tuberculoventral": "+",
|
||||
"sgc": "t",
|
||||
"tstellate": "o",
|
||||
}
|
||||
pop_order = [self.prot.sgc, self.prot.dstellate, self.prot.tuberculoventral]
|
||||
trials = self.selected_trials()
|
||||
for pop in pop_order:
|
||||
pre_inds = rec["connections"].get(pop, [])
|
||||
for preind in pre_inds:
|
||||
# iterate over all trials
|
||||
for j in trials:
|
||||
result = self.selected_results[j]
|
||||
spikes = result[(pop.type, preind)][1]
|
||||
y = np.ones(len(spikes)) * i + j / (
|
||||
2.0 * len(self.selected_results)
|
||||
)
|
||||
self.input_plot.plot(
|
||||
spikes,
|
||||
y,
|
||||
pen=None,
|
||||
symbolBrush=pop_colors[pop.type],
|
||||
symbol="+",
|
||||
symbolPen=None,
|
||||
)
|
||||
i += 1
|
||||
labels.append(pop.type + " " + str(preind))
|
||||
self.input_plot.getAxis("left").setTicks([list(enumerate(labels))])
|
||||
|
||||
def update_cell_plot(self):
|
||||
self.cell_plot.clear()
|
||||
if self.selected_cell is None:
|
||||
return
|
||||
pop, cell_ind = self.selected_cell
|
||||
|
||||
self.cell_plot.setTitle(
|
||||
"%s %d %s" % (pop.type, cell_ind, str(self.stim_combo.currentText()))
|
||||
)
|
||||
trials = self.selected_trials()
|
||||
for i in trials:
|
||||
result = self.selected_results[i]
|
||||
y = result[(pop.type, cell_ind)][0]
|
||||
if y is not None:
|
||||
p = self.cell_plot.plot(
|
||||
self.selected_results[0]["t"],
|
||||
y,
|
||||
name="%s-%d" % self.selected_cell,
|
||||
antialias=True,
|
||||
pen=(i, len(self.selected_results) * 1.5),
|
||||
)
|
||||
# p.curve.setClickable(True)
|
||||
# p.sigClicked.connect(self.cell_curve_clicked)
|
||||
# p.cell_ind = ind
|
||||
|
||||
def tuning_plot_clicked(self, event):
|
||||
spos = event.scenePos()
|
||||
stimpos = self.tuning_plot.plotItem.vb.mapSceneToView(spos)
|
||||
x = 10 ** stimpos.x()
|
||||
y = stimpos.y()
|
||||
|
||||
best = None
|
||||
for stim, result in list(self.results.values()):
|
||||
f0 = stim.opts["f0"]
|
||||
dbspl = stim.opts["dbspl"]
|
||||
if x < f0 or y < dbspl:
|
||||
continue
|
||||
if best is None:
|
||||
best = stim
|
||||
continue
|
||||
if f0 > best.opts["f0"] or dbspl > best.opts["dbspl"]:
|
||||
best = stim
|
||||
continue
|
||||
|
||||
if best is None:
|
||||
return
|
||||
self.select_stim(best.opts["f0"], best.opts["dbspl"])
|
||||
|
||||
def nv_cell_selected(self, nv, cell):
|
||||
self.select_cell(*cell)
|
||||
|
||||
def stim_selected(self):
|
||||
key = str(self.stim_combo.currentText())
|
||||
results = self.results[key]
|
||||
self.selected_results = results[1]
|
||||
self.selected_stim = results[0]
|
||||
self.update_stim_plot()
|
||||
self.update_raster_plot()
|
||||
self.update_cell_plot()
|
||||
|
||||
self.stim_rect.setPos(np.log10(results[0].opts["f0"]), results[0].opts["dbspl"])
|
||||
|
||||
def trial_selected(self):
|
||||
self.update_raster_plot()
|
||||
self.update_cell_plot()
|
||||
self.update_tuning()
|
||||
|
||||
def selected_trials(self):
|
||||
if self.trial_combo.currentIndex() == 0:
|
||||
return list(range(self.iterations))
|
||||
else:
|
||||
return [self.trial_combo.currentIndex() - 1]
|
||||
|
||||
def select_stim(self, f0, dbspl):
|
||||
i = self.stim_order.index((f0, dbspl))
|
||||
self.stim_combo.setCurrentIndex(i)
|
||||
|
||||
def select_cell(self, pop, cell_id):
|
||||
self.selected_cell = pop, cell_id
|
||||
self.update_tuning()
|
||||
self.update_cell_plot()
|
||||
self.update_raster_plot()
|
||||
|
||||
# def cell_curve_clicked(self, c):
|
||||
# if self.selected is not None:
|
||||
# pen = self.selected.curve.opts['pen']
|
||||
# pen.setWidth(1)
|
||||
# self.selected.setPen(pen)
|
||||
|
||||
# pen = c.curve.opts['pen']
|
||||
# pen.setWidth(3)
|
||||
# c.setPen(pen)
|
||||
# self.selected = c
|
||||
|
||||
# self.show_cell(c.cell_ind)
|
||||
|
||||
def update_tuning(self):
|
||||
# update matrix image
|
||||
if self.selected_cell is None:
|
||||
return
|
||||
|
||||
pop, ind = self.selected_cell
|
||||
fvals = set()
|
||||
lvals = set()
|
||||
|
||||
# first get lists of all frequencies and levels in the matrix
|
||||
for stim, vec in list(self.results.values()):
|
||||
fvals.add(stim.key()["f0"])
|
||||
lvals.add(stim.key()["dbspl"])
|
||||
fvals = sorted(list(fvals))
|
||||
lvals = sorted(list(lvals))
|
||||
|
||||
# Get spontaneous rate statistics
|
||||
spont_spikes = 0
|
||||
spont_time = 0
|
||||
for stim, iterations in list(self.results.values()):
|
||||
for vec in list(iterations.values()):
|
||||
spikes = vec[(pop.type, ind)][1]
|
||||
spont_spikes += (
|
||||
(spikes >= self.baseline[0]) & (spikes < self.baseline[1])
|
||||
).sum()
|
||||
spont_time += self.baseline[1] - self.baseline[0]
|
||||
spont_rate = spont_spikes / spont_time
|
||||
|
||||
# next count the number of spikes for the selected cell at each point in the matrix
|
||||
matrix = np.zeros((len(fvals), len(lvals)))
|
||||
trials = self.selected_trials()
|
||||
for stim, iteration in list(self.results.values()):
|
||||
for i in trials:
|
||||
vec = iteration[i]
|
||||
spikes = vec[(pop.type, ind)][1]
|
||||
n_spikes = (
|
||||
(spikes >= self.response[0]) & (spikes < self.response[1])
|
||||
).sum()
|
||||
i = fvals.index(stim.key()["f0"])
|
||||
j = lvals.index(stim.key()["dbspl"])
|
||||
matrix[i, j] += n_spikes - spont_rate * (
|
||||
self.response[1] - self.response[0]
|
||||
)
|
||||
matrix /= self.iterations
|
||||
|
||||
# plot and scale the matrix image
|
||||
# note that the origin (lower left) of each image pixel indicates its actual test freq/level.
|
||||
self.tuning_img.setImage(matrix)
|
||||
self.tuning_img.resetTransform()
|
||||
self.tuning_img.setPos(np.log10(min(fvals)), min(lvals))
|
||||
self.tuning_img.scale(
|
||||
(np.log10(max(fvals)) - np.log10(min(fvals))) / (len(fvals) - 1),
|
||||
(max(lvals) - min(lvals)) / (len(lvals) - 1),
|
||||
)
|
||||
|
||||
|
||||
class NetworkTree(QtGui.QTreeWidget):
|
||||
def __init__(self, prot):
|
||||
self.prot = prot
|
||||
QtGui.QTreeWidget.__init__(self)
|
||||
self.setColumnCount(2)
|
||||
|
||||
self.update_tree()
|
||||
|
||||
def update_tree(self):
|
||||
for pop_name in ["bushy", "tstellate", "dstellate", "tuberculoventral", "sgc"]:
|
||||
if not hasattr(self.prot, pop_name):
|
||||
continue
|
||||
pop = getattr(self.prot, pop_name)
|
||||
grp = QtGui.QTreeWidgetItem([pop_name])
|
||||
self.addTopLevelItem(grp)
|
||||
for cell in pop.real_cells():
|
||||
self.add_cell(grp, pop, cell)
|
||||
|
||||
def add_cell(self, grp_item, pop, cell):
|
||||
item = QtGui.QTreeWidgetItem([str(cell)])
|
||||
grp_item.addChild(item)
|
||||
all_conns = pop.cell_connections(cell)
|
||||
if all_conns == 0:
|
||||
return
|
||||
for cpop, conns in list(all_conns.items()):
|
||||
pop_grp = QtGui.QTreeWidgetItem([cpop.type, str(conns)])
|
||||
item.addChild(pop_grp)
|
||||
|
||||
|
||||
class NetworkVisualizer(pg.PlotWidget):
|
||||
|
||||
cell_selected = pg.QtCore.Signal(object, object)
|
||||
|
||||
def __init__(self, populations):
|
||||
self.pops = populations
|
||||
pg.PlotWidget.__init__(self)
|
||||
self.setLogMode(x=True, y=False)
|
||||
|
||||
self.cells = pg.ScatterPlotItem(clickable=True)
|
||||
self.cells.setZValue(10)
|
||||
self.addItem(self.cells)
|
||||
self.cells.sigClicked.connect(self.cells_clicked)
|
||||
|
||||
self.selected = pg.ScatterPlotItem()
|
||||
self.selected.setZValue(20)
|
||||
self.addItem(self.selected)
|
||||
|
||||
self.connections = pg.PlotCurveItem()
|
||||
self.addItem(self.connections)
|
||||
|
||||
# first assign positions of all cells
|
||||
cells = []
|
||||
for y, pop in enumerate(self.pops.values()):
|
||||
pop.cell_spots = []
|
||||
pop.fwd_connections = {}
|
||||
for i, cell in enumerate(pop._cells):
|
||||
pos = (np.log10(cell["cf"]), y)
|
||||
real = cell["cell"] != 0
|
||||
if not real:
|
||||
pop.cell_spots.append(None)
|
||||
continue
|
||||
brush = pg.mkBrush("b") if real else pg.mkBrush(255, 255, 255, 30)
|
||||
spot = {
|
||||
"x": pos[0],
|
||||
"y": pos[1],
|
||||
"symbol": "o" if real else "x",
|
||||
"brush": brush,
|
||||
"pen": None,
|
||||
"data": (pop, i),
|
||||
}
|
||||
cells.append(spot)
|
||||
pop.cell_spots.append(spot)
|
||||
|
||||
self.cells.setData(cells)
|
||||
|
||||
self.getAxis("left").setTicks([list(enumerate(self.pops.keys()))])
|
||||
|
||||
# now assign connection lines and record forward connectivity
|
||||
con_x = []
|
||||
con_y = []
|
||||
for pop in list(self.pops.values()):
|
||||
for i, cell in enumerate(pop._cells):
|
||||
conns = cell["connections"]
|
||||
if conns == 0:
|
||||
continue
|
||||
for prepop, precells in list(conns.items()):
|
||||
spot = pop.cell_spots[i]
|
||||
if spot is None:
|
||||
continue
|
||||
p1 = spot["x"], spot["y"]
|
||||
for j in precells:
|
||||
prepop.fwd_connections.setdefault(j, [])
|
||||
prepop.fwd_connections[j].append((pop, i))
|
||||
spot2 = prepop.cell_spots[j]
|
||||
if spot2 is None:
|
||||
return
|
||||
p2 = spot2["x"], spot2["y"]
|
||||
con_x.extend([p1[0], p2[0]])
|
||||
con_y.extend([p1[1], p2[1]])
|
||||
self.connections.setData(
|
||||
x=con_x, y=con_y, connect="pairs", pen=(255, 255, 255, 60)
|
||||
)
|
||||
|
||||
def cells_clicked(self, *args):
|
||||
selected = None
|
||||
for spot in args[1]:
|
||||
# find the first real cell
|
||||
pop, i = spot.data()
|
||||
if pop._cells[i]["cell"] != 0:
|
||||
selected = spot
|
||||
break
|
||||
if selected is None:
|
||||
self.selected.hide()
|
||||
return
|
||||
|
||||
rec = pop._cells[i]
|
||||
pos = selected.pos()
|
||||
spots = [
|
||||
{
|
||||
"x": pos.x(),
|
||||
"y": pos.y(),
|
||||
"size": 15,
|
||||
"symbol": "o",
|
||||
"pen": "y",
|
||||
"brush": "b",
|
||||
}
|
||||
]
|
||||
|
||||
# display presynaptic cells
|
||||
if rec["connections"] != 0:
|
||||
for prepop, preinds in list(rec["connections"].items()):
|
||||
for preind in preinds:
|
||||
spot = prepop.cell_spots[preind].copy()
|
||||
spot["size"] = 15
|
||||
spot["brush"] = "r"
|
||||
spots.append(spot)
|
||||
|
||||
# display postsynaptic cells
|
||||
for postpop, postind in pop.fwd_connections.get(i, []):
|
||||
spot = postpop.cell_spots[postind].copy()
|
||||
spot["size"] = 15
|
||||
spot["brush"] = "g"
|
||||
spots.append(spot)
|
||||
|
||||
self.selected.setData(spots)
|
||||
self.selected.show()
|
||||
|
||||
self.cell_selected.emit(self, selected.data())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import pickle, os, sys
|
||||
|
||||
app = pg.mkQApp()
|
||||
pg.dbg()
|
||||
|
||||
# Create a sound stimulus and use it to generate spike trains for the SGC
|
||||
# population
|
||||
stims = []
|
||||
parallel = True
|
||||
|
||||
nreps = 5
|
||||
fmin = 4e3
|
||||
fmax = 32e3
|
||||
octavespacing = 1 / 8.0
|
||||
# octavespacing = 1.
|
||||
n_frequencies = int(np.log2(fmax / fmin) / octavespacing) + 1
|
||||
fvals = (
|
||||
np.logspace(
|
||||
np.log2(fmin / 1000.0),
|
||||
np.log2(fmax / 1000.0),
|
||||
num=n_frequencies,
|
||||
endpoint=True,
|
||||
base=2,
|
||||
)
|
||||
* 1000.0
|
||||
)
|
||||
|
||||
n_levels = 11
|
||||
# n_levels = 3
|
||||
levels = np.linspace(20, 100, n_levels)
|
||||
|
||||
print(("Frequencies:", fvals / 1000.0))
|
||||
print(("Levels:", levels))
|
||||
|
||||
syntype = "multisite"
|
||||
path = os.path.dirname(__file__)
|
||||
cachepath = os.path.join(path, "cache")
|
||||
if not os.path.isdir(cachepath):
|
||||
os.mkdir(cachepath)
|
||||
|
||||
seed = 34657845
|
||||
prot = CNSoundStim(seed=seed, synapsetype=syntype)
|
||||
i = 0
|
||||
|
||||
start_time = timeit.default_timer()
|
||||
|
||||
# stimpar = {'dur': 0.06, 'pip': 0.025, 'start': [0.02], 'baseline': [10, 20], 'response': [20, 45]}
|
||||
stimpar = {
|
||||
"dur": 0.2,
|
||||
"pip": 0.04,
|
||||
"start": [0.1],
|
||||
"baseline": [50, 100],
|
||||
"response": [100, 140],
|
||||
}
|
||||
tasks = []
|
||||
for f in fvals:
|
||||
for db in levels:
|
||||
for i in range(nreps):
|
||||
tasks.append((f, db, i))
|
||||
|
||||
results = {}
|
||||
workers = 1 if not parallel else None
|
||||
tot_runs = len(fvals) * len(levels) * nreps
|
||||
with mp.Parallelize(
|
||||
enumerate(tasks),
|
||||
results=results,
|
||||
progressDialog="Running parallel simulation..",
|
||||
workers=workers,
|
||||
) as tasker:
|
||||
for i, task in tasker:
|
||||
f, db, iteration = task
|
||||
stim = sound.TonePip(
|
||||
rate=100e3,
|
||||
duration=stimpar["dur"],
|
||||
f0=f,
|
||||
dbspl=db, # dura 0.2, pip_start 0.1 pipdur 0.04
|
||||
ramp_duration=2.5e-3,
|
||||
pip_duration=stimpar["pip"],
|
||||
pip_start=stimpar["start"],
|
||||
)
|
||||
|
||||
print(("=== Start run %d/%d ===" % (i + 1, tot_runs)))
|
||||
cachefile = os.path.join(
|
||||
cachepath,
|
||||
"seed=%d_f0=%f_dbspl=%f_syntype=%s_iter=%d.pk"
|
||||
% (seed, f, db, syntype, iteration),
|
||||
)
|
||||
if "--ignore-cache" in sys.argv or not os.path.isfile(cachefile):
|
||||
result = prot.run(stim, seed=i)
|
||||
pickle.dump(result, open(cachefile, "wb"))
|
||||
else:
|
||||
print(" (Loading cached results)")
|
||||
result = pickle.load(open(cachefile, "rb"))
|
||||
tasker.results[(f, db, iteration)] = (stim, result)
|
||||
print(("--- finished run %d/%d ---" % (i + 1, tot_runs)))
|
||||
|
||||
# get time of run before display
|
||||
elapsed = timeit.default_timer() - start_time
|
||||
print(
|
||||
"Elapsed time for %d stimuli: %f (%f sec per stim), synapses: %s"
|
||||
% (len(tasks), elapsed, elapsed / len(tasks), prot.bushy._synapsetype)
|
||||
)
|
||||
|
||||
nd = NetworkSimDisplay(
|
||||
prot, results, baseline=stimpar["baseline"], response=stimpar["response"]
|
||||
)
|
||||
nd.show()
|
||||
|
||||
if sys.flags.interactive == 0:
|
||||
pg.QtGui.QApplication.exec_()
|
||||
59
examples/test_populations.py
Normal file
59
examples/test_populations.py
Normal file
@@ -0,0 +1,59 @@
|
||||
"""
|
||||
Test connection between two cell populations.
|
||||
|
||||
Usage: python test_populations.py <pre_celltype> <post_celltype>
|
||||
|
||||
This script:
|
||||
|
||||
1. Creates two cell populations (pop1 and pop2)
|
||||
2. Connects pop1 => pop2
|
||||
3. Instantiates a single cell in pop2
|
||||
4. Automatically generates presynaptic cells and synapses from pop1
|
||||
5. Stimulates presynaptic cells and records postsynaptically
|
||||
|
||||
This is a high-level approach to generating networks in that the supporting
|
||||
cells (those in pop1) are created automatically based on expected patterns
|
||||
of connectivity in the cochlear nucleus. A lower-level approach is demonstrated
|
||||
in test_synapses.py, in which the individual pre- and postsynaptic cells are
|
||||
manually created and connected.
|
||||
"""
|
||||
from cnmodel import populations
|
||||
from cnmodel.protocols import PopulationTest
|
||||
import pyqtgraph as pg
|
||||
import sys
|
||||
|
||||
|
||||
def testpopulation():
|
||||
if len(sys.argv) < 3:
|
||||
print("Usage: python test_populations.py <pre_celltype> <post_celltype>")
|
||||
sys.exit(1)
|
||||
|
||||
pop_types = {
|
||||
"sgc": populations.SGC,
|
||||
"bushy": populations.Bushy,
|
||||
"tstellate": populations.TStellate,
|
||||
"dstellate": populations.DStellate,
|
||||
"pyramidal": populations.Pyramidal,
|
||||
"tuberculoventral": populations.Tuberculoventral,
|
||||
}
|
||||
|
||||
pops = []
|
||||
for cell_type in sys.argv[1:3]:
|
||||
if cell_type not in pop_types:
|
||||
print(
|
||||
'\nUnsupported cell type: "%s". Options are %s'
|
||||
% (cell_type, list(pop_types.keys()))
|
||||
)
|
||||
sys.exit(-1)
|
||||
pops.append(pop_types[cell_type]())
|
||||
|
||||
pt = PopulationTest()
|
||||
pt.run(pops)
|
||||
pt.show()
|
||||
|
||||
if sys.flags.interactive == 0:
|
||||
pg.QtGui.QApplication.exec_()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
testpopulation()
|
||||
96
examples/test_sgc_input.py
Normal file
96
examples/test_sgc_input.py
Normal file
@@ -0,0 +1,96 @@
|
||||
"""
|
||||
Test generating a series of EPSPs in a bushy cell in response to tone pip.
|
||||
|
||||
This script:
|
||||
|
||||
1. Creates one SGC and one bushy cell.
|
||||
2. Connects the two cells with a synapse.
|
||||
3. Specifies a tone pip input to the SGC cell.
|
||||
4. Records the bushy cell Vm.
|
||||
|
||||
The auditory nerve spike train is generated automatically by the DummySGC class
|
||||
using the tone pip. For lower-level access to the auditory nerve model, see the
|
||||
test_an_model.py and test_sound_stim.py examples.
|
||||
|
||||
The simulator that is run depends on what is available and how the script is called.
|
||||
python examples/test_sgc_input.py [cochlea | matlab] will try to use the specified
|
||||
simulator. If no simulator is specified, it will try to use cochlea or matlab, in
|
||||
that order.
|
||||
|
||||
"""
|
||||
import sys
|
||||
import numpy as np
|
||||
import pyqtgraph as pg
|
||||
from neuron import h
|
||||
from cnmodel.protocols import Protocol
|
||||
from cnmodel import cells
|
||||
from cnmodel.util import sound
|
||||
from cnmodel.util import custom_init
|
||||
|
||||
|
||||
class SGCInputTest(Protocol):
|
||||
def run(self, temp=34.0, dt=0.025, seed=575982035, simulator=None):
|
||||
preCell = cells.DummySGC(cf=4000, sr=2)
|
||||
postCell = cells.Bushy.create()
|
||||
synapse = preCell.connect(postCell)
|
||||
self.pre_cell = preCell
|
||||
self.post_cell = postCell
|
||||
self.synapse = synapse
|
||||
|
||||
self.stim = sound.TonePip(
|
||||
rate=100e3,
|
||||
duration=0.1,
|
||||
f0=4000,
|
||||
dbspl=80,
|
||||
ramp_duration=2.5e-3,
|
||||
pip_duration=0.04,
|
||||
pip_start=[0.02],
|
||||
)
|
||||
|
||||
preCell.set_sound_stim(self.stim, seed=seed, simulator=simulator)
|
||||
|
||||
self["vm"] = postCell.soma(0.5)._ref_v
|
||||
# self['prevm'] = preCell.soma(0.5)._ref_v
|
||||
for i in range(30):
|
||||
self["xmtr%d" % i] = synapse.terminal.relsite._ref_XMTR[i]
|
||||
synapse.terminal.relsite.Dep_Flag = False
|
||||
self["t"] = h._ref_t
|
||||
|
||||
h.tstop = 100.0 # duration of a run
|
||||
h.celsius = temp
|
||||
h.dt = dt
|
||||
|
||||
custom_init()
|
||||
h.run()
|
||||
|
||||
def show(self):
|
||||
self.win = pg.GraphicsWindow()
|
||||
|
||||
p1 = self.win.addPlot(title="Bushy Vm")
|
||||
p1.plot(self["t"], self["vm"])
|
||||
p2 = self.win.addPlot(title="xmtr", row=1, col=0)
|
||||
for i in range(30):
|
||||
p2.plot(self["t"], self["xmtr%d" % i], pen=(i, 15))
|
||||
p2.setXLink(p1)
|
||||
|
||||
p3 = self.win.addPlot(title="AN spikes", row=2, col=0)
|
||||
vt = pg.VTickGroup(self.pre_cell._spiketrain)
|
||||
p3.addItem(vt)
|
||||
p3.setXLink(p1)
|
||||
|
||||
p4 = self.win.addPlot(title="stim", row=3, col=0)
|
||||
p4.plot(self.stim.time * 1000, self.stim.sound)
|
||||
p4.setXLink(p1)
|
||||
self.win.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
simulator = None
|
||||
if len(sys.argv) > 1:
|
||||
simulator = sys.argv[1]
|
||||
prot = SGCInputTest()
|
||||
prot.run(simulator=simulator)
|
||||
prot.show()
|
||||
|
||||
if sys.flags.interactive == 0:
|
||||
pg.QtGui.QApplication.exec_()
|
||||
431
examples/test_sgc_input_PSTH.py
Normal file
431
examples/test_sgc_input_PSTH.py
Normal file
@@ -0,0 +1,431 @@
|
||||
import sys
|
||||
import argparse
|
||||
import numpy as np
|
||||
import pyqtgraph as pg
|
||||
from neuron import h
|
||||
from cnmodel.protocols import Protocol
|
||||
from cnmodel import cells
|
||||
from cnmodel.util import sound
|
||||
from cnmodel.util import custom_init
|
||||
import cnmodel.util.pynrnutilities as PU
|
||||
from cnmodel import data
|
||||
|
||||
species = "mouse" # tables for other species do not yet exist
|
||||
|
||||
|
||||
def runTrial(cell, info):
|
||||
"""
|
||||
info is a dict
|
||||
"""
|
||||
if cell == "bushy":
|
||||
post_cell = cells.Bushy.create(species=species)
|
||||
elif cell == "tstellate":
|
||||
post_cell = cells.TStellate.create(species=species)
|
||||
elif cell == "octopus":
|
||||
post_cell = cells.Octopus.create(species=species)
|
||||
elif cell == "dstellate":
|
||||
post_cell = cells.DStellate.create(species=species)
|
||||
elif cell == "tuberculoventral":
|
||||
post_cell = cells.DStellate.create(species=species)
|
||||
elif cell == "pyramidal":
|
||||
post_cell = cells.DStellate.create(species=species)
|
||||
else:
|
||||
raise ValueError("cell %s is not yet implemented for PSTH testing" % self.cell)
|
||||
pre_cells = []
|
||||
synapses = []
|
||||
j = 0
|
||||
xmtr = {}
|
||||
for nsgc, sgc in enumerate(range(info["n_sgc"])):
|
||||
pre_cells.append(cells.DummySGC(cf=info["cf"], sr=info["sr"]))
|
||||
if synapseType == "simple":
|
||||
synapses.append(pre_cells[-1].connect(post_cell, type=synapseType))
|
||||
synapses[-1].terminal.netcon.weight[0] = info["gmax"]
|
||||
elif synapseType == "multisite":
|
||||
synapses.append(
|
||||
pre_cells[-1].connect(
|
||||
post_cell,
|
||||
post_opts={"AMPAScale": 1.0, "NMDAScale": 1.0},
|
||||
type=synapseType,
|
||||
)
|
||||
)
|
||||
for i in range(synapses[-1].terminal.n_rzones):
|
||||
xmtr["xmtr%04d" % j] = h.Vector()
|
||||
xmtr["xmtr%04d" % j].record(synapses[-1].terminal.relsite._ref_XMTR[i])
|
||||
j = j + 1
|
||||
synapses[
|
||||
-1
|
||||
].terminal.relsite.Dep_Flag = False # no depression in these simulations
|
||||
pre_cells[-1].set_sound_stim(
|
||||
info["stim"], seed=info["seed"] + nsgc, simulator=info["simulator"]
|
||||
)
|
||||
Vm = h.Vector()
|
||||
Vm.record(post_cell.soma(0.5)._ref_v)
|
||||
rtime = h.Vector()
|
||||
rtime.record(h._ref_t)
|
||||
h.tstop = 1e3 * info["run_duration"] # duration of a run
|
||||
h.celsius = info["temp"]
|
||||
h.dt = info["dt"]
|
||||
post_cell.cell_initialize()
|
||||
info["init"]()
|
||||
h.t = 0.0
|
||||
h.run()
|
||||
return {
|
||||
"time": np.array(rtime),
|
||||
"vm": Vm.to_python(),
|
||||
"xmtr": xmtr,
|
||||
"pre_cells": pre_cells,
|
||||
"post_cell": post_cell,
|
||||
"synapses": synapses,
|
||||
}
|
||||
|
||||
|
||||
class SGCInputTestPSTH(Protocol):
|
||||
def set_cell(self, cell="bushy"):
|
||||
self.cell = cell
|
||||
|
||||
def run(
|
||||
self,
|
||||
temp=34.0,
|
||||
dt=0.025,
|
||||
seed=575982035,
|
||||
reps=10,
|
||||
stimulus="tone",
|
||||
simulator="cochlea",
|
||||
parallelize=False,
|
||||
):
|
||||
assert stimulus in ["tone", "SAM", "clicks"] # cases available
|
||||
assert self.cell in [
|
||||
"bushy",
|
||||
"tstellate",
|
||||
"octopus",
|
||||
"dstellate",
|
||||
"tuberculoventral",
|
||||
"pyramidal",
|
||||
]
|
||||
self.nrep = reps
|
||||
self.stimulus = stimulus
|
||||
self.run_duration = 0.20 # in seconds
|
||||
self.pip_duration = 0.05 # in seconds
|
||||
self.pip_start = [0.1] # in seconds
|
||||
self.Fs = 100e3 # in Hz
|
||||
self.f0 = 4000.0 # stimulus in Hz
|
||||
self.cf = 4000.0 # SGCs in Hz
|
||||
self.fMod = 100.0 # mod freq, Hz
|
||||
self.dMod = 0.0 # % mod depth, Hz
|
||||
self.dbspl = 50.0
|
||||
self.simulator = simulator
|
||||
self.sr = 2 # set SR group
|
||||
if self.stimulus == "SAM":
|
||||
self.dMod = 100.0
|
||||
self.stim = sound.SAMTone(
|
||||
rate=self.Fs,
|
||||
duration=self.run_duration,
|
||||
f0=self.f0,
|
||||
fmod=self.fMod,
|
||||
dmod=self.dMod,
|
||||
dbspl=self.dbspl,
|
||||
ramp_duration=2.5e-3,
|
||||
pip_duration=self.pip_duration,
|
||||
pip_start=self.pip_start,
|
||||
)
|
||||
if self.stimulus == "tone":
|
||||
self.f0 = 4000.0
|
||||
self.cf = 4000.0
|
||||
self.stim = sound.TonePip(
|
||||
rate=self.Fs,
|
||||
duration=self.run_duration,
|
||||
f0=self.f0,
|
||||
dbspl=self.dbspl,
|
||||
ramp_duration=2.5e-3,
|
||||
pip_duration=self.pip_duration,
|
||||
pip_start=self.pip_start,
|
||||
)
|
||||
|
||||
if self.stimulus == "clicks":
|
||||
self.click_rate = 0.020 # msec
|
||||
self.stim = sound.ClickTrain(
|
||||
rate=self.Fs,
|
||||
duration=self.run_duration,
|
||||
f0=self.f0,
|
||||
dbspl=self.dbspl,
|
||||
click_start=0.010,
|
||||
click_duration=100.0e-6,
|
||||
click_interval=self.click_rate,
|
||||
nclicks=int((self.run_duration - 0.01) / self.click_rate),
|
||||
ramp_duration=2.5e-3,
|
||||
)
|
||||
|
||||
n_sgc = data.get(
|
||||
"convergence", species=species, post_type=self.cell, pre_type="sgc"
|
||||
)[0]
|
||||
self.n_sgc = int(np.round(n_sgc))
|
||||
# for simple synapses, need this value:
|
||||
self.AMPA_gmax = (
|
||||
data.get(
|
||||
"sgc_synapse", species=species, post_type=self.cell, field="AMPA_gmax"
|
||||
)[0]
|
||||
/ 1e3
|
||||
) # convert nS to uS for NEURON
|
||||
self.vms = [None for n in range(self.nrep)]
|
||||
self.synapses = [None for n in range(self.nrep)]
|
||||
self.xmtrs = [None for n in range(self.nrep)]
|
||||
self.pre_cells = [None for n in range(self.nrep)]
|
||||
self.time = [None for n in range(self.nrep)]
|
||||
info = {
|
||||
"n_sgc": self.n_sgc,
|
||||
"gmax": self.AMPA_gmax,
|
||||
"stim": self.stim,
|
||||
"simulator": self.simulator,
|
||||
"cf": self.cf,
|
||||
"sr": self.sr,
|
||||
"seed": seed,
|
||||
"run_duration": self.run_duration,
|
||||
"temp": temp,
|
||||
"dt": dt,
|
||||
"init": custom_init,
|
||||
}
|
||||
if not parallelize:
|
||||
for nr in range(self.nrep):
|
||||
info["seed"] = seed + 3 * self.n_sgc * nr
|
||||
res = runTrial(self.cell, info)
|
||||
# res contains: {'time': time, 'vm': Vm, 'xmtr': xmtr, 'pre_cells': pre_cells, 'post_cell': post_cell}
|
||||
self.pre_cells[nr] = res["pre_cells"]
|
||||
self.time[nr] = res["time"]
|
||||
self.xmtr = {k: v.to_python() for k, v in list(res["xmtr"].items())}
|
||||
self.vms[nr] = res["vm"]
|
||||
self.synapses[nr] = res["synapses"]
|
||||
self.xmtrs[nr] = self.xmtr
|
||||
|
||||
if parallelize:
|
||||
pass
|
||||
|
||||
def show(self):
|
||||
self.win = pg.GraphicsWindow()
|
||||
self.win.setBackground("w")
|
||||
Fs = self.Fs
|
||||
p1 = self.win.addPlot(
|
||||
title="Stimulus", row=0, col=0, labels={"bottom": "T (ms)", "left": "V"}
|
||||
)
|
||||
p1.plot(self.stim.time * 1000, self.stim.sound, pen=pg.mkPen("k", width=0.75))
|
||||
p1.setXLink(p1)
|
||||
|
||||
p2 = self.win.addPlot(
|
||||
title="AN spikes",
|
||||
row=1,
|
||||
col=0,
|
||||
labels={"bottom": "T (ms)", "left": "AN spikes (first trial)"},
|
||||
)
|
||||
for nr in range(self.nrep):
|
||||
xan = []
|
||||
yan = []
|
||||
for k in range(len(self.pre_cells[nr])):
|
||||
r = self.pre_cells[nr][k]._spiketrain
|
||||
xan.extend(r)
|
||||
yr = k + np.zeros_like(r) + 0.2
|
||||
yan.extend(yr)
|
||||
c = pg.PlotCurveItem()
|
||||
xp = np.repeat(np.array(xan), 2)
|
||||
yp = np.repeat(np.array(yan), 2)
|
||||
yp[1::2] = yp[::2] + 0.6
|
||||
c.setData(
|
||||
xp.flatten(),
|
||||
yp.flatten(),
|
||||
connect="pairs",
|
||||
pen=pg.mkPen(pg.intColor(nr, self.nrep), hues=self.nrep, width=1.0),
|
||||
)
|
||||
p2.addItem(c)
|
||||
p2.setXLink(p1)
|
||||
|
||||
p3 = self.win.addPlot(
|
||||
title="%s Spikes" % self.cell,
|
||||
row=2,
|
||||
col=0,
|
||||
labels={"bottom": "T (ms)", "left": "Trial #"},
|
||||
)
|
||||
xcn = []
|
||||
ycn = []
|
||||
xspks = []
|
||||
for k in range(self.nrep):
|
||||
bspk = PU.findspikes(self.time[k], self.vms[k], -35.0)
|
||||
xcn.extend(bspk)
|
||||
yr = k + np.zeros_like(bspk) + 0.2
|
||||
ycn.extend(yr)
|
||||
d = pg.PlotCurveItem()
|
||||
xp = np.repeat(np.array(xcn), 2)
|
||||
yp = np.repeat(np.array(ycn), 2)
|
||||
yp[1::2] = yp[::2] + 0.6
|
||||
d.setData(
|
||||
xp.flatten(), yp.flatten(), connect="pairs", pen=pg.mkPen("k", width=1.5)
|
||||
)
|
||||
p3.addItem(d)
|
||||
p3.setXLink(p1)
|
||||
|
||||
p4 = self.win.addPlot(
|
||||
title="%s Vm" % self.cell,
|
||||
row=3,
|
||||
col=0,
|
||||
labels={"bottom": "T (ms)", "left": "Vm (mV)"},
|
||||
)
|
||||
for nr in range(self.nrep):
|
||||
p4.plot(
|
||||
self.time[nr],
|
||||
self.vms[nr],
|
||||
pen=pg.mkPen(pg.intColor(nr, self.nrep), hues=self.nrep, width=1.0),
|
||||
)
|
||||
p4.setXLink(p1)
|
||||
|
||||
p5 = self.win.addPlot(
|
||||
title="xmtr", row=0, col=1, labels={"bottom": "T (ms)", "left": "gSyn"}
|
||||
)
|
||||
if synapseType == "multisite":
|
||||
for nr in [0]:
|
||||
syn = self.synapses[nr]
|
||||
j = 0
|
||||
for k in range(self.n_sgc):
|
||||
synapse = syn[k]
|
||||
for i in range(synapse.terminal.n_rzones):
|
||||
p5.plot(
|
||||
self.time[nr],
|
||||
self.xmtrs[nr]["xmtr%04d" % j],
|
||||
pen=pg.mkPen(
|
||||
pg.intColor(nr, self.nrep), hues=self.nrep, width=1.0
|
||||
),
|
||||
)
|
||||
j = j + 1
|
||||
p5.setXLink(p1)
|
||||
|
||||
p6 = self.win.addPlot(
|
||||
title="AN PSTH",
|
||||
row=1,
|
||||
col=1,
|
||||
labels={"bottom": "T (ms)", "left": "Sp/ms/trial"},
|
||||
)
|
||||
bins = np.arange(0, 200, 1)
|
||||
(hist, binedges) = np.histogram(xan, bins)
|
||||
curve6 = p6.plot(
|
||||
binedges,
|
||||
hist,
|
||||
stepMode=True,
|
||||
fillBrush=(0, 0, 0, 255),
|
||||
brush=pg.mkBrush("k"),
|
||||
fillLevel=0,
|
||||
)
|
||||
|
||||
p7 = self.win.addPlot(
|
||||
title="%s PSTH" % self.cell,
|
||||
row=2,
|
||||
col=1,
|
||||
labels={"bottom": "T (ms)", "left": "Sp/ms/trial"},
|
||||
)
|
||||
bins = np.arange(0, 200, 1)
|
||||
(hist, binedges) = np.histogram(xcn, bins)
|
||||
curve7 = p7.plot(
|
||||
binedges,
|
||||
hist,
|
||||
stepMode=True,
|
||||
fillBrush=(0, 0, 0, 255),
|
||||
brush=pg.mkBrush("k"),
|
||||
fillLevel=0,
|
||||
)
|
||||
|
||||
# p6 = self.win.addPlot(title='AN phase', row=1, col=1)
|
||||
# phasewin = [self.pip_start[0] + 0.25*self.pip_duration, self.pip_start[0] + self.pip_duration]
|
||||
# prespk = self.pre_cells[0]._spiketrain # just sample one...
|
||||
# spkin = prespk[np.where(prespk > phasewin[0]*1e3)]
|
||||
# spikesinwin = spkin[np.where(spkin <= phasewin[1]*1e3)]
|
||||
# print "\nCell type: %s" % self.cell
|
||||
# print "Stimulus: "
|
||||
#
|
||||
# # set freq for VS calculation
|
||||
# if self.stimulus == 'tone':
|
||||
# f0 = self.f0
|
||||
# print "Tone: f0=%.3f at %3.1f dbSPL, cell CF=%.3f" % (self.f0, self.dbspl, self.cf)
|
||||
# if self.stimulus == 'SAM':
|
||||
# f0 = self.fMod
|
||||
# print ("SAM Tone: f0=%.3f at %3.1f dbSPL, fMod=%3.1f dMod=%5.2f, cell CF=%.3f" %
|
||||
# (self.f0, self.dbspl, self.fMod, self.dMod, self.cf))
|
||||
# if self.stimulus == 'clicks':
|
||||
# f0 = 1./self.click_rate
|
||||
# print "Clicks: interval %.3f at %3.1f dbSPL, cell CF=%.3f " % (self.click_rate, self.dbspl, self.cf)
|
||||
# vs = PU.vector_strength(spikesinwin, f0)
|
||||
#
|
||||
# print 'AN Vector Strength: %7.3f, d=%.2f (us) Rayleigh: %7.3f p = %.3e n = %d' % (vs['r'], vs['d']*1e6, vs['R'], vs['p'], vs['n'])
|
||||
# (hist, binedges) = np.histogram(vs['ph'])
|
||||
# curve = p6.plot(binedges, hist, stepMode=True, fillBrush=(100, 100, 255, 150), fillLevel=0)
|
||||
# p6.setXRange(0., 2*np.pi)
|
||||
#
|
||||
# p7 = self.win.addPlot(title='%s phase' % self.cell, row=2, col=1)
|
||||
# spkin = bspk[np.where(bspk > phasewin[0]*1e3)]
|
||||
# spikesinwin = spkin[np.where(spkin <= phasewin[1]*1e3)]
|
||||
# vs = PU.vector_strength(spikesinwin, f0)
|
||||
# print '%s Vector Strength: %7.3f, d=%.2f (us) Rayleigh: %7.3f p = %.3e n = %d' % (self.cell, vs['r'], vs['d']*1e6, vs['R'], vs['p'], vs['n'])
|
||||
# (hist, binedges) = np.histogram(vs['ph'])
|
||||
# curve = p7.plot(binedges, hist, stepMode=True, fillBrush=(100, 100, 255, 150), fillLevel=0)
|
||||
# p7.setXRange(0., 2*np.pi)
|
||||
# p7.setXLink(p6)
|
||||
|
||||
self.win.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Compute AN only PSTH in postsynaptic cell"
|
||||
)
|
||||
parser.add_argument(
|
||||
type=str,
|
||||
dest="cell",
|
||||
default="bushy",
|
||||
choices=[
|
||||
"bushy",
|
||||
"tstellate",
|
||||
"dstellate",
|
||||
"octopus",
|
||||
"tuberculoventral",
|
||||
"pyramida",
|
||||
],
|
||||
help="Select target cell",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-s",
|
||||
"--stimulus",
|
||||
type=str,
|
||||
dest="stimulus",
|
||||
default="tone",
|
||||
choices=["tone", "SAM", "clicks"],
|
||||
help="Select stimulus from ['tone', 'SAM', 'clicks']",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-t",
|
||||
"--type",
|
||||
type=str,
|
||||
dest="syntype",
|
||||
default="simple",
|
||||
choices=["simple", "multisite"],
|
||||
help="Set synapse type (simple, multisite)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-n",
|
||||
"--nrep",
|
||||
type=int,
|
||||
dest="nrep",
|
||||
default=10,
|
||||
help="Set number of repetitions",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
cell = args.cell
|
||||
stimulus = args.stimulus
|
||||
nrep = args.nrep
|
||||
synapseType = args.syntype
|
||||
|
||||
print("cell type: ", cell)
|
||||
prot = SGCInputTestPSTH()
|
||||
prot.set_cell(cell)
|
||||
prot.run(stimulus=stimulus, reps=nrep)
|
||||
prot.show()
|
||||
|
||||
import sys
|
||||
|
||||
if sys.flags.interactive == 0:
|
||||
pg.QtGui.QApplication.exec_()
|
||||
248
examples/test_sgc_input_phaselocking.py
Normal file
248
examples/test_sgc_input_phaselocking.py
Normal file
@@ -0,0 +1,248 @@
|
||||
"""
|
||||
test_sgc_input_phaselocking.py
|
||||
|
||||
Test phase locking from an input sgc to a target cell type. Runs simulations
|
||||
with AN input, and plots the results, including PSTH and phase histogram.
|
||||
|
||||
Usage: python test_sgc_input_phaselocking.py celltype stimulus species
|
||||
where:
|
||||
celltype is one of [bushy, tstellate, octopus, dstellate] (default: bushy)
|
||||
stimulus is one of [tone, SAM, clicks] (default: tone)
|
||||
species is one of [guineapig, mouse] (default: guineapig)
|
||||
|
||||
"""
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
import pyqtgraph as pg
|
||||
from neuron import h
|
||||
from cnmodel.protocols import Protocol
|
||||
from cnmodel import cells
|
||||
from cnmodel.util import sound
|
||||
import cnmodel.util.pynrnutilities as PU
|
||||
from cnmodel import data
|
||||
|
||||
|
||||
class SGCInputTestPL(Protocol):
|
||||
def set_cell(self, cell="bushy"):
|
||||
self.cell = cell
|
||||
|
||||
def run(
|
||||
self, temp=34.0, dt=0.025, seed=575982035, stimulus="tone", species="mouse"
|
||||
):
|
||||
assert stimulus in ["tone", "SAM", "clicks"] # cases available
|
||||
if self.cell == "bushy":
|
||||
postCell = cells.Bushy.create(species=species)
|
||||
elif self.cell == "tstellate":
|
||||
postCell = cells.TStellate.create(species=species)
|
||||
elif self.cell == "octopus":
|
||||
postCell = cells.Octopus.create(species=species)
|
||||
elif self.cell == "dstellate":
|
||||
postCell = cells.DStellate.create(species=species)
|
||||
else:
|
||||
raise ValueError(
|
||||
"cell %s is not yet implemented for phaselocking" % self.cell
|
||||
)
|
||||
self.post_cell = postCell
|
||||
self.stimulus = stimulus
|
||||
self.run_duration = 1.0 # in seconds
|
||||
self.pip_duration = 0.8 # in seconds
|
||||
self.pip_start = [0.02] # in seconds
|
||||
self.Fs = 100e3 # in Hz
|
||||
self.f0 = 4000.0 # stimulus in Hz
|
||||
self.cf = 4000.0 # SGCs in Hz
|
||||
self.fMod = 100.0 # mod freq, Hz
|
||||
self.dMod = 50.0 # % mod depth, Hz
|
||||
self.dbspl = 60.0
|
||||
if self.stimulus == "SAM":
|
||||
self.stim = sound.SAMTone(
|
||||
rate=self.Fs,
|
||||
duration=self.run_duration,
|
||||
f0=self.f0,
|
||||
fmod=self.fMod,
|
||||
dmod=self.dMod,
|
||||
dbspl=self.dbspl,
|
||||
ramp_duration=2.5e-3,
|
||||
pip_duration=self.pip_duration,
|
||||
pip_start=self.pip_start,
|
||||
)
|
||||
if self.stimulus == "tone":
|
||||
self.f0 = 1000.0
|
||||
self.cf = 1000.0
|
||||
self.stim = sound.TonePip(
|
||||
rate=self.Fs,
|
||||
duration=self.run_duration,
|
||||
f0=self.f0,
|
||||
dbspl=self.dbspl,
|
||||
ramp_duration=2.5e-3,
|
||||
pip_duration=self.pip_duration,
|
||||
pip_start=self.pip_start,
|
||||
)
|
||||
|
||||
if self.stimulus == "clicks":
|
||||
self.click_rate = 0.020 # msec
|
||||
self.stim = sound.ClickTrain(
|
||||
rate=self.Fs,
|
||||
duration=self.run_duration,
|
||||
f0=self.f0,
|
||||
dbspl=self.dbspl,
|
||||
click_start=0.010,
|
||||
click_duration=100.0e-6,
|
||||
click_interval=self.click_rate,
|
||||
nclicks=int((self.run_duration - 0.01) / self.click_rate),
|
||||
ramp_duration=2.5e-3,
|
||||
)
|
||||
|
||||
n_sgc = data.get(
|
||||
"convergence", species=species, post_type=postCell.type, pre_type="sgc"
|
||||
)[0]
|
||||
self.n_sgc = int(np.round(n_sgc))
|
||||
|
||||
self.pre_cells = []
|
||||
self.synapses = []
|
||||
j = 0
|
||||
for k in range(self.n_sgc):
|
||||
seed = seed + k
|
||||
preCell = cells.DummySGC(cf=self.cf, sr=2)
|
||||
synapse = preCell.connect(postCell)
|
||||
for i in range(synapse.terminal.n_rzones):
|
||||
self["xmtr%03d" % j] = synapse.terminal.relsite._ref_XMTR[i]
|
||||
j = j + 1
|
||||
synapse.terminal.relsite.Dep_Flag = False
|
||||
preCell.set_sound_stim(self.stim, seed=seed)
|
||||
self.pre_cells.append(preCell)
|
||||
self.synapses.append(synapse)
|
||||
|
||||
self["vm"] = postCell.soma(0.5)._ref_v
|
||||
# self['prevm'] = preCell.soma(0.5)._ref_v
|
||||
self["t"] = h._ref_t
|
||||
postCell.cell_initialize()
|
||||
h.tstop = 1e3 * self.run_duration # duration of a run
|
||||
h.celsius = temp
|
||||
h.dt = dt
|
||||
|
||||
self.custom_init()
|
||||
h.run()
|
||||
|
||||
def show(self):
|
||||
self.win = pg.GraphicsWindow()
|
||||
p1 = self.win.addPlot(title="stim", row=0, col=0)
|
||||
p1.plot(self.stim.time * 1000, self.stim.sound)
|
||||
p1.setXLink(p1)
|
||||
|
||||
p2 = self.win.addPlot(title="AN spikes", row=1, col=0)
|
||||
vt = pg.VTickGroup(self.pre_cells[0]._spiketrain)
|
||||
p2.addItem(vt)
|
||||
p2.setXLink(p1)
|
||||
|
||||
p3 = self.win.addPlot(title="%s Spikes" % self.cell, row=2, col=0)
|
||||
bspk = PU.findspikes(self["t"], self["vm"], -30.0)
|
||||
bspktick = pg.VTickGroup(bspk)
|
||||
p3.addItem(bspktick)
|
||||
p3.setXLink(p1)
|
||||
|
||||
p4 = self.win.addPlot(title="%s Vm" % self.cell, row=3, col=0)
|
||||
p4.plot(self["t"], self["vm"])
|
||||
p4.setXLink(p1)
|
||||
|
||||
p5 = self.win.addPlot(title="xmtr", row=0, col=1)
|
||||
j = 0
|
||||
for k in range(self.n_sgc):
|
||||
synapse = self.synapses[k]
|
||||
for i in range(synapse.terminal.n_rzones):
|
||||
p5.plot(self["t"], self["xmtr%03d" % j], pen=(i, 15))
|
||||
j = j + 1
|
||||
p5.setXLink(p1)
|
||||
|
||||
p6 = self.win.addPlot(title="AN phase", row=1, col=1)
|
||||
phasewin = [
|
||||
self.pip_start[0] + 0.25 * self.pip_duration,
|
||||
self.pip_start[0] + self.pip_duration,
|
||||
]
|
||||
prespk = self.pre_cells[0]._spiketrain # just sample one...
|
||||
spkin = prespk[np.where(prespk > phasewin[0] * 1e3)]
|
||||
spikesinwin = spkin[np.where(spkin <= phasewin[1] * 1e3)]
|
||||
print("\nCell type: %s" % self.cell)
|
||||
print("Stimulus: ")
|
||||
|
||||
# set freq for VS calculation
|
||||
if self.stimulus == "tone":
|
||||
f0 = self.f0
|
||||
print(
|
||||
"Tone: f0=%.3f at %3.1f dbSPL, cell CF=%.3f"
|
||||
% (self.f0, self.dbspl, self.cf)
|
||||
)
|
||||
if self.stimulus == "SAM":
|
||||
f0 = self.fMod
|
||||
print(
|
||||
(
|
||||
"SAM Tone: f0=%.3f at %3.1f dbSPL, fMod=%3.1f dMod=%5.2f, cell CF=%.3f"
|
||||
% (self.f0, self.dbspl, self.fMod, self.dMod, self.cf)
|
||||
)
|
||||
)
|
||||
if self.stimulus == "clicks":
|
||||
f0 = 1.0 / self.click_rate
|
||||
print(
|
||||
"Clicks: interval %.3f at %3.1f dbSPL, cell CF=%.3f "
|
||||
% (self.click_rate, self.dbspl, self.cf)
|
||||
)
|
||||
vs = PU.vector_strength(spikesinwin, f0)
|
||||
|
||||
print(
|
||||
"AN Vector Strength at %.1f: %7.3f, d=%.2f (us) Rayleigh: %7.3f p = %.3e n = %d"
|
||||
% (f0, vs["r"], vs["d"] * 1e6, vs["R"], vs["p"], vs["n"])
|
||||
)
|
||||
(hist, binedges) = np.histogram(vs["ph"])
|
||||
p6.plot(
|
||||
binedges, hist, stepMode=True, fillBrush=(100, 100, 255, 150), fillLevel=0
|
||||
)
|
||||
p6.setXRange(0.0, 2 * np.pi)
|
||||
|
||||
p7 = self.win.addPlot(title="%s phase" % self.cell, row=2, col=1)
|
||||
spkin = bspk[np.where(bspk > phasewin[0] * 1e3)]
|
||||
spikesinwin = spkin[np.where(spkin <= phasewin[1] * 1e3)]
|
||||
vs = PU.vector_strength(spikesinwin, f0)
|
||||
print(
|
||||
"%s Vector Strength: %7.3f, d=%.2f (us) Rayleigh: %7.3f p = %.3e n = %d"
|
||||
% (self.cell, vs["r"], vs["d"] * 1e6, vs["R"], vs["p"], vs["n"])
|
||||
)
|
||||
(hist, binedges) = np.histogram(vs["ph"])
|
||||
p7.plot(
|
||||
binedges, hist, stepMode=True, fillBrush=(100, 100, 255, 150), fillLevel=0
|
||||
)
|
||||
p7.setXRange(0.0, 2 * np.pi)
|
||||
p7.setXLink(p6)
|
||||
|
||||
self.win.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) > 1 and sys.argv[1] in ["help", "-h", "--help"]:
|
||||
print(
|
||||
"\nUsage: python test_sgc_input_phaselocking.py\n celltype [bushy, tstellate, octopus, dstellate] (default: bushy)"
|
||||
)
|
||||
print(" stimulus [tone, SAM, clicks] (default: tone)")
|
||||
print(" species [guineapig mouse] (default: guineapig)\n")
|
||||
exit(0)
|
||||
if len(sys.argv) > 1:
|
||||
cell = sys.argv[1]
|
||||
else:
|
||||
cell = "bushy"
|
||||
if len(sys.argv) > 2:
|
||||
stimulus = sys.argv[2]
|
||||
else:
|
||||
stimulus = "tone"
|
||||
if len(sys.argv) > 3:
|
||||
species = sys.argv[3]
|
||||
else:
|
||||
species = "guineapig"
|
||||
print("cell type: ", cell)
|
||||
prot = SGCInputTestPL()
|
||||
prot.set_cell(cell)
|
||||
prot.run(stimulus=stimulus, species=species)
|
||||
prot.show()
|
||||
|
||||
import sys
|
||||
|
||||
if sys.flags.interactive == 0:
|
||||
pg.QtGui.QApplication.exec_()
|
||||
97
examples/test_simple_synapses.py
Normal file
97
examples/test_simple_synapses.py
Normal file
@@ -0,0 +1,97 @@
|
||||
"""
|
||||
test_simple_synapses
|
||||
|
||||
Test synapses between cell types.
|
||||
|
||||
Usage:
|
||||
python test_synapses.py <pre_celltype> <post_celltype>
|
||||
Supported cell types: sgc, bushy, tstellate, dstellate, tuberculoventral, pyramidal
|
||||
"""
|
||||
import sys
|
||||
import pyqtgraph as pg
|
||||
from cnmodel.protocols.simple_synapse_test import SimpleSynapseTest
|
||||
from cnmodel import cells
|
||||
from cnmodel.synapses import Synapse
|
||||
|
||||
|
||||
def runtest():
|
||||
if len(sys.argv) < 3:
|
||||
print("Usage: python test_synapses.py <pre_celltype> <post_celltype>")
|
||||
print(
|
||||
" Supported cell types: sgc, bushy, tstellate, dstellate, tuberculoventral, pyramidal"
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
convergence = {
|
||||
"sgc": {
|
||||
"bushy": 1,
|
||||
"tstellate": 6,
|
||||
"dstellate": 10,
|
||||
"dstellate_eager": 10,
|
||||
"tuberculoventral": 6,
|
||||
"pyramidal": 5,
|
||||
},
|
||||
"dstellate": {
|
||||
"bushy": 10,
|
||||
"tstellate": 15,
|
||||
"dstellate": 5,
|
||||
"tuberculoventral": 10,
|
||||
"pyramidal": 10,
|
||||
},
|
||||
"tuberculoventral": {
|
||||
"bushy": 6,
|
||||
"tstellate": 3,
|
||||
"dstellate": 0,
|
||||
"tuberculoventral": 2,
|
||||
"pyramidal": 10,
|
||||
},
|
||||
}
|
||||
|
||||
c = []
|
||||
for cellType in sys.argv[1:3]:
|
||||
if cellType == "sgc":
|
||||
cell = cells.SGC.create()
|
||||
elif cellType == "tstellate":
|
||||
cell = cells.TStellate.create(debug=True, ttx=False)
|
||||
elif (
|
||||
cellType == "dstellate"
|
||||
): # Type I-II Rothman model, similiar excitability (Xie/Manis, unpublished)
|
||||
cell = cells.DStellate.create(model="RM03", debug=True, ttx=False)
|
||||
elif cellType == "dstellate_eager": # From Eager et al.
|
||||
cell = cells.DStellate.create(model="Eager", debug=True, ttx=False)
|
||||
elif cellType == "bushy":
|
||||
cell = cells.Bushy.create(debug=True, ttx=True)
|
||||
elif cellType == "tuberculoventral":
|
||||
cell = cells.Tuberculoventral.create(debug=True, ttx=False)
|
||||
elif cellType == "pyramidal":
|
||||
cell = cells.Pyramidal.create(debug=True, ttx=False)
|
||||
else:
|
||||
raise ValueError("Unknown cell type '%s'" % cellType)
|
||||
c.append(cell)
|
||||
|
||||
preCell, postCell = c
|
||||
|
||||
nTerminals = convergence.get(sys.argv[1], {}).get(sys.argv[2], None)
|
||||
if nTerminals is None:
|
||||
nTerminals = 1
|
||||
print(
|
||||
"Warning: Unknown convergence for %s => %s, assuming %d"
|
||||
% (sys.argv[1], sys.argv[2], nTerminals)
|
||||
)
|
||||
|
||||
if sys.argv[1:3] == ["sgc", "bushy"]:
|
||||
niter = 1
|
||||
else:
|
||||
niter = 20
|
||||
|
||||
st = SimpleSynapseTest()
|
||||
st.run(preCell.soma, postCell.soma, iterations=niter)
|
||||
st.show()
|
||||
return st # keep in memory
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
r = runtest()
|
||||
print("runtest done")
|
||||
if sys.flags.interactive == 0:
|
||||
pg.QtGui.QApplication.exec_()
|
||||
116
examples/test_sound_stim.py
Normal file
116
examples/test_sound_stim.py
Normal file
@@ -0,0 +1,116 @@
|
||||
"""
|
||||
Test using sound stimulation to generate SGC spike trains.
|
||||
|
||||
This script uses an_model.get_spiketrain(), which internally calls MATLAB to
|
||||
generate spike trains and caches the output. A higher-level approach is to use
|
||||
DummySGC, which will automatically feed the spike train into a synapse for
|
||||
input to downstream neurons (see test_sgc_input.py). Lower-level access to the
|
||||
auditory nerve model is demonstrated in test_an_model.py.
|
||||
|
||||
This script also can measure the time required to generate the spike trains, or
|
||||
to retrieve them from the cache. In addition, it can access a second interface
|
||||
to the Zilany et al. mode that is in pure python ("cochlea") for comparison.
|
||||
In general the speed to compute the spike trains for the same sets of stimuli
|
||||
is faster with the pure Python interface than with the Matlab interface, and
|
||||
fastest for retrieval of pre-computed trains. Note that changing the value
|
||||
of "seed" will force a recomputation of the spike trains.
|
||||
"""
|
||||
import numpy as np
|
||||
import pyqtgraph as pg
|
||||
from cnmodel import an_model
|
||||
from cnmodel.util import sound
|
||||
import cochlea
|
||||
|
||||
import time
|
||||
|
||||
seed = 34986
|
||||
|
||||
|
||||
def time_usage(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
beg_ts = time.time()
|
||||
res = func(*args, **kwargs)
|
||||
end_ts = time.time()
|
||||
print(("** Elapsed time: %f" % (end_ts - beg_ts)))
|
||||
return res
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
def set_dbspl(signal, dbspl):
|
||||
"""Scale the level of `signal` to the given dB_SPL."""
|
||||
p0 = 20e-6
|
||||
rms = np.sqrt(np.sum(signal ** 2) / signal.size)
|
||||
scaled = signal * 10 ** (dbspl / 20.0) * p0 / rms
|
||||
return scaled
|
||||
|
||||
|
||||
@time_usage
|
||||
def sound_stim(seed, useMatlab=True):
|
||||
cf = 1.5e3
|
||||
levels = list(range(-10, 101, 10))
|
||||
|
||||
result = {}
|
||||
if useMatlab:
|
||||
simulator = "matlab"
|
||||
else:
|
||||
simulator = "cochlea"
|
||||
for sr in 1, 2, 3:
|
||||
spikes = []
|
||||
for level in levels:
|
||||
stim = sound.TonePip(
|
||||
rate=100e3,
|
||||
duration=0.5,
|
||||
f0=cf,
|
||||
dbspl=level,
|
||||
pip_duration=0.5,
|
||||
pip_start=[0],
|
||||
ramp_duration=2.5e-3,
|
||||
)
|
||||
if simulator == "cochlea":
|
||||
stim._sound = set_dbspl(stim.sound, level) # adjust scaling here
|
||||
spikes.append(
|
||||
an_model.get_spiketrain(
|
||||
cf=cf, sr=sr, seed=seed, stim=stim, simulator=simulator
|
||||
)
|
||||
)
|
||||
seed += 1
|
||||
result[sr] = {"levels": levels, "spikes": spikes}
|
||||
return result
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def runtest():
|
||||
usematlab = True
|
||||
if len(sys.argv) > 0:
|
||||
if len(sys.argv) == 1:
|
||||
print(
|
||||
'Call requires argument, must be either "matlab" or "cochlea"; default is "matlab"'
|
||||
)
|
||||
exit()
|
||||
flag = sys.argv[1]
|
||||
if flag not in ["matlab", "cochlea"]:
|
||||
print('Flag must be either "matlab" or "cochlea"; default is "matlab"')
|
||||
exit()
|
||||
if flag == "cochlea":
|
||||
usematlab = False
|
||||
if usematlab:
|
||||
print("Running with matlab simulator")
|
||||
else:
|
||||
print("Running with MR cochlea simulator")
|
||||
|
||||
result = sound_stim(seed, useMatlab=usematlab)
|
||||
|
||||
win = pg.GraphicsWindow()
|
||||
p1 = win.addPlot(title="Rate-level function")
|
||||
for i, x in enumerate(result.keys()):
|
||||
p1.plot(result[x]["levels"], [s.size for s in result[x]["spikes"]], pen=(x, 6))
|
||||
return win
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
win = runtest()
|
||||
if sys.flags.interactive == 0:
|
||||
pg.QtGui.QApplication.exec_()
|
||||
70
examples/test_sounds.py
Normal file
70
examples/test_sounds.py
Normal file
@@ -0,0 +1,70 @@
|
||||
"""
|
||||
Test sounds and plot waveforms.
|
||||
|
||||
This script tests the sound waveform generator for a variety of sounds
|
||||
|
||||
"""
|
||||
import sys
|
||||
import numpy as np
|
||||
import pyqtgraph as pg
|
||||
from cnmodel.util import sound
|
||||
from collections import OrderedDict
|
||||
from scipy import signal
|
||||
|
||||
class test_sounds():
|
||||
def __init__(self):
|
||||
cf = 2e3
|
||||
Fs = 100e3 # sample frequency
|
||||
level = 80.
|
||||
seed = 34978
|
||||
fmod = 10.
|
||||
dmod = 100.
|
||||
win = pg.GraphicsWindow()
|
||||
pipwin = win.addPlot(title='sound pip', row=0, col=0)
|
||||
pipmodwin = win.addPlot(title='100 % SAM modulated pip', row=1, col=0)
|
||||
noisewin = win.addPlot(title='WB noise', row=2, col=0)
|
||||
noisemodwin = win.addPlot(title='100 % SAM Modulated WB Noise', row=3, col=0)
|
||||
clickwin = win.addPlot(title='clicks', row=4, col=0)
|
||||
wavewin = win.addPlot(title='wavefile', row=5, col=0)
|
||||
|
||||
pipwins = win.addPlot(title='sound pip Spec', row=0, col=1)
|
||||
pipmodwins = win.addPlot(title='100 % SAM modulated pip', row=1, col=1)
|
||||
noisewins = win.addPlot(title='WB noise', row=2, col=1)
|
||||
noisemodwins = win.addPlot(title='100 % SAM Modulated WB Noise', row=3, col=1)
|
||||
clickwins = win.addPlot(title='click spec', row=4, col=1)
|
||||
wavewins = win.addPlot(title='Wavefile spec', row=5, col=1)
|
||||
|
||||
stims = OrderedDict([('pip', (pipwin, sound.TonePip)), ('pipmod', (pipmodwin, sound.SAMTone)),
|
||||
('noise', (noisewin, sound.NoisePip)), ('noisemod', (noisemodwin, sound.SAMNoise)),
|
||||
('clicks', (clickwin, sound.ClickTrain)),
|
||||
('wavefile', (wavewin, sound.ReadWavefile))])
|
||||
|
||||
specs = OrderedDict([('pip', (pipwins, sound.TonePip)), ('pipmod', (pipmodwins, sound.SAMTone)),
|
||||
('noise', (noisewins, sound.NoisePip)), ('noisemod', (noisemodwins, sound.SAMNoise)),
|
||||
('clicks', (clickwins, sound.ClickTrain)),
|
||||
('wavefile', (wavewins, sound.ReadWavefile))])
|
||||
|
||||
|
||||
for stim in stims:
|
||||
print(stim)
|
||||
if stim in ['clicks']:
|
||||
wave = stims[stim][1](rate=Fs, duration=1.0, dbspl=level,
|
||||
click_duration=1e-4, click_starts=1e-3*np.linspace(10, 500, 50))
|
||||
# wave = stims[stim][1](rate=Fs, dbspl=level, click_interval=10., nclicks=10,
|
||||
# click_duration=1e-4, click_start=10.)
|
||||
elif stim in ['wavefile']:
|
||||
wave = stims[stim][1](wavefile='cnmodel/examples/stim172_geese.wav', rate=Fs, dbspl=level)
|
||||
wave.sound # force generation here
|
||||
print('time shape test: ', wave.time.shape)
|
||||
else:
|
||||
wave = stims[stim][1](rate=Fs, duration=1.0, f0=cf, dbspl=level,
|
||||
pip_duration=0.8, pip_start=[10e-3], ramp_duration=2.5e-3,
|
||||
fmod=fmod, dmod=dmod, seed=seed)
|
||||
|
||||
stims[stim][0].plot(wave.time, wave.sound)
|
||||
f, Pxx_spec = signal.periodogram(wave.sound, Fs) # window='flattop', nperseg=8192, noverlap=512, scaling='spectrum')
|
||||
specs[stim][0].plot(f, np.sqrt(Pxx_spec))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_sounds()
|
||||
210
examples/test_synapses.py
Normal file
210
examples/test_synapses.py
Normal file
@@ -0,0 +1,210 @@
|
||||
"""
|
||||
Test synaptic connections between two different cell types.
|
||||
|
||||
usage: test_synapses.py [-h] [-t {simple,multisite}] [-c]
|
||||
{sgc,tstellate,dstellate,tuberculoventral}
|
||||
{bushy,tstellate,dstellate,octopus,tuberculoventral,pyramidal}
|
||||
|
||||
Compute AN only PSTH in postsynaptic cell
|
||||
|
||||
positional arguments:
|
||||
{sgc,tstellate,dstellate,tuberculoventral}
|
||||
Select presynaptic cell type
|
||||
{bushy,tstellate,dstellate,octopus,tuberculoventral,pyramidal}
|
||||
Select postsynaptic cell type
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-t {simple,multisite}, --type {simple,multisite}
|
||||
Set synapse type (simple, multisite)
|
||||
-c, --convergence Use convergence = 1 for comparision between simple and
|
||||
multi, instead of default table
|
||||
|
||||
|
||||
This script:
|
||||
|
||||
1. Creates single pre- and postsynaptic cells
|
||||
2. Creates multiple synaptic terminals between the two cells.
|
||||
(the convergence is hard-coded below).
|
||||
3. Stimulates the presynaptic cell by current injection.
|
||||
4. Records and analyzes the resulting post-synaptic events.
|
||||
|
||||
This is used mainly to check that the strength, kinetics, and dynamics of
|
||||
each synapse type is working as expected. A higher-level approach is
|
||||
demonstrated in test_populations.py, in which the presynaptic cells are
|
||||
automatically generated using expected patterns of connectivity.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import pyqtgraph as pg
|
||||
from cnmodel.protocols import SynapseTest
|
||||
from cnmodel import cells
|
||||
from cnmodel.synapses import Synapse
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def runtest():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Compute AN only PSTH in postsynaptic cell"
|
||||
)
|
||||
parser.add_argument(
|
||||
type=str,
|
||||
dest="precell",
|
||||
default="sgc",
|
||||
choices=["sgc", "tstellate", "dstellate", "tuberculoventral"],
|
||||
help="Select presynaptic cell type",
|
||||
)
|
||||
parser.add_argument(
|
||||
type=str,
|
||||
dest="postcell",
|
||||
default="bushy",
|
||||
choices=[
|
||||
"bushy",
|
||||
"tstellate",
|
||||
"dstellate",
|
||||
"octopus",
|
||||
"tuberculoventral",
|
||||
"pyramidal",
|
||||
],
|
||||
help="Select postsynaptic cell type",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-t",
|
||||
"--type",
|
||||
type=str,
|
||||
dest="syntype",
|
||||
default="multisite",
|
||||
choices=["simple", "multisite"],
|
||||
help="Set synapse type (simple, multisite)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-c",
|
||||
"--convergence",
|
||||
action="store_true",
|
||||
dest="convergence",
|
||||
help="Use convergence = 1 for comparision between simple and multi, instead of default table",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
precell = args.precell
|
||||
postcell = args.postcell
|
||||
synapseType = args.syntype
|
||||
use_conv_table = args.convergence
|
||||
|
||||
# These must be se3t to 1 to match data in original tables. Otherwise, it would be better
|
||||
# to use the original tables.
|
||||
|
||||
if not use_conv_table:
|
||||
convergence = {
|
||||
"sgc": {
|
||||
"bushy": 1,
|
||||
"tstellate": 1,
|
||||
"dstellate": 1,
|
||||
"dstellate_eager": 10,
|
||||
"octopus": 10,
|
||||
"tuberculoventral": 1,
|
||||
"pyramidal": 1,
|
||||
"cartwheel": 0,
|
||||
},
|
||||
"dstellate": {"bushy": 10, "tstellate": 15, "dstellate": 5},
|
||||
}
|
||||
else:
|
||||
convergence = {
|
||||
"sgc": {
|
||||
"bushy": 1,
|
||||
"tstellate": 1,
|
||||
"dstellate": 1,
|
||||
"dstellate_eager": 1,
|
||||
"octopus": 1,
|
||||
"tuberculoventral": 1,
|
||||
"pyramidal": 1,
|
||||
"cartwheel": 0,
|
||||
},
|
||||
"dstellate": {
|
||||
"bushy": 1,
|
||||
"tstellate": 1,
|
||||
"dstellate": 0,
|
||||
"tuberculoventral": 1,
|
||||
"pyramidal": 1,
|
||||
"cartwheel": 0,
|
||||
},
|
||||
"tuberculoventral": {
|
||||
"bushy": 1,
|
||||
"tstellate": 1,
|
||||
"dstellate": 0,
|
||||
"tuberculoventral": 1,
|
||||
"pyramidal": 1,
|
||||
"cartwheel": 0,
|
||||
},
|
||||
}
|
||||
|
||||
c = []
|
||||
for cellType in [precell, postcell]:
|
||||
if cellType == "sgc":
|
||||
cell = cells.SGC.create()
|
||||
elif cellType == "tstellate":
|
||||
cell = cells.TStellate.create(debug=True, ttx=False)
|
||||
elif (
|
||||
cellType == "dstellate"
|
||||
): # Type I-II Rothman model, similiar excitability (Xie/Manis, unpublished)
|
||||
cell = cells.DStellate.create(model="RM03", debug=True, ttx=False)
|
||||
elif cellType == "dstellate_eager": # From Eager et al.
|
||||
cell = cells.DStellate.create(model="Eager", debug=True, ttx=False)
|
||||
elif cellType == "bushy":
|
||||
cell = cells.Bushy.create(debug=True, ttx=True)
|
||||
elif cellType == "tuberculoventral":
|
||||
cell = cells.Tuberculoventral.create(debug=True, ttx=True)
|
||||
elif cellType == "pyramidal":
|
||||
cell = cells.Pyramidal.create(debug=True, ttx=True)
|
||||
elif cellType == "octopus":
|
||||
cell = cells.Octopus.create(debug=True, ttx=True)
|
||||
else:
|
||||
raise ValueError("Unknown cell type '%s'" % cellType)
|
||||
c.append(cell)
|
||||
|
||||
preCell, postCell = c
|
||||
|
||||
if not use_conv_table:
|
||||
nTerminals = convergence.get(precell, {}).get(postcell, None)
|
||||
else:
|
||||
nTerminals = 1
|
||||
# print("Warning: Unknown convergence for %s => %s, assuming %d" % (precell, postcell, nTerminals))
|
||||
|
||||
if [precell, postcell] == ["sgc", "bushy"]:
|
||||
niter = 5
|
||||
else:
|
||||
niter = 20
|
||||
# syntype = 'multisite'
|
||||
# if len(sys.argv) > 3:
|
||||
# syntype = sys.argv[3]
|
||||
# assert(syntype in ['simple', 'multisite'])
|
||||
if synapseType == "simple":
|
||||
niter = 1
|
||||
|
||||
st = SynapseTest()
|
||||
st.run(
|
||||
preCell.soma,
|
||||
postCell.soma,
|
||||
nTerminals,
|
||||
vclamp=-65.0,
|
||||
iterations=niter,
|
||||
synapsetype=synapseType,
|
||||
)
|
||||
st.show_result()
|
||||
st.plots["VPre"].setYRange(-70.0, 10.0)
|
||||
st.plots["EPSC"].setYRange(-2.0, 0.5)
|
||||
st.plots["latency2080"].setYRange(0.0, 1.0)
|
||||
st.plots["halfwidth"].setYRange(0.0, 1.0)
|
||||
st.plots["RT"].setYRange(0.0, 0.2)
|
||||
st.plots["latency"].setYRange(0.0, 1.0)
|
||||
st.plots["latency_distribution"].setYRange(0.0, 1.0)
|
||||
return st # need to keep st alive in memory
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
st = runtest()
|
||||
if sys.flags.interactive == 0:
|
||||
pg.QtGui.QApplication.exec_()
|
||||
312
examples/toy_model.py
Executable file
312
examples/toy_model.py
Executable file
@@ -0,0 +1,312 @@
|
||||
#!/usr/bin/python
|
||||
"""
|
||||
Basic test of initialization of multiple cells in the model, and running multiple cells at one time.
|
||||
Plots the resposnes to a series of current injections for most implemented baseic cell types in
|
||||
in cnmodel.
|
||||
|
||||
Usage:
|
||||
python examples/toy_model.py (no arguments)
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
import sys
|
||||
from neuron import h
|
||||
import numpy as np
|
||||
import cnmodel.cells as cells
|
||||
from cnmodel.protocols import Protocol
|
||||
from cnmodel.util import custom_init
|
||||
from collections import OrderedDict
|
||||
import re
|
||||
import pyqtgraph.exporters
|
||||
from cnmodel.util import pyqtgraphPlotHelpers as PH
|
||||
from cnmodel.protocols import IVCurve
|
||||
|
||||
|
||||
try: # check for pyqtgraph install
|
||||
import pyqtgraph as pg
|
||||
except ImportError:
|
||||
raise ImportError("This model requires pyqtgraph")
|
||||
|
||||
from cnmodel.util.stim import make_pulse
|
||||
|
||||
|
||||
def autorowcol(n):
|
||||
"""
|
||||
return a reasonable layout (cols, rows) for n plots on a page
|
||||
up to 16.
|
||||
Otherwise return floor(sqrt(n)) + 1 for both r and c.
|
||||
"""
|
||||
nmap = {
|
||||
1: (1, 1),
|
||||
2: (2, 1),
|
||||
3: (3, 1),
|
||||
4: (2, 2),
|
||||
5: (3, 2),
|
||||
6: (3, 2),
|
||||
7: (3, 3),
|
||||
8: (3, 3),
|
||||
9: (3, 3),
|
||||
10: (3, 4),
|
||||
11: (3, 4),
|
||||
12: (3, 4),
|
||||
13: (4, 4),
|
||||
14: (4, 4),
|
||||
15: (4, 4),
|
||||
16: (4, 4),
|
||||
}
|
||||
if n <= 16:
|
||||
return nmap[n][0], nmap[n][1]
|
||||
else:
|
||||
nx = np.floor(np.sqrt(n)) + 1
|
||||
return nx, nx
|
||||
|
||||
|
||||
def makeLayout(cols=1, rows=1, letters=True, margins=4, spacing=4, nmax=None):
|
||||
"""
|
||||
Create a multipanel plot, returning the various pyptgraph elements.
|
||||
The layout is always a rectangular grid with shape (cols, rows)
|
||||
if letters is true, then the plot is labeled "A, B, C..."
|
||||
margins sets the margins around the outside of the plot
|
||||
spacing sets the spacing between the elements of the grid
|
||||
"""
|
||||
import string
|
||||
|
||||
letters = string.ascii_uppercase
|
||||
widget = pg.QtGui.QWidget()
|
||||
gridLayout = pg.QtGui.QGridLayout()
|
||||
widget.setLayout(gridLayout)
|
||||
gridLayout.setContentsMargins(margins, margins, margins, margins)
|
||||
gridLayout.setSpacing(spacing)
|
||||
plots = [[0 for x in range(cols)] for x in range(rows)]
|
||||
i = 0
|
||||
for c in range(cols):
|
||||
for r in range(rows):
|
||||
plots[r][c] = pg.PlotWidget()
|
||||
gridLayout.addWidget(plots[r][c], r, c)
|
||||
# labelUp(plots[r][c], 'T(s)', 'Y', title = letters[i])
|
||||
i += 1
|
||||
if i > 25:
|
||||
i = 0
|
||||
if nmax is not None and i >= nmax:
|
||||
break # that's all - leave out empty plots
|
||||
|
||||
return (plots, widget, gridLayout)
|
||||
|
||||
|
||||
def getnextrowcol(plx, row, col, cols):
|
||||
col += 1
|
||||
if col >= cols:
|
||||
col = 0
|
||||
row += 1
|
||||
return (plx[row][col], row, col)
|
||||
|
||||
|
||||
class Toy(Protocol):
|
||||
"""
|
||||
Calls to encapsulate the model runs
|
||||
Run a set of cells with defined parameters to show excitability patterns.
|
||||
Note that cells from Rothman and Manis are run at 22C; others at various
|
||||
temperatures depending on how they were initially measured and defined.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(Toy, self).__init__()
|
||||
|
||||
def current_name(self, name, n):
|
||||
"""
|
||||
From the name of the current model, get the current injection information
|
||||
|
||||
Parameters
|
||||
---------
|
||||
name : str (no default)
|
||||
name of the cell type
|
||||
n : int (no default)
|
||||
"""
|
||||
if len(self.celltypes[name][3]) > 2:
|
||||
injs = self.celltypes[name][3]
|
||||
injarr = np.linspace(injs[0], injs[1], injs[2], endpoint=True)
|
||||
return "%.3f" % injarr[n]
|
||||
else:
|
||||
return "%.3f" % self.celltypes[name][3][n]
|
||||
|
||||
def getname(self, cell, ninj):
|
||||
name = self.make_name(cell)
|
||||
iname = self.current_name(name, ninj)
|
||||
nname = name + " " + iname
|
||||
return name, nname
|
||||
|
||||
def make_name(self, cell):
|
||||
return cell + ", " + self.celltypes[cell][1] + ":"
|
||||
|
||||
def run(self):
|
||||
sre = re.compile(
|
||||
"(?P<cell>\w+)(?:[, ]*)(?P<type>[\w-]*)(?:[, ]*)(?P<species>[\w-]*)"
|
||||
) # regex for keys in cell types
|
||||
self.celltypes = OrderedDict(
|
||||
[
|
||||
("Bushy, II", (cells.Bushy, "II", "guineapig", (-0.5, 0.5, 11), 22)),
|
||||
(
|
||||
"Bushy, II-I",
|
||||
(cells.Bushy, "II-I", "guineapig", (-0.5, 0.5, 11), 22),
|
||||
),
|
||||
(
|
||||
"DStellate, I-II",
|
||||
(cells.DStellate, "I-II", "guineapig", (-0.3, 0.3, 9), 22),
|
||||
),
|
||||
(
|
||||
"TStellate, I-c",
|
||||
(cells.TStellate, "I-c", "guineapig", (-0.15, 0.15, 9), 22),
|
||||
),
|
||||
(
|
||||
"TStellate, I-t",
|
||||
(cells.TStellate, "I-t", "guineapig", (-0.15, 0.15, 9), 22),
|
||||
),
|
||||
(
|
||||
"Octopus, II-o",
|
||||
(cells.Octopus, "II-o", "guineapig", (-2.5, 2.5, 11), 22),
|
||||
),
|
||||
("Bushy, II, Mouse", (cells.Bushy, "II", "mouse", (-1, 1.2, 13), 34)),
|
||||
(
|
||||
"TStellate, I-c, Mouse",
|
||||
(cells.TStellate, "I-c", "mouse", (-1, 1, 9), 34),
|
||||
),
|
||||
(
|
||||
"DStellate, I-II, Mouse",
|
||||
(cells.DStellate, "I-II", "mouse", (-0.5, 0.5, 9), 34),
|
||||
),
|
||||
(
|
||||
"Pyramidal, I, Rat",
|
||||
(cells.Pyramidal, "I", "rat", (-0.3, 0.4, 11), 34),
|
||||
),
|
||||
(
|
||||
"Cartwheel, I, Mouse",
|
||||
(cells.Cartwheel, "I", "mouse", (-0.5, 0.5, 9), 34),
|
||||
),
|
||||
(
|
||||
"Tuberculoventral, I, Mouse",
|
||||
(cells.Tuberculoventral, "I", "mouse", (-0.35, 1, 11), 34),
|
||||
),
|
||||
("SGC, bm, Mouse", (cells.SGC, "bm", "mouse", (-0.2, 0.6, 9), 34)),
|
||||
("SGC, a, Mouse", (cells.SGC, "a", "mouse", (-0.2, 0.6, 9), 34)),
|
||||
]
|
||||
)
|
||||
|
||||
dt = 0.025
|
||||
h.dt = dt
|
||||
h.celsius = 22
|
||||
|
||||
stim = {"NP": 1, "delay": 10, "dur": 100, "amp": 0.0, "dt": h.dt}
|
||||
tend = stim["delay"] + stim["dur"] + 20.0
|
||||
|
||||
netcells = {}
|
||||
for c in list(self.celltypes.keys()):
|
||||
g = sre.match(c)
|
||||
cellname = g.group("cell")
|
||||
modelType = g.group("type")
|
||||
species = self.celltypes[c][2]
|
||||
if g.group("type") == "":
|
||||
netcells[c] = self.celltypes[c][0].create()
|
||||
else:
|
||||
netcells[c] = self.celltypes[c][0].create(
|
||||
modelType=modelType, species=species, debug=False
|
||||
)
|
||||
# dicts to hold data
|
||||
pl = OrderedDict([])
|
||||
pl2 = OrderedDict([])
|
||||
rvec = OrderedDict([])
|
||||
vec = OrderedDict([])
|
||||
istim = OrderedDict([])
|
||||
ncells = len(list(self.celltypes.keys()))
|
||||
#
|
||||
# build plotting area
|
||||
#
|
||||
app = pg.mkQApp()
|
||||
self.win = pg.GraphicsWindow()
|
||||
self.win.setBackground("w")
|
||||
self.win.resize(800, 600)
|
||||
cols, rows = autorowcol(ncells)
|
||||
|
||||
row = 0
|
||||
col = 0
|
||||
labelStyle = {"color": "#000", "font-size": "9pt", "weight": "normal"}
|
||||
tickStyle = pg.QtGui.QFont("Arial", 9, pg.QtGui.QFont.Light)
|
||||
self.iv = IVCurve() # use standard IVCurve here...
|
||||
for n, name in enumerate(self.celltypes.keys()):
|
||||
nrn_cell = netcells[
|
||||
name
|
||||
] # get the Neuron object we are using for this cell class
|
||||
injcmds = list(self.celltypes[name][3]) # list of injections
|
||||
injcmds[2] = (injcmds[1] - injcmds[0]) / (
|
||||
float(injcmds[2] - 1)
|
||||
) # convert to pulse format for IVCurve
|
||||
temperature = self.celltypes[name][4]
|
||||
nrn_cell.set_temperature(float(temperature))
|
||||
ninjs = len(injcmds)
|
||||
print("cell: ", name)
|
||||
# print( 'injs: ', injcmds)
|
||||
pl[name] = self.win.addPlot(
|
||||
labels={"left": "V (mV)", "bottom": "Time (ms)"}
|
||||
)
|
||||
PH.nice_plot(pl[name])
|
||||
pl[name].setTitle(title=name, font=pg.QtGui.QFont("Arial", 10))
|
||||
col += 1
|
||||
if col >= cols:
|
||||
col = 0
|
||||
self.win.nextRow()
|
||||
row += 1
|
||||
self.iv.reset()
|
||||
self.iv.run(
|
||||
{"pulse": [injcmds]},
|
||||
nrn_cell,
|
||||
durs=(stim["delay"], stim["dur"], 20.0),
|
||||
sites=None,
|
||||
reppulse=None,
|
||||
temp=float(temperature),
|
||||
)
|
||||
for k in range(len(self.iv.voltage_traces)):
|
||||
pl[name].plot(
|
||||
self.iv.time_values,
|
||||
self.iv.voltage_traces[k],
|
||||
pen=pg.mkPen("k", width=0.75),
|
||||
)
|
||||
pl[name].setRange(xRange=(0.0, 130.0), yRange=(-160.0, 40.0))
|
||||
PH.noaxes(pl[name])
|
||||
PH.calbar(
|
||||
pl[list(self.celltypes.keys())[0]],
|
||||
calbar=[0, -120.0, 10.0, 20.0],
|
||||
unitNames={"x": "ms", "y": "mV"},
|
||||
)
|
||||
|
||||
text = u"{0:2d}\u00b0C {1:.2f}-{2:.2f} nA".format(
|
||||
int(temperature),
|
||||
np.min(self.iv.current_cmd),
|
||||
np.max(self.iv.current_cmd),
|
||||
)
|
||||
ti = pg.TextItem(text, anchor=(1, 0))
|
||||
ti.setFont(pg.QtGui.QFont("Arial", 9))
|
||||
ti.setPos(120.0, -120.0)
|
||||
pl[name].addItem(ti)
|
||||
# get overall Rin, etc; need to initialize all cells
|
||||
nrn_cell.cell_initialize()
|
||||
for n, name in enumerate(self.celltypes.keys()):
|
||||
nrn_cell = netcells[name]
|
||||
nrn_cell.vm0 = nrn_cell.soma.v
|
||||
pars = nrn_cell.compute_rmrintau(auto_initialize=False)
|
||||
print(
|
||||
"{0:>14s} [{1:>24s}] *** Rin = {2:6.1f} M\ohm Tau = {3:6.1f} ms Vm = {4:6.1f} mV".format(
|
||||
nrn_cell.status["name"], name, pars["Rin"], pars["tau"], pars["v"]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
t = Toy()
|
||||
t.run()
|
||||
if sys.flags.interactive == 0:
|
||||
pg.QtGui.QApplication.exec_()
|
||||
# exporter = pg.exporters.ImageExporter(t.win.scene())
|
||||
# exporter.export('~/Desktop/Model_Figure2.svg')
|
||||
Reference in New Issue
Block a user