From 4d5f7e9a916171d2813a32fbd19139bf53489442 Mon Sep 17 00:00:00 2001 From: "Austin E. Soplata" Date: Wed, 20 May 2026 15:38:41 -0400 Subject: [PATCH 1/2] REF apply default colors in a few places, drop some comments --- doc/roadmap.md | 2 +- hnn_core/gui/_viz_manager.py | 10 ++++++---- hnn_core/network.py | 7 ------- hnn_core/network_models.py | 2 -- hnn_core/tests/test_viz.py | 4 ++-- hnn_core/viz.py | 10 ++++++++++ 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/doc/roadmap.md b/doc/roadmap.md index 7b2163f93e..4c17581257 100644 --- a/doc/roadmap.md +++ b/doc/roadmap.md @@ -27,7 +27,7 @@ interactive GUI is essential for all new users of HNN to develop an intuition on how to interact with the large-scale computational model to study the multi-scale neural dynamics underlying their MEG/EEG data. Once this intuition is gained, users who chose to can dive into the -computational neural modeling code, where further command line utily can +computational neural modeling code, where further command line utility can be developed. As such, an equal goal is to enable the neural modeling and coding community to participate in HNN development. We are prioritizing best practices in open-source software design and the diff --git a/hnn_core/gui/_viz_manager.py b/hnn_core/gui/_viz_manager.py index ceb4707030..5b3d7daea7 100644 --- a/hnn_core/gui/_viz_manager.py +++ b/hnn_core/gui/_viz_manager.py @@ -27,6 +27,7 @@ from hnn_core.dipole import _rmse, average_dipoles from hnn_core.gui._logging import logger +from hnn_core.network_models import default_drive_colors from hnn_core.viz import plot_dipole # @@ -295,18 +296,19 @@ def _update_ax(fig, ax, single_simulation, sim_name, plot_type, plot_config): if "evdist" in name: if "evdist" not in drive_locations.keys(): drive_locations["evdist"] = drive["location"] - drive_colors["evdist"] = "g" + drive_colors["evdist"] = default_drive_colors["distal"] # remove all increments of default 'evprox' inputs elif "evprox" in name: if "evprox" not in drive_locations.keys(): drive_locations["evprox"] = drive["location"] - drive_colors["evprox"] = "r" + drive_colors["evprox"] = default_drive_colors["proximal"] + else: drive_locations[name] = drive["location"] if drive["location"] == "proximal": - drive_colors[name] = "r" + drive_colors[name] = default_drive_colors["proximal"] elif drive["location"] == "distal": - drive_colors[name] = "g" + drive_colors[name] = default_drive_colors["distal"] # all drives to plot, excluding 'evdist' and 'evprox' increments all_drives = list(drive_locations.keys()) diff --git a/hnn_core/network.py b/hnn_core/network.py index ef817b8b30..444fdadac5 100644 --- a/hnn_core/network.py +++ b/hnn_core/network.py @@ -521,13 +521,6 @@ def __init__( ) else: # Default behavior - create standard network - """ - wip: - so why not put cell name direct right? - 1. will always need to create a cell object for using, might not satisfy the current problem solving reqs - 2. What if more added in the future? makes the code modular aka, future proof! - """ - # wip: getting it from network_models this time from .network_models import default_cell_metadata cell_types_default = { diff --git a/hnn_core/network_models.py b/hnn_core/network_models.py index 2bf237c57a..b4325fa99a 100644 --- a/hnn_core/network_models.py +++ b/hnn_core/network_models.py @@ -16,7 +16,6 @@ # serialisation / deserialisation) can import it without instantiating # a full Network object. -# colors are a wip placeholder that will change post dev meet discussion default_cell_metadata = { "L2_basket": { "morpho_type": "basket", @@ -56,7 +55,6 @@ }, } -# same, placeholder, wip default_drive_colors = { "proximal": "r", "distal": "g", diff --git a/hnn_core/tests/test_viz.py b/hnn_core/tests/test_viz.py index 720d5401f7..9ba78878c7 100644 --- a/hnn_core/tests/test_viz.py +++ b/hnn_core/tests/test_viz.py @@ -11,6 +11,8 @@ import hnn_core from hnn_core import read_params, jones_2009_model +from hnn_core.dipole import simulate_dipole +from hnn_core.network_models import default_cell_metadata from hnn_core.viz import ( plot_cells, plot_dipole, @@ -21,7 +23,6 @@ plot_drive_strength, NetworkPlotter, ) -from hnn_core.dipole import simulate_dipole matplotlib.use("agg") @@ -402,7 +403,6 @@ def _get_line_hex_colors(fig): # Default colors should come from cell metadata fig = net.cell_response.plot_spikes_raster(trial_idx=0, show=False) colors, labels = _get_line_hex_colors(fig) - from hnn_core.network_models import default_cell_metadata expected_cell_types = sorted(default_cell_metadata.keys()) expected_colors = [ diff --git a/hnn_core/viz.py b/hnn_core/viz.py index 6a7d5cbfc8..11377346c8 100644 --- a/hnn_core/viz.py +++ b/hnn_core/viz.py @@ -554,6 +554,7 @@ def plot_spikes_hist( _validate_type(color, (str, list, dict, None), "color", "str, list of str, or dict") + # Currently, we cannot use `hnn_core.network_models.default_cell_metadata` colors or `.default` if color is None: color_cycle = cycle(["r", "g", "b", "y", "m", "c"]) elif isinstance(color, str): @@ -571,6 +572,12 @@ def plot_spikes_hist( spike_label: list() for spike_label in np.unique(list(spike_labels.values())) } spike_color = dict() # Store colors specified for each spike_label + # NOTE: Currently, since `CellResponse` only contains the "type" (aka drive name or + # cell name) of what produced each spike, but not whether that drive was proximal or + # distal, there is currently no way to apply the coloring of + # `hnn_core.network_models.default_drive_colors` to the spikes in this plot. If + # `CellResponse` is ever guaranteed access to the `Network` information in the + # future, then this will be fixable. for spike_type, spike_label in spike_labels.items(): if spike_label not in spike_color: if isinstance(color, dict): @@ -582,6 +589,9 @@ def plot_spikes_hist( color[spike_label], str, "Dictionary values of color", "str" ) spike_color[spike_label] = color[spike_label] + elif spike_label in default_cell_metadata.keys(): + # Overwrite spike colors if the spikes come from true cells + spike_color[spike_label] = default_cell_metadata[spike_label]["color"] else: spike_color[spike_label] = next(color_cycle) spike_type_times[spike_label].extend(spike_times[spike_types_mask[spike_type]]) From 063be326aef1d91185d99efbdd0258d170c85a17 Mon Sep 17 00:00:00 2001 From: "Austin E. Soplata" Date: Thu, 21 May 2026 14:59:51 -0400 Subject: [PATCH 2/2] MAINT small doc changes and regen the main network --- hnn_core/param/jones2009_base.json | 18 +++++++++++++----- hnn_core/viz.py | 3 +-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/hnn_core/param/jones2009_base.json b/hnn_core/param/jones2009_base.json index 5a6963686e..41aa0d4a9e 100644 --- a/hnn_core/param/jones2009_base.json +++ b/hnn_core/param/jones2009_base.json @@ -81,7 +81,9 @@ "electro_type": "inhibitory", "layer": "2", "measure_dipole": false, - "reference": "https://doi.org/10.7554/eLife.51214" + "reference": "https://doi.org/10.7554/eLife.51214", + "color": "m", + "marker": "x" } }, "L2_pyramidal": { @@ -473,7 +475,9 @@ "electro_type": "excitatory", "layer": "2", "measure_dipole": true, - "reference": "https://doi.org/10.7554/eLife.51214" + "reference": "https://doi.org/10.7554/eLife.51214", + "color": "c", + "marker": "^" } }, "L5_basket": { @@ -550,7 +554,9 @@ "electro_type": "inhibitory", "layer": "5", "measure_dipole": false, - "reference": "https://doi.org/10.7554/eLife.51214" + "reference": "https://doi.org/10.7554/eLife.51214", + "color": "r", + "marker": "x" } }, "L5_pyramidal": { @@ -1144,7 +1150,7 @@ ] ], "nseg": 1, - "v0": -72, + "v0": -72.0, "mechs": { "hh2": { "gkbar_hh2": 0.01, @@ -1268,7 +1274,9 @@ "electro_type": "excitatory", "layer": "5", "measure_dipole": true, - "reference": "https://doi.org/10.7554/eLife.51214" + "reference": "https://doi.org/10.7554/eLife.51214", + "color": "b", + "marker": "^" } } }, diff --git a/hnn_core/viz.py b/hnn_core/viz.py index 11377346c8..ded4c5044e 100644 --- a/hnn_core/viz.py +++ b/hnn_core/viz.py @@ -12,7 +12,7 @@ def _get_cell_colors_from_metadata(cell_types_dict): - """Get color and marker mappings (WIP) from cell_metadata. + """Get color and marker mappings from cell_metadata. Parameters ---------- @@ -554,7 +554,6 @@ def plot_spikes_hist( _validate_type(color, (str, list, dict, None), "color", "str, list of str, or dict") - # Currently, we cannot use `hnn_core.network_models.default_cell_metadata` colors or `.default` if color is None: color_cycle = cycle(["r", "g", "b", "y", "m", "c"]) elif isinstance(color, str):