def test_9_epochcontainer_for_regionbodies_currentstimulus(self):
     no_of_epochs = eg.compute_totalepochs_per_cellregion(
         self.ic_stimparameters)
     [start_ts, stop_ts] = eg.epoch_times_list(self.ic_stimparameters)
     filler = eg.epochcontainer_for_regionbodies(self.chosenmodel,
                                                 no_of_epochs, start_ts,
                                                 stop_ts)
     #print(filler) # how does the epochcontainer metadata look?
     # self.chosenmodel.regions ->
     # {"soma": ["v", "i_cap"], "axon": ["v"],
     # "channels": {"soma": {"hh": ["il", "el"], "pas": ["i"]}, "axon": {"pas": ["i"]}}}
     compare1a = filler["epoch0soma"]["v"]["tags"][0]  # number of epochs
     compare1b = filler["epoch0soma"]["v"]["tags"][1]  # epochID
     compare1c = filler["epoch0soma"]["v"]["tags"][2].split()[-1]  # recsite
     compare1d = filler["epoch0soma"]["v"]["tags"][3]  # all recsites
     compare1e = filler["epoch0soma"]["v"]["tags"][4]  # modelname
     compare1f = filler["epoch0soma"]["v"]["tags"][5]  # modelscale
     compare1g = filler["epoch0soma"]["v"]["tags"][6].split()[
         -1]  # key for recsite
     compare2a = filler["epoch0axon"]["v"]["tags"][0]
     compare2b = filler["epoch0axon"]["v"]["tags"][1]
     compare2c = filler["epoch0axon"]["v"]["tags"][2].split()[-1]
     compare2d = filler["epoch1soma"]["v"]["tags"][3]  # all recsites
     compare2e = filler["epoch0axon"]["v"]["tags"][4]
     compare2f = filler["epoch0axon"]["v"]["tags"][5]
     compare2g = filler["epoch1soma"]["v"]["tags"][6].split()[-1]
     #
     compare1 = [
         compare1a, compare1b, compare1c, compare1d, compare1e, compare1f,
         compare1g
     ]
     compare2 = [
         compare2a, compare2b, compare2c, compare2d, compare2e, compare2f,
         compare2g
     ]
     a = Counter(compare1) == Counter(compare2)
     #
     compare3a = filler["epoch0soma"]["v"]["tags"][1]  # epochID
     compare3b = filler["epoch0soma"]["v"]["tags"][2].split()[
         -1]  # [ region, recsite ]
     compare3c = filler["epoch0soma"]["v"]["tags"][3]  # all recsites
     compare4a = filler["epoch1soma"]["v"]["tags"][1]
     compare4b = filler["epoch1soma"]["i_cap"]["tags"][2].split()[-1]
     compare4c = filler["epoch0axon"]["v"]["tags"][3]
     #
     compare3 = [compare3a, compare3b, compare3c]
     compare4 = [compare4a, compare4b, compare4c]
     b = Counter(compare3) != Counter(compare4)
     #
     self.assertEqual([a, b], [True, True])
 def test_4_epoch_times_list_epoch1Istimulus(self):
     #              <---100--->   <----50---->
     # 0----------10-----------110------------160------------200
     # ep0        ep1          ep2            ep3
     ic_stimparam = {
         "type": ["current", "IClamp"],
         "stimlist": [
             {
                 "amp": 0.5,
                 "dur": 100.0,
                 "delay": 10
             },  # 0, 10.0
             {
                 "amp": 1.0,
                 "dur": 50.0,
                 "delay": 10.0 + 100.0
             }
         ],
         "tstop":
         self.ic_runtimeparam["tstop"]
     }
     [start_ts, stop_ts] = eg.epoch_times_list(ic_stimparam)
     #print(start_ts, stop_ts)
     a = Counter(start_ts) == Counter([0, 10, 110, 160])
     b = Counter(stop_ts) == Counter([10, 110, 160, 200])
     self.assertEqual([a, b], [True, True])
 def test_7_epoch_times_list_nostimulus(self):
     # 0----------10
     # ep0
     [start_ts, stop_ts] = eg.epoch_times_list(self.no_runtimeparam)
     #print(start_ts, stop_ts)
     a = Counter(start_ts) == Counter([0])
     b = Counter(stop_ts) == Counter([self.no_runtimeparam["tstop"]])
     self.assertEqual([a, b], [True, True])
 def test_8_epochcontainer_for_regionbodies_nostimulus(self):
     no_of_epochs = eg.compute_totalepochs_per_cellregion(
         self.no_runtimeparam)
     [start_ts, stop_ts] = eg.epoch_times_list(self.no_runtimeparam)
     filler = eg.epochcontainer_for_regionbodies(self.chosenmodel,
                                                 no_of_epochs, start_ts,
                                                 stop_ts)
     compare2 = len(filler)
     # self.chosenmodel.regions ->
     # {"soma": ["v", "i_cap"], "axon": ["v"],
     # "channels": {"soma": {"hh": ["il", "el"], "pas": ["i"]}, "axon": {"pas": ["i"]}}}
     no_of_regions = 2
     compare1 = no_of_regions * no_of_epochs
     a = Counter( [ compare2, filler["epoch0soma"]["v"]["start_time"],
                    filler["epoch0soma"]["v"]["stop_time"] ] ) \
         == Counter( [ compare1, filler["epoch0axon"]["v"]["start_time"],
                       self.no_runtimeparam["tstop"] ] )
     #print filler # how does the epochcontainer metadata look?
     self.assertEqual(a, True)
 def test_11_epochcontainer_without_stimulus(self):
     filler = eg.epochcontainer(chosenmodel=self.chosenmodel,
                                parameters=self.no_runtimeparam)
     no_of_epochs = filler["epoch0soma"]["v"]["tags"][0]
     a = Counter( [ int(no_of_epochs[0]),
                    filler["epoch0soma"]["v"]["start_time"],
                    filler["epoch0soma"]["v"]["stop_time"] ] ) \
         == Counter( [ 1, filler["epoch0axon"]["v"]["start_time"],
                       self.no_runtimeparam["tstop"] ] )
     #print filler # how does the epochcontainer metadata look?
     self.assertEqual(a, True)
 def test_12_forepoch_without_stimulus(self):
     runtimeparam = {"dt": 0.01, "celsius": 30, "tstop": 100, "v_init": 65}
     epochmd = eg.forepoch(chosenmodel=self.chosenmodel,
                           parameters=runtimeparam)
     # self.chosenmodel.regions = {'soma':0.0, 'axon':0.0}
     no_of_stimulus_epochs_per_region = 0
     compare2 = epochmd["epoch" + str(no_of_stimulus_epochs_per_region) +
                        "soma"]["stop_time"]
     compare1 = epochmd["epoch" + str(no_of_stimulus_epochs_per_region) +
                        "axon"]["stop_time"]
     #print epochmd # hows does the main epoch metadata look?
     self.assertEqual(compare2, compare1)
 def test_14_forepoch_with_stimulus_laststimulus_notequals_tstop(self):
     stimparameters = {
         "type": ["current", "IRamp"],
         "stimlist": [{
             "amp_initial": 0.0,
             "amp_final": 0.5,
             "dur": 5.0,
             "delay": 5.0
         }, {
             "amp_initial": 0.5,
             "amp_final": 1.0,
             "dur": 5.0,
             "delay": 10.0
         }, {
             "amp_initial": 1.0,
             "amp_final": 0.5,
             "dur": 5.0,
             "delay": 15.0
         }, {
             "amp_initial": 0.5,
             "amp_final": 0.0,
             "dur": 5.0,
             "delay": 20.0
         }],
         "tstop":
         20.0 + 10.0
     }
     epochmd = eg.forepoch(chosenmodel=self.chosenmodel,
                           parameters=stimparameters)
     # self.chosenmodel.regions = {'soma':0.0, 'axon':0.0}
     no_of_stimulus_epochs_per_region = len(stimparameters["stimlist"])
     compare2 = [
         epochmd["epoch" + str(0) + "soma"]["stop_time"],
         epochmd["epoch" + str(no_of_stimulus_epochs_per_region) +
                 "soma"]["stop_time"],
         epochmd["epoch" + str(no_of_stimulus_epochs_per_region + 1) +
                 "soma"]["stop_time"]
     ]
     compare1 = [
         epochmd["epoch" + str(0) + "axon"]["stop_time"],
         epochmd["epoch" + str(no_of_stimulus_epochs_per_region) +
                 "axon"]["stop_time"], stimparameters["tstop"]
     ]
     #print epochmd # how does the main epoch metadata look?
     self.assertEqual(compare2, compare1)
 def test_11_an_epoch_poststimulus(self):
     stimparameters = {
         "type": ["current", "IClamp"],
         "stimlist": [{
             "amp": 0.5,
             "dur": 100.0,
             "delay": 10.0
         }, {
             "amp": 1.0,
             "dur": 50.0,
             "delay": 10.0 + 100.0
         }],
         "tstop":
         200.0
     }
     epoch_value = eg.an_epoch(3, "axon", stimparameters)
     compare2 = epoch_value["description"]
     compare1 = "last, no stimulus"
     #print epoch_value # hows does an epoch metadata look?
     self.assertEqual(compare2, compare1)
 def test_7_an_epoch_prestimulus(self):
     stimparameters = {
         "type": ["current", "IClamp"],
         "stimlist": [{
             "amp": 0.5,
             "dur": 100.0,
             "delay": 10.0
         }, {
             "amp": 1.0,
             "dur": 50.0,
             "delay": 10.0 + 100.0
         }],
         "tstop":
         10.0 + 100.0 + 50.0
     }
     epoch_value = eg.an_epoch(0, "soma", stimparameters)
     compare2 = epoch_value["start_time"] + epoch_value["stop_time"]
     compare1 = 0.0 + stimparameters["stimlist"][0]["delay"]
     #print epoch_value # how does an epoch metadata look?
     self.assertEqual(compare2, compare1)
 def test_6_epoch_times_list_Vstimulus(self):
     #  <---10--->  <----20---->
     # 0----------10-----------20------------35
     # ep0        ep1          ep2
     sec_stimparam = {
         "type": ["voltage", "SEClamp"],
         "stimlist": [{
             'amp1': 0.,
             'dur1': 10.0
         }, {
             'amp2': -70.0,
             'dur2': 20.0
         }],
         "tstop": self.sec_runtimeparam["tstop"]
     }
     [start_ts, stop_ts] = eg.epoch_times_list(sec_stimparam)
     #print(start_ts, stop_ts)
     a = Counter(start_ts) == Counter([0, 10, 20])
     b = Counter(stop_ts) == Counter([10, 20, 35])
     self.assertEqual([a, b], [True, True])
 def test_10_an_epoch_laststimulus_notequals_tstop(self):
     stimparameters = {
         "type": ["current", "IClamp"],
         "stimlist": [{
             "amp": 0.5,
             "dur": 100.0,
             "delay": 10.0
         }, {
             "amp": 1.0,
             "dur": 50.0,
             "delay": 10.0 + 100.0
         }],
         "tstop":
         200.0
     }
     epoch_value = eg.an_epoch(2, "axon", stimparameters)
     compare2 = epoch_value["description"]
     compare1 = "IClamp stimulation of model with amplitude = " + \
                    str(stimparameters["stimlist"][1]["amp"]) + " nA"
     #print epoch_value # hows does an epoch metadata look?
     self.assertEqual(compare2, compare1)
 def test_3_compute_totalepochs_per_cellregion_with_voltagestimulus(self):
     self.assertEqual(
         eg.compute_totalepochs_per_cellregion(self.sec_stimparameters),
         1 + len(self.sec_stimparameters["stimlist"]))
 def test_2_compute_totalepochs_per_cellregion_with_currentstimulus(self):
     self.assertEqual(
         eg.compute_totalepochs_per_cellregion(self.ic_stimparameters),
         1 + len(self.ic_stimparameters["stimlist"]))
 def test_1_compute_totalepochs_per_cellregion_without_stimulus(self):
     self.assertEqual(
         eg.compute_totalepochs_per_cellregion(self.no_runtimeparam), 1)
 def test_8_epochcontainer_with_voltagestimulus(self):
     filler = eg.epochcontainer(chosenmodel=self.chosenmodel,
                                parameters=self.sec_stimparameters)
     #print(filler) # how does the epochcontainer metadata look?
     #print(filler.keys())
     #print(filler["epoch0soma"].keys())
     # self.chosenmodel.regions ->
     # {"soma": ["v", "i_cap"], "axon": ["v"],
     # "channels": {"soma": {"hh": ["il", "el"], "pas": ["i"]}, "axon": {"pas": ["i"]}}}
     compare1a = filler["epoch0soma"]["v"]["tags"][0]  # number of epochs
     compare1b = filler["epoch0soma"]["v"]["tags"][1]  # epochID
     compare1c = filler["epoch0soma"]["v"]["tags"][2].split()[-1]  # recsite
     compare1d = filler["epoch0soma"]["v"]["tags"][3]  # all recsites
     compare1e = filler["epoch0soma"]["v"]["tags"][4]  # modelname
     compare1f = filler["epoch0soma"]["v"]["tags"][5]  # modelscale
     compare1g = filler["epoch0soma"]["v"]["tags"][6].split()[
         -1]  # key for recsite
     compare2a = filler["epoch0axon"]["v"]["tags"][0]
     compare2b = filler["epoch0axon"]["v"]["tags"][1]
     compare2c = filler["epoch0axon"]["v"]["tags"][2].split()[-1]
     compare2d = filler["epoch1soma"]["v"]["tags"][3]  # all recsites
     compare2e = filler["epoch0axon"]["v"]["tags"][4]
     compare2f = filler["epoch0axon"]["v"]["tags"][5]
     compare2g = filler["epoch1soma"]["v"]["tags"][6].split()[-1]
     #
     compare1 = [
         compare1a, compare1b, compare1c, compare1d, compare1e, compare1f,
         compare1g
     ]
     compare2 = [
         compare2a, compare2b, compare2c, compare2d, compare2e, compare2f,
         compare2g
     ]
     a = Counter(compare1) == Counter(compare2)
     #
     compare3a = filler["epoch0soma"]["v"]["tags"][1]  # epochID
     compare3b = filler["epoch0soma"]["v"]["tags"][2].split()[
         -1]  # [ region, recsite ]
     compare3c = filler["epoch0soma"]["v"]["tags"][3]  # all recsites
     compare4a = filler["epoch1soma"]["v"]["tags"][1]
     compare4b = filler["epoch1soma"]["i_cap"]["tags"][2].split()[-1]
     compare4c = filler["epoch0axon"]["v"]["tags"][3]
     #
     compare3 = [compare3a, compare3b, compare3c]
     compare4 = [compare4a, compare4b, compare4c]
     b = Counter(compare3) != Counter(compare4)
     #
     compare5a = filler["epoch0channels"]["soma"]["pas"]["i"]["tags"][
         0]  # number of epochs
     compare5b = filler["epoch0channels"]["soma"]["pas"]["i"]["tags"][
         1]  # epochID
     compare5c = filler["epoch0channels"]["soma"]["pas"]["i"]["tags"][
         2].split()[-1]  # recsite
     compare5d = filler["epoch0channels"]["soma"]["pas"]["i"]["tags"][
         3]  # all recsites
     compare5e = filler["epoch0channels"]["soma"]["pas"]["i"]["tags"][
         4]  # modelname
     compare5f = filler["epoch0channels"]["soma"]["pas"]["i"]["tags"][
         5]  # modelscale
     compare5g = filler["epoch0channels"]["soma"]["pas"]["i"]["tags"][
         6].split()[-1]  # key for recsite
     compare6a = filler["epoch0channels"]["axon"]["pas"]["i"]["tags"][
         0]  # number of epochs
     compare6b = filler["epoch0channels"]["axon"]["pas"]["i"]["tags"][
         1]  # epochID
     compare6c = filler["epoch0channels"]["axon"]["pas"]["i"]["tags"][
         2].split()[-1]  # recsite
     compare6d = filler["epoch0channels"]["axon"]["pas"]["i"]["tags"][
         3]  # all recsites
     compare6e = filler["epoch0channels"]["axon"]["pas"]["i"]["tags"][
         4]  # modelname
     compare6f = filler["epoch0channels"]["axon"]["pas"]["i"]["tags"][
         5]  # modelscale
     compare6g = filler["epoch0channels"]["axon"]["pas"]["i"]["tags"][
         6].split()[-1]  # key for recsite
     #
     compare5 = [
         compare5a, compare5b, compare5c, compare5d, compare5e, compare5f,
         compare5g
     ]
     compare6 = [
         compare6a, compare6b, compare6c, compare6d, compare6e, compare6f,
         compare6g
     ]
     c = Counter(compare5) == Counter(compare6)
     #
     compare7a = filler["epoch0channels"]["soma"]["hh"]["il"]["tags"][
         0]  # number of epochs
     compare7b = filler["epoch0channels"]["soma"]["hh"]["il"]["tags"][
         1]  # epochID
     compare7c = filler["epoch0channels"]["soma"]["hh"]["il"]["tags"][
         2].split()[-1]  # recsite
     compare7d = filler["epoch0channels"]["soma"]["hh"]["il"]["tags"][
         3]  # all recsites
     compare7e = filler["epoch0channels"]["soma"]["hh"]["il"]["tags"][
         6].split()[-1]  # key for recsite
     compare8a = filler["epoch1channels"]["axon"]["pas"]["i"]["tags"][
         0]  # number of epochs
     compare8b = filler["epoch1channels"]["soma"]["hh"]["il"]["tags"][
         1]  # epochID
     compare8c = filler["epoch0channels"]["axon"]["pas"]["i"]["tags"][
         2].split()[-1]  # recsite
     compare8d = filler["epoch0channels"]["soma"]["pas"]["i"]["tags"][
         3]  # all recsites
     compare8e = filler["epoch0channels"]["soma"]["hh"]["el"]["tags"][
         6].split()[-1]  # key for recsite
     #
     compare7 = [compare7a, compare7b, compare7c, compare7d, compare7e]
     compare8 = [compare8a, compare8b, compare8c, compare8d, compare8e]
     d = Counter(compare7) != Counter(compare8)
     #
     self.assertEqual([a, b, c, d], [True, True, True, True])