Skip to content

Commit

Permalink
Merge pull request #99 from openworm/development
Browse files Browse the repository at this point in the history
 To v0.9.1
  • Loading branch information
pgleeson authored Jan 21, 2025
2 parents ee1f681 + 25ab227 commit b27aa23
Show file tree
Hide file tree
Showing 686 changed files with 528 additions and 341 deletions.
1 change: 1 addition & 0 deletions .github/workflows/non_omv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
- name: Run test script
run: |
pip install ruff
./test.sh
- name: Final version info
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,4 @@ arm64
/examples/parametersweep/IClamp_GenericNeuronCellX__lems.xml
/examples/parametersweep/LEMS_SimCanonical_X.png
/examples/parametersweep/Canonical_X__lems.xml
/examples/parametersweep/average_last_1percent_GenericNeuronCellX.png
13 changes: 7 additions & 6 deletions c302/CompareMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ def getColumnsXls(fileIn):
# print(indexName[c])
while curr_row < num_rows:
curr_row += 1
row = worksheet.row(curr_row)
# row = worksheet.row(curr_row)
# print('Row:', curr_row)
curr_cell = -1
while curr_cell < num_cells:
curr_cell += 1
# Cell Types: 0=Empty, 1=Text, 2=Number, 3=Date, 4=Boolean, 5=Error, 6=Blank
cell_type = worksheet.cell_type(curr_row, curr_cell)
# cell_type = worksheet.cell_type(curr_row, curr_cell)
cell_value = str(worksheet.cell_value(curr_row, curr_cell))
# print(' ', cell_type, ':', cell_value)
cols[indexName[curr_cell]] += [cell_value]
Expand Down 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/NeuroMLUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def fract(a, b, f):


if __name__ == "__main__":
from SpreadsheetDataReader import read_data, read_muscle_data
# from SpreadsheetDataReader import read_data, read_muscle_data
from WormNeuroAtlasReader import read_data, read_muscle_data

cells, neuron_conns = read_data(include_nonconnected_cells=True)
Expand Down
6 changes: 3 additions & 3 deletions c302/OpenWormReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from owmeta.neuron import Neuron
from owmeta.muscle import BodyWallMuscle
from owmeta.worm import Worm
except:
except Exception:
print("owmeta not installed! Cannot run OpenWormReader")
exit()

Expand Down 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 Expand Up @@ -158,7 +158,7 @@ def format_muscle_name(muscle_name):
exit()

conn_map_OWR = {}
for c in conns:
for c in neuron_conns:
conn_map_OWR[c.short().lower()] = c

from c302.UpdatedSpreadsheetDataReader import read_data as read_data_usr
Expand Down
2 changes: 1 addition & 1 deletion c302/SpreadsheetDataReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

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

from xlrd import open_workbook
import os

spreadsheet_location = os.path.dirname(os.path.abspath(__file__)) + "/data/"

from c302 import print_

READER_DESCRIPTION = (
"""Data extracted from CElegansNeuronTables.xls for neuronal connectivity"""
Expand Down
17 changes: 12 additions & 5 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

try:
Expand All @@ -51,13 +52,14 @@
from owmeta.muscle import Muscle

owmeta_installed = True
except:

except Exception:
print("owmeta not installed! Proceeding anyway...")
owmeta_installed = False

try:
from urllib2 import URLError # Python 2
except:
except Exception:
from urllib.error import URLError # Python 3

logging.basicConfig()
Expand Down Expand Up @@ -519,7 +521,7 @@ def _get_cell_info(bnd, cells):
all_muscle_info = collections.OrderedDict()

if bnd is None:
if cached_owmeta_data == None:
if cached_owmeta_data is None:
print_("Loading owmeta cached data from: %s" % OWMETA_CACHED_DATA_FILE)
with open(OWMETA_CACHED_DATA_FILE) as f:
cached_owmeta_data = json.load(f)
Expand Down Expand Up @@ -1730,10 +1732,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.%s" % args.parameters),
"ParameterisedModel",
)
params = ParameterisedModel()
generate(
args.reference,
Expand Down
2 changes: 1 addition & 1 deletion c302/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.9.0"
__version__ = "0.9.1"
1 change: 0 additions & 1 deletion c302/analyse.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys
import matplotlib.pyplot as plt
from pylab import *


fig = plt.figure(facecolor="#FFFFFF", edgecolor="#FFFFFF")
Expand Down
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
Loading

0 comments on commit b27aa23

Please sign in to comment.