From b63b459b1b1636ee7755f5b480458c7e2eed0b1d Mon Sep 17 00:00:00 2001 From: samadpls Date: Sun, 28 Apr 2024 16:45:35 +0500 Subject: [PATCH] REF: update spike data format --- hnn_core/viz.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/hnn_core/viz.py b/hnn_core/viz.py index 16e3e8c548..f9da47e8ea 100644 --- a/hnn_core/viz.py +++ b/hnn_core/viz.py @@ -514,17 +514,13 @@ def plot_spikes_raster(cell_response, trial_idx=None, ax=None, show=True): _validate_type(trial_idx, list, 'trial_idx', 'int, list of int') # Extract desired trials - if len(cell_response._spike_times[0]) > 0: - spike_times = np.concatenate( - np.array(cell_response._spike_times, dtype=object)[trial_idx]) - spike_types = np.concatenate( - np.array(cell_response._spike_types, dtype=object)[trial_idx]) - spike_gids = np.concatenate( - np.array(cell_response._spike_gids, dtype=object)[trial_idx]) - else: - spike_times = np.array([]) - spike_types = np.array([]) - spike_gids = np.array([]) + spike_times = [] + spike_types = [] + spike_gids = [] + for trial in trial_idx: + spike_times.append(cell_response.spike_times[trial]) + spike_types.append(cell_response.spike_types[trial]) + spike_gids.append(cell_response.spike_gids[trial]) cell_types = ['L2_basket', 'L2_pyramidal', 'L5_basket', 'L5_pyramidal'] cell_type_colors = {'L5_pyramidal': 'r', 'L5_basket': 'b', @@ -539,10 +535,10 @@ def plot_spikes_raster(cell_response, trial_idx=None, ax=None, show=True): cell_type_gids = np.unique(spike_gids[spike_types == cell_type]) cell_type_times, cell_type_ypos = [], [] for gid in cell_type_gids: - gid_time = spike_times[spike_gids == gid] + gid_time = np.array(spike_times)[np.array(spike_gids) == gid] cell_type_times.append(gid_time) cell_type_ypos.append(ypos) - ypos = ypos - 1 + ypos -= 1 if cell_type_times: events.append(