Changes to Ephys Schema#65
Conversation
1) map channel to electrode function 2) Fix bug in trace extraction (currently doesn't account for file boundaries 3) Add impedance measurement tables 4) Add STTC tables
…ies, STTC, ImpedanceMeasurements) - Move neo/quantities/elephant imports to lazy imports inside STTC.make() to avoid breaking the module in environments without these packages - Fix map_channel_to_electrode: restrict ElectrodeConfig.Electrode fetch by probe_type (was unrestricted), add conflict detection across multiple configs, and deduplicate consistent mappings safely - Fix LFP boundary trimming: replace elif with two independent if blocks so single-file sessions correctly trim both start and end boundaries - Replace # REMOVE LATER comment in STTC.make() with proper explanation - Fix ImpedanceMeasurements.make(): move EphysSessionProbe existence check before the fetch to prevent KeyError on empty result Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Potential memory crash in The spike time latency calculation uses: diff_matrix = np.abs(np.subtract.outer(spikes_A, spikes_B))
closest_spikes = np.min(diff_matrix, axis=1)This allocates a full
The existing STTC rows only cover low-firing units (unit 0 at ~1.8 Hz) so it hasn't crashed yet, but it will as soon as higher-firing units are included. Suggestion only: a memory-safe alternative using binary search ( sorted_B = np.sort(spikes_B)
idx = np.searchsorted(sorted_B, spikes_A, side='left')
left_idx = np.clip(idx - 1, 0, len(sorted_B) - 1)
right_idx = np.clip(idx, 0, len(sorted_B) - 1)
closest_spikes = np.minimum(
np.abs(spikes_A - sorted_B[left_idx]),
np.abs(spikes_A - sorted_B[right_idx]),
)
spike_time_latencies = closest_spikes[closest_spikes <= dt] |
|
Minor: Spike times are converted to integer milliseconds before being passed to spikes_A = (spike_times[i] * ...).astype(int)Two concerns:
|
There was a problem hiding this comment.
Review: ephys. prefix in foreign keys within ephys_no_curation.py
Two new table definitions in this PR use -> ephys.X to reference tables defined in this same file:
ImpedanceFile(line 518):-> ephys.EphysRawFileSTTC(line 1262):-> ephys.CuratedClustering
Why this is fragile: ephys is not imported in ephys_no_curation.py. The reference resolves only because the workflow's ephys.py sets linking_module=__name__ where from element_array_ephys import ephys_no_curation as ephys. Any other project activating this element without that exact alias will get a runtime resolution error.
Both tables should reference these classes directly since they live in the same module:
# ImpedanceFile (line 518)
-> EphysRawFile
# STTC (line 1262)
-> CuratedClusteringNote: STTC.make() already uses CuratedClustering.Unit & key (no prefix), confirming the inconsistency.
| """ | ||
|
|
||
| definition = """ | ||
| -> ephys.CuratedClustering |
There was a problem hiding this comment.
-> ephys.CuratedClustering uses ephys which is not defined in this file — it only resolves via the workflow's linking module alias (import ephys_no_curation as ephys). Since CuratedClustering is defined in this same file, use -> CuratedClustering directly. Same issue at line 518 for ImpedanceFile -> ephys.EphysRawFile → should be -> EphysRawFile.
@MilagrosMarin