Skip to content

Commit e1c9b35

Browse files
committed
WIP: nwb line length, Readme mention of
1 parent b62fd12 commit e1c9b35

File tree

2 files changed

+37
-24
lines changed

2 files changed

+37
-24
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@
33
+ This repository features DataJoint pipeline design for extracellular array electrophysiology,
44
with Neuropixels probe and Kilosort spike sorting method.
55

6-
+ The pipeline presented here is not a complete pipeline by itself, but rather a modular
7-
design of tables and dependencies specific to the extracellular electrophysiology workflow.
6+
+ The pipeline presented here is not a complete pipeline by itself, but rather a modular
7+
design of tables and dependencies specific to the extracellular electrophysiology
8+
workflow
89

910
+ This modular pipeline element can be flexibly attached downstream
1011
to any particular design of experiment session, thus assembling a fully functional
1112
ephys pipeline.
1213

14+
+ This Element provides three schema options, selected via the DataJoint config file, with `dj.config['custom']['ephys_mode']`
15+
+ `acute` probe insertion, with curated clustering
16+
+ `chronic` probe insertion, with curated clustering
17+
+ `no-curation`, with kilosort triggered clustering
18+
1319
+ See the [Element Array Electrophysiology documentation](https://elements.datajoint.org/description/array_ephys/) for the background information and development timeline.
1420

1521
+ For more information on the DataJoint Elements project, please visit https://elements.datajoint.org. This work is supported by the National Institutes of Health.

element_array_ephys/export/nwb/nwb.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def __init__(self, lfp_electrodes_query, chunk_length: int = 10000):
4242
----------
4343
lfp_electrodes_query: element_array_ephys.ephys.LFP.Electrode
4444
chunk_length: int, optional
45-
Chunks are blocks of disk space where data are stored contiguously and compressed
45+
Chunks are blocks of disk space where data are stored contiguously
46+
and compressed
4647
"""
4748
self.lfp_electrodes_query = lfp_electrodes_query
4849
self.electrodes = self.lfp_electrodes_query.fetch("electrode")
@@ -305,8 +306,8 @@ def add_ephys_units_to_nwb(
305306
def get_electrodes_mapping(electrodes):
306307
"""
307308
Create a mapping from the probe and electrode id to the row number of the electrodes
308-
table. This is used in the construction of the DynamicTableRegion that indicates what rows of the electrodes
309-
table correspond to the data in an ElectricalSeries.
309+
table. This is used in the construction of the DynamicTableRegion that indicates
310+
what rows of the electrodes table correspond to the data in an ElectricalSeries.
310311
311312
Parameters
312313
----------
@@ -359,18 +360,17 @@ def add_ephys_recording_to_nwb(
359360
end_frame: int = None,
360361
):
361362
"""
362-
Read voltage data directly from source files and iteratively transfer them to the NWB file. Automatically
363-
applies lossless compression to the data, so the final file might be smaller than the original, without
364-
data loss. Currently supports Neuropixels data acquired with SpikeGLX or Open Ephys, and relies on SpikeInterface to read the data.
363+
Read voltage data directly from source files and iteratively transfer them to the
364+
NWB file. Automatically applies lossless compression to the data, so the final file
365+
might be smaller than the original, without data loss. Currently supports
366+
Neuropixels data acquired with SpikeGLX or Open Ephys, and relies on SpikeInterface
367+
to read the data.
365368
366369
source data -> acquisition["ElectricalSeries"]
367370
368371
Parameters
369372
----------
370-
session_key: dict
371-
ephys_root_data_dir: str
372-
nwbfile: NWBFile
373-
end_frame: int, optional
373+
session_key: dict ephys_root_data_dir: str nwbfile: NWBFile end_frame: int, optional
374374
Used for small test conversions
375375
"""
376376

@@ -432,8 +432,12 @@ def add_ephys_lfp_from_dj_to_nwb(session_key: dict, nwbfile: pynwb.NWBFile):
432432
"""
433433
Read LFP data from the data in element-aray-ephys
434434
435-
ephys.LFP.Electrode::lfp -> processing["ecephys"].lfp.electrical_series["ElectricalSeries{insertion_number}"].data
436-
ephys.LFP::lfp_time_stamps -> processing["ecephys"].lfp.electrical_series["ElectricalSeries{insertion_number}"].timestamps
435+
ephys.LFP.Electrode::lfp ->
436+
processing["ecephys"].lfp.electrical_series["ElectricalSeries{insertion_number}"
437+
].data
438+
ephys.LFP::lfp_time_stamps ->
439+
processing["ecephys"].lfp.electrical_series["ElectricalSeries{insertion_number}"
440+
].timestamps
437441
438442
Parameters
439443
----------
@@ -478,7 +482,7 @@ def add_ephys_lfp_from_dj_to_nwb(session_key: dict, nwbfile: pynwb.NWBFile):
478482
def add_ephys_lfp_from_source_to_nwb(
479483
session_key: dict, ephys_root_data_dir, nwbfile: pynwb.NWBFile, end_frame=None):
480484
"""
481-
Read the LFP data directly from the source file. Currently, only works for SpikeGLX data.
485+
Read the LFP data from the source file. Currently, only works for SpikeGLX data.
482486
483487
ephys.EphysRecording::recording_datetime -> acquisition
484488
@@ -517,7 +521,8 @@ def add_ephys_lfp_from_source_to_nwb(
517521
extractor = extractors.read_spikeglx(os.path.split(file_path)[0], "imec.lf")
518522
else:
519523
raise ValueError(
520-
f"unsupported acq_software type: {ephys_recording_record['acq_software']}"
524+
"unsupported acq_software type:" +
525+
f"{ephys_recording_record['acq_software']}"
521526
)
522527

523528
if end_frame is not None:
@@ -567,7 +572,7 @@ def ecephys_session_to_nwb(
567572
----------
568573
session_key: dict
569574
raw: bool
570-
Whether to include the raw data from source. SpikeGLX and OpenEphys are supported
575+
Whether to include the raw data from source. SpikeGLX & OpenEphys are supported
571576
spikes: bool
572577
Whether to include CuratedClustering
573578
lfp:
@@ -576,13 +581,14 @@ def ecephys_session_to_nwb(
576581
False - do not convert LFP
577582
end_frame: int, optional
578583
Used to create small test conversions where large datasets are truncated.
579-
lab_key, project_key, and protocol_key: dictionaries used to look up optional additional metadata
584+
lab_key, project_key, and protocol_key: dictionaries to look up optional metadata
580585
nwbfile_kwargs: dict, optional
581-
- If element-session is not being used, this argument is required and must be a dictionary containing
582-
'session_description' (str), 'identifier' (str), and 'session_start_time' (datetime),
583-
the minimal data for instantiating an NWBFile object.
584-
585-
- If element-session is being used, this argument can optionally be used to add over overwrite NWBFile fields.
586+
- If element-session is not being used, this argument is required and must be a
587+
dictionary containing 'session_description' (str), 'identifier' (str), and
588+
'session_start_time' (datetime), the required minimal data for instantiating
589+
an NWBFile object.
590+
- If element-session is being used, this argument can optionally be used to
591+
overwrite NWBFile fields.
586592
"""
587593

588594
session_to_nwb = getattr(ephys._linking_module, 'session_to_nwb', False)
@@ -611,7 +617,8 @@ def ecephys_session_to_nwb(
611617
add_ephys_lfp_from_dj_to_nwb(session_key, nwbfile)
612618

613619
if lfp == "source":
614-
add_ephys_lfp_from_source_to_nwb(session_key, ephys_root_data_dir=ephys_root_data_dir,
620+
add_ephys_lfp_from_source_to_nwb(session_key,
621+
ephys_root_data_dir=ephys_root_data_dir,
615622
nwbfile=nwbfile, end_frame=end_frame)
616623

617624
return nwbfile

0 commit comments

Comments
 (0)