Skip to content

Commit

Permalink
Merge branch 'experimental' into ow_test_cect
Browse files Browse the repository at this point in the history
  • Loading branch information
pgleeson committed Dec 3, 2024
2 parents ac151cb + bc81498 commit 2ee6ae7
Show file tree
Hide file tree
Showing 29 changed files with 159 additions and 46 deletions.
9 changes: 5 additions & 4 deletions c302/CompareMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,11 @@ def matchLists(cols1, cols2, indexName1, indexName2):
# 'R', 'Rp', 'S', 'Sp' map to 'Send'.
# 'NMJ' does not map.
def typeMapping(cols1, cols2, indexName1, indexName2):
list1 = ["GapJunction", "Send"]
list2 = ["EJ", "NMJ", "R", "Rp", "S", "Sp"]
type1 = cols1[indexName1[2]]
type2 = cols2[indexName2[2]]
# list1 = ["GapJunction", "Send"]
# list2 = ["EJ", "NMJ", "R", "Rp", "S", "Sp"]
# type1 = cols1[indexName1[2]]
# type2 = cols2[indexName2[2]]
pass


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion c302/OpenWormReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def read_data(self, include_nonconnected_cells=False):

try:
cell_names, pre, post, conns = self._read_connections("neuron")
except:
except Exception:
print(
"\nProblem loading connections via owmeta! The package is installed however. You may need to try running:"
+ "\n\n owm bundle remote --user add ow 'https://raw.githubusercontent.com/openworm/owmeta-bundles/master/index.json'\n"
Expand Down
2 changes: 1 addition & 1 deletion c302/SpreadsheetDataReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
############################################################


from c302 import print_
from c302.ConnectomeReader import ConnectionInfo
from c302.ConnectomeReader import analyse_connections
from c302 import print_

from xlrd import open_workbook
import os
Expand Down
2 changes: 1 addition & 1 deletion c302/White_A.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from c302.WhiteDataReader import White_A

from c302.NeuroMLUtilities import analyse_connections
from c302.ConnectomeReader import analyse_connections

read_data = White_A.read_data
read_muscle_data = White_A.read_muscle_data
Expand Down
2 changes: 1 addition & 1 deletion c302/White_L4.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from c302.WhiteDataReader import White_L4

from c302.NeuroMLUtilities import analyse_connections
from c302.ConnectomeReader import analyse_connections

read_data = White_L4.read_data
read_muscle_data = White_L4.read_muscle_data
Expand Down
2 changes: 1 addition & 1 deletion c302/White_whole.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from c302.WhiteDataReader import White_whole

from c302.NeuroMLUtilities import analyse_connections
from c302.ConnectomeReader import analyse_connections

read_data = White_whole.read_data
read_muscle_data = White_whole.read_muscle_data
Expand Down
2 changes: 1 addition & 1 deletion c302/WitvlietDataReader1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Should be tidied up.

from c302.W_SpreadsheetDataReader import WitvlietDataReader
from c302.NeuroMLUtilities import analyse_connections
from c302.ConnectomeReader import analyse_connections

wdr = WitvlietDataReader("witvliet_2020_7.xlsx")

Expand Down
2 changes: 1 addition & 1 deletion c302/WitvlietDataReader2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Should be tidied up.

from c302.W_SpreadsheetDataReader import WitvlietDataReader
from c302.NeuroMLUtilities import analyse_connections
from c302.ConnectomeReader import analyse_connections

wdr = WitvlietDataReader("witvliet_2020_8.xlsx")

Expand Down
10 changes: 8 additions & 2 deletions c302/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import neuroml.writers as writers
import neuroml.loaders as loaders

import c302.bioparameters
# import c302.bioparameters

import airspeed

Expand All @@ -39,6 +39,7 @@

import json


import collections


Expand Down Expand Up @@ -1710,10 +1711,15 @@ def parse_dict_arg(dict_arg):


def main():
import importlib

print("Starting c302 v%s..." % __version__)
args = process_args()

exec("from c302.%s import ParameterisedModel" % args.parameters, globals())
ParameterisedModel = getattr(
importlib.import_module("c302.parameters_%s" % args.parameters),
"ParameterisedModel",
)
params = ParameterisedModel()
generate(
args.reference,
Expand Down
28 changes: 28 additions & 0 deletions c302/analyse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import sys
import matplotlib.pyplot as plt


fig = plt.figure(facecolor="#FFFFFF", edgecolor="#FFFFFF")
p = fig.add_subplot(111)


dat_file = sys.argv[1]

traces = open(dat_file, "r")
volts = {}

# Very inefficient...
for line in traces:
if not line.strip().startswith("#"):
points = line.split()
for i in range(len(points)):
if not volts.has_key(i):
volts[i] = []
volts[i].append(float(points[i]) + 0.0020 * i)

for cell_index in volts.keys():
if cell_index <= 302:
if cell_index > 0:
p.plot(volts[0], volts[cell_index])

plt.show()
11 changes: 8 additions & 3 deletions c302/c302_FW.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import os
import importlib

sys.path.insert(0, os.path.abspath("."))

Expand All @@ -21,7 +22,10 @@ def setup(
verbose=True,
config_param_overrides={},
):
exec("from c302.parameters_%s import ParameterisedModel" % parameter_set, globals())
ParameterisedModel = getattr(
importlib.import_module("c302.parameters_%s" % parameter_set),
"ParameterisedModel",
)
params = ParameterisedModel()

params.set_bioparameter(
Expand All @@ -34,13 +38,14 @@ def setup(
"unphysiological_offset_current_dur", "2000 ms", "Testing TapWithdrawal", "0"
)

"""
VA_motors = ["VA%s" % c for c in range_incl(1, 12)]
VB_motors = ["VB%s" % c for c in range_incl(1, 11)]
DA_motors = ["DA%s" % c for c in range_incl(1, 9)]
AS_motors = ["AS%s" % c for c in range_incl(1, 11)]"""
VB_motors = ["VB%s" % c for c in range_incl(1, 11)]
DB_motors = ["DB%s" % c for c in range_incl(1, 7)]
DD_motors = ["DD%s" % c for c in range_incl(1, 6)]
VD_motors = ["VD%s" % c for c in range_incl(1, 13)]
AS_motors = ["AS%s" % c for c in range_incl(1, 11)]

cells = list(["AVBL", "AVBR"] + DB_motors + VD_motors + VB_motors + DD_motors)

Expand Down
7 changes: 6 additions & 1 deletion c302/c302_Full.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import c302
import sys

import importlib


def setup(
parameter_set,
Expand All @@ -14,7 +16,10 @@ def setup(
config_param_overrides={},
verbose=True,
):
exec("from c302.parameters_%s import ParameterisedModel" % parameter_set, globals())
ParameterisedModel = getattr(
importlib.import_module("c302.parameters_%s" % parameter_set),
"ParameterisedModel",
)
params = ParameterisedModel()

# Some random set of neurons
Expand Down
9 changes: 7 additions & 2 deletions c302/c302_IClamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import sys
import neuroml.writers as writers

import importlib


def setup(
parameter_set,
Expand All @@ -17,11 +19,14 @@ def setup(
reference = "c302_%s_IClamp" % parameter_set
c302.print_("Setting up %s" % reference)

exec("from c302.parameters_%s import ParameterisedModel" % parameter_set, globals())
ParameterisedModel = getattr(
importlib.import_module("c302.parameters_%s" % parameter_set),
"ParameterisedModel",
)
params = ParameterisedModel()

stim_amplitudes = ["1pA", "2pA", "3pA", "4pA", "5pA", "6pA"]
if duration == None:
if duration is None:
duration = (len(stim_amplitudes)) * 1000

my_cells = ["ADAL", "PVCL"]
Expand Down
7 changes: 6 additions & 1 deletion c302/c302_IClampMuscle.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import c302
import sys

import importlib


def setup(
parameter_set,
Expand All @@ -12,7 +14,10 @@ def setup(
param_overrides={},
verbose=True,
):
exec("from c302.parameters_%s import ParameterisedModel" % parameter_set, globals())
ParameterisedModel = getattr(
importlib.import_module("c302.parameters_%s" % parameter_set),
"ParameterisedModel",
)
params = ParameterisedModel()

my_cells = []
Expand Down
12 changes: 8 additions & 4 deletions c302/c302_MultiSyns.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from c302 import generate, add_new_input
from c302 import generate, add_new_input, print_

import neuroml.writers as writers

import importlib
import sys


if __name__ == "__main__":
parameter_set = sys.argv[1] if len(sys.argv) == 2 else "A"

exec("from c302.parameters_%s import ParameterisedModel" % parameter_set, globals())
ParameterisedModel = getattr(
importlib.import_module("c302.parameters_%s" % parameter_set),
"ParameterisedModel",
)
params = ParameterisedModel()

cells = ["URYDL", "SMDDR", "ADAL", "RIML", "IL2VL", "RIPL"]
Expand All @@ -26,7 +30,7 @@
duration=1000,
dt=0.1,
target_directory=target_directory,
verbose=verbose,
verbose=True,
)

stim_amplitude = "0.35nA"
Expand All @@ -39,4 +43,4 @@
nml_doc, nml_file
) # Write over network file written above...

c302.print_("(Re)written network file to: " + nml_file)
print_("(Re)written network file to: " + nml_file)
13 changes: 9 additions & 4 deletions c302/c302_MuscleTest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import os
import importlib

sys.path.insert(0, os.path.abspath("."))

Expand All @@ -21,7 +22,10 @@ def setup(
verbose=True,
config_param_overrides={},
):
exec("from c302.parameters_%s import ParameterisedModel" % parameter_set, globals())
ParameterisedModel = getattr(
importlib.import_module("c302.parameters_%s" % parameter_set),
"ParameterisedModel",
)
params = ParameterisedModel()

params.set_bioparameter(
Expand All @@ -34,13 +38,14 @@ def setup(
"unphysiological_offset_current_dur", "2000 ms", "Testing TapWithdrawal", "0"
)

"""
VA_motors = ["VA%s" % c for c in range_incl(1, 12)]
VB_motors = ["VB%s" % c for c in range_incl(1, 11)]
DA_motors = ["DA%s" % c for c in range_incl(1, 9)]
DB_motors = ["DB%s" % c for c in range_incl(1, 7)]
DD_motors = ["DD%s" % c for c in range_incl(1, 6)]
VD_motors = ["VD%s" % c for c in range_incl(1, 13)]
AS_motors = ["AS%s" % c for c in range_incl(1, 11)]
AS_motors = ["AS%s" % c for c in range_incl(1, 11)]"""

cells = []

Expand Down Expand Up @@ -75,7 +80,7 @@ def setup(
"ca_conc_rho_muscle": "0.002138919 mol_per_m_per_A_per_s",
}

end = "%sms" % (int(duration) - 100)
# end = "%sms" % (int(duration) - 100)

input_list = []

Expand Down Expand Up @@ -174,4 +179,4 @@ def setup(
if len(sys.argv) == 3:
setup_kwargs["data_reader"] = sys.argv[2]

setup(parameter_set, generate=True, data_reader=data_reader)
# setup(parameter_set, generate=True, data_reader=data_reader)
7 changes: 6 additions & 1 deletion c302/c302_Muscles.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import c302
import sys

import importlib


def setup(
parameter_set,
Expand All @@ -13,7 +15,10 @@ def setup(
config_param_overrides={},
verbose=True,
):
exec("from c302.parameters_%s import ParameterisedModel" % parameter_set, globals())
ParameterisedModel = getattr(
importlib.import_module("c302.parameters_%s" % parameter_set),
"ParameterisedModel",
)
params = ParameterisedModel()

params.set_bioparameter(
Expand Down
6 changes: 5 additions & 1 deletion c302/c302_MusclesSine.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import c302
import sys
import importlib


def setup(
Expand All @@ -13,7 +14,10 @@ def setup(
config_param_overrides={},
verbose=True,
):
exec("from c302.parameters_%s import ParameterisedModel" % parameter_set, globals())
ParameterisedModel = getattr(
importlib.import_module("c302.parameters_%s" % parameter_set),
"ParameterisedModel",
)
params = ParameterisedModel()

params.set_bioparameter(
Expand Down
6 changes: 5 additions & 1 deletion c302/c302_Oscillator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import c302
import sys
import importlib


def setup(
Expand All @@ -13,7 +14,10 @@ def setup(
config_param_overrides={},
verbose=True,
):
exec("from c302.parameters_%s import ParameterisedModel" % parameter_set, globals())
ParameterisedModel = getattr(
importlib.import_module("c302.parameters_%s" % parameter_set),
"ParameterisedModel",
)
params = ParameterisedModel()

params.set_bioparameter("unphysiological_offset_current", "4pA", "Testing Osc", "0")
Expand Down
Loading

0 comments on commit 2ee6ae7

Please sign in to comment.