diff --git a/doc/roadmap.md b/doc/roadmap.md index 7b2163f93..4c1758125 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 ceb470703..5b3d7daea 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 ef817b8b3..444fdadac 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 2bf237c57..b4325fa99 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/param/jones2009_base.json b/hnn_core/param/jones2009_base.json index 5a6963686..41aa0d4a9 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/tests/test_viz.py b/hnn_core/tests/test_viz.py index 720d5401f..9ba78878c 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 6a7d5cbfc..ded4c5044 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 ---------- @@ -571,6 +571,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 +588,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]])