From b25de47d6c46d1a1e2fc86d8272de1a83cee0f48 Mon Sep 17 00:00:00 2001
From: pgleeson
Date: Wed, 8 May 2024 16:59:15 +0100
Subject: [PATCH 1/4] More options on colours of conn matrix
---
c302/c302_utils.py | 62 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 49 insertions(+), 13 deletions(-)
diff --git a/c302/c302_utils.py b/c302/c302_utils.py
index 7cac4aa7..e1e7e0fd 100644
--- a/c302/c302_utils.py
+++ b/c302/c302_utils.py
@@ -350,7 +350,7 @@ def plot_c302_results(lems_results,
plt.close("all")
-def _show_conn_matrix(data, t, all_info_pre, all_info_post, type, save_figure_to=False, verbose=True, figsize=default_figsize):
+def _show_conn_matrix(data, t, all_info_pre, all_info_post, type, save_figure_to=False, verbose=True, figsize=default_figsize, colormap=None):
if data.shape[0]>0 and data.shape[1]>0 and np.amax(data)>0:
@@ -372,8 +372,12 @@ def _show_conn_matrix(data, t, all_info_pre, all_info_post, type, save_figure_to
fig.canvas.manager.set_window_title(title)
import matplotlib
#cm = matplotlib.cm.get_cmap('gist_stern_r')
- cmap = plt.colormaps['gist_stern_r']
- #cmap = plt.colormaps['gist_earth']
+ if colormap==None:
+ cmap = plt.colormaps['gist_stern_r']
+ else:
+ #cmap = plt.colormaps['gist_earth']
+ #cmap = plt.colormaps['nipy_spectral']
+ cmap = plt.colormaps[colormap]
im = plt.imshow(data, cmap=cmap, interpolation='nearest',norm=None)
@@ -409,7 +413,7 @@ def _show_conn_matrix(data, t, all_info_pre, all_info_post, type, save_figure_to
else:
c302.print_("Not saving figure", verbose)
-def generate_conn_matrix(nml_doc, save_fig_dir=None, verbose=False, figsize=default_figsize):
+def generate_conn_matrix(nml_doc, save_fig_dir=None, verbose=False, figsize=default_figsize, order_by_type=False, colormap=None):
net = nml_doc.networks[0]
@@ -458,6 +462,22 @@ def generate_conn_matrix(nml_doc, save_fig_dir=None, verbose=False, figsize=defa
c302.print_('Unable to connect to owmeta bundle: %s' % e)
traceback.print_exc()
+ '''
+ if order_by_type:
+ ordered_all_neuron_info = {}
+ order = ['(Se)','(InSe)','(In)','(Mo)']
+
+ for o in order:
+ for c in all_neuron_info:
+ print('Checking: %s'%str(all_neuron_info[c]))
+ if o in all_neuron_info[c][4]:
+ print('Adding: %s'%str(all_neuron_info[c]))
+ ordered_all_neuron_info[c] = all_neuron_info[c]
+
+
+ print('Swapping %s with %s'%(all_neuron_info,ordered_all_neuron_info))
+ all_neuron_info = ordered_all_neuron_info'''
+
all_neurons = []
all_muscles = []
for c in all_cells:
@@ -497,22 +517,26 @@ def generate_conn_matrix(nml_doc, save_fig_dir=None, verbose=False, figsize=defa
_show_conn_matrix(data_exc_n, 'Excitatory (non GABA) conns to neurons',all_neuron_info,all_neuron_info,
net.id, save_figure_to='%s/%s_exc_to_neurons.png'%(save_fig_dir,net.id) if save_fig_dir else None,
verbose=verbose,
- figsize=figsize)
+ figsize=figsize,
+ colormap=colormap)
_show_conn_matrix(data_exc_m, 'Excitatory (non GABA) conns to muscles',all_neuron_info,all_muscle_info,
net.id, save_figure_to='%s/%s_exc_to_muscles.png'%(save_fig_dir,net.id) if save_fig_dir else None,
verbose=verbose,
- figsize=figsize)
+ figsize=figsize,
+ colormap=colormap)
_show_conn_matrix(data_inh_n, 'Inhibitory (GABA) conns to neurons',all_neuron_info,all_neuron_info,
net.id, save_figure_to='%s/%s_inh_to_neurons.png'%(save_fig_dir,net.id) if save_fig_dir else None,
verbose=verbose,
- figsize=figsize)
+ figsize=figsize,
+ colormap=colormap)
_show_conn_matrix(data_inh_m, 'Inhibitory (GABA) conns to muscles',all_neuron_info,all_muscle_info,
net.id, save_figure_to='%s/%s_inh_to_muscles.png'%(save_fig_dir,net.id) if save_fig_dir else None,
verbose=verbose,
- figsize=figsize)
+ figsize=figsize,
+ colormap=colormap)
data_n = np.zeros((len(all_neurons),len(all_neurons)))
@@ -544,14 +568,16 @@ def generate_conn_matrix(nml_doc, save_fig_dir=None, verbose=False, figsize=defa
_show_conn_matrix(data_n, 'Electrical (gap junction) conns to neurons',all_neuron_info,all_neuron_info,
net.id, save_figure_to='%s/%s_elec_neurons_neurons.png'%(save_fig_dir,net.id) if save_fig_dir else None,
verbose=verbose,
- figsize=figsize)
+ figsize=figsize,
+ colormap=colormap)
if neuron_muscle:
_show_conn_matrix(data_n_m, 'Electrical (gap junction) conns between neurons and muscles', all_neuron_info, all_muscle_info,
net.id,
save_figure_to='%s/%s_elec_neurons_muscles.png' % (save_fig_dir, net.id) if save_fig_dir else None,
verbose=verbose,
- figsize=figsize)
+ figsize=figsize,
+ colormap=colormap)
if muscle_muscle:
_show_conn_matrix(data_m_m, 'Electrical (gap junction) conns between muscles', all_muscle_info,
@@ -560,7 +586,8 @@ def generate_conn_matrix(nml_doc, save_fig_dir=None, verbose=False, figsize=defa
save_figure_to='%s/%s_elec_muscles_muscles.png' % (
save_fig_dir, net.id) if save_fig_dir else None,
verbose=verbose,
- figsize=figsize)
+ figsize=figsize,
+ colormap=colormap)
#_show_conn_matrix(data_m, 'Electrical (gap junction) conns to muscles',all_neuron_info,all_muscle_info, net.id)
@@ -578,6 +605,7 @@ def generate_conn_matrix(nml_doc, save_fig_dir=None, verbose=False, figsize=defa
configs = ['c302_C0_Syns.net.nml', 'c302_C0_Social.net.nml','c302_C0_Muscles.net.nml','c302_C0_Pharyngeal.net.nml','c302_C0_Oscillator.net.nml','c302_C0_Full.net.nml']
figsize=(6.4,4.8)
+ colormap = None
if '-phar' in sys.argv:
@@ -587,6 +615,10 @@ def generate_conn_matrix(nml_doc, save_fig_dir=None, verbose=False, figsize=defa
configs = ['c302_C1_Oscillator.net.nml']
+ elif '-soc' in sys.argv:
+
+ configs = ['c302_C1_Social.net.nml']
+
elif '-musc' in sys.argv:
configs = ['c302_C1_Muscles.net.nml']
@@ -595,13 +627,17 @@ def generate_conn_matrix(nml_doc, save_fig_dir=None, verbose=False, figsize=defa
elif '-full' in sys.argv:
configs = ['c302_C1_Full.net.nml']
- figsize=(10,10)
+ figsize=(12,12)
+ colormap = 'nipy_spectral'
for c in configs:
nml_doc = read_neuroml2_file('examples/%s'%c)
- generate_conn_matrix(nml_doc, save_fig_dir='./examples/summary/images', figsize=figsize)
+ generate_conn_matrix(nml_doc,
+ save_fig_dir='./examples/summary/images',
+ figsize=figsize,
+ colormap=colormap)
if not '-nogui' in sys.argv:
plt.show()
From ecd01284535f62cad84502c1f6ff1a6d9a2d8f7e Mon Sep 17 00:00:00 2001
From: pgleeson
Date: Wed, 8 May 2024 16:59:49 +0100
Subject: [PATCH 2/4] Test on mac too
---
.github/workflows/non_omv.yml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/non_omv.yml b/.github/workflows/non_omv.yml
index 054b40bd..ef24168b 100644
--- a/.github/workflows/non_omv.yml
+++ b/.github/workflows/non_omv.yml
@@ -9,10 +9,11 @@ on:
jobs:
build:
- runs-on: ubuntu-latest
+ runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
- matrix:
+ matrix:
+ runs-on: [ubuntu-latest, macos-12, macos-latest ]
python-version: [ 3.7, 3.8, 3.9, "3.10" ]
steps:
From 59d29b21bec4e9b389b9ad63a70fed9cc2151e9e Mon Sep 17 00:00:00 2001
From: pgleeson
Date: Wed, 8 May 2024 17:33:40 +0100
Subject: [PATCH 3/4] Install HDF5 for pytables on macos-latest
---
.github/workflows/non_omv.yml | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/non_omv.yml b/.github/workflows/non_omv.yml
index ef24168b..f331ef8d 100644
--- a/.github/workflows/non_omv.yml
+++ b/.github/workflows/non_omv.yml
@@ -14,15 +14,21 @@ jobs:
fail-fast: false
matrix:
runs-on: [ubuntu-latest, macos-12, macos-latest ]
- python-version: [ 3.7, 3.8, 3.9, "3.10" ]
+ python-version: [ 3.8, 3.9, "3.10", "3.11" ]
steps:
- uses: actions/checkout@v4
+
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
+ - name: Install HDF5 for pytables on macos-latest
+ if: ${{ matrix.runs-on == 'macos-latest' }}
+ run: |
+ brew install hdf5
+
- name: Install OMV
run: |
pip install git+https://github.com/OpenSourceBrain/osb-model-validation
From 1f3e776ab516d2f00cc86e6af0c1561833679663 Mon Sep 17 00:00:00 2001
From: pgleeson
Date: Wed, 8 May 2024 18:17:00 +0100
Subject: [PATCH 4/4] Remove py3.11, owmeta not py3.11 compativble..
---
.github/workflows/non_omv.yml | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/non_omv.yml b/.github/workflows/non_omv.yml
index f331ef8d..918d6f36 100644
--- a/.github/workflows/non_omv.yml
+++ b/.github/workflows/non_omv.yml
@@ -14,7 +14,10 @@ jobs:
fail-fast: false
matrix:
runs-on: [ubuntu-latest, macos-12, macos-latest ]
- python-version: [ 3.8, 3.9, "3.10", "3.11" ]
+ python-version: [ 3.8, 3.9, "3.10" ]
+ exclude:
+ - runs-on: macos-latest
+ python-version: "3.8"
steps:
- uses: actions/checkout@v4
@@ -23,7 +26,7 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
-
+
- name: Install HDF5 for pytables on macos-latest
if: ${{ matrix.runs-on == 'macos-latest' }}
run: |