Skip to content

Commit

Permalink
spikeglx.Reader(): add option to specify meta-data file
Browse files Browse the repository at this point in the history
  • Loading branch information
oliche committed Jun 19, 2023
1 parent faeb5ed commit 971f501
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# 0.6.0
## 0.6.2 2023-06-19
- add option to specify meta-data file for spikeglx.Reader

## 0.6.1 2023-06-06
- Fix bug in ADC cycles sampling for Neuropixel 1.0 probes
-
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name="ibl-neuropixel",
version="0.6.1",
version="0.6.2",
author="The International Brain Laboratory",
description="Collection of tools for Neuropixel 1.0 and 2.0 probes data",
long_description=long_description,
Expand Down
12 changes: 6 additions & 6 deletions src/spikeglx.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ class Reader:
"""

def __init__(self, sglx_file, open=True, nc=None, ns=None, fs=None, dtype='int16', s2v=None,
nsync=None, ignore_warnings=False):
nsync=None, ignore_warnings=False, meta_file=None):
"""
An interface for reading data from a SpikeGLX file
:param sglx_file: Path to a SpikeGLX file (compressed or otherwise), or to a meta-data file
:param open: when True the file is opened
"""
self.ignore_warnings = ignore_warnings
sglx_file = Path(sglx_file)
file_meta_data = sglx_file.with_suffix('.meta')
if file_meta_data == sglx_file:
meta_file = meta_file or sglx_file.with_suffix('.meta')
if meta_file == sglx_file:
# if a meta-data file is provided, try to get the binary file
self.file_bin = sglx_file.with_suffix('.cbin') if sglx_file.with_suffix('.cbin').exists() else None
self.file_bin = sglx_file.with_suffix('.bin') if sglx_file.with_suffix('.bin').exists() else None
Expand All @@ -57,7 +57,7 @@ def __init__(self, sglx_file, open=True, nc=None, ns=None, fs=None, dtype='int16
self.nbytes = self.file_bin.stat().st_size if self.file_bin else None
self.dtype = np.dtype(dtype)

if not file_meta_data.exists():
if not meta_file.exists():
# if no meta-data file is provided, try to get critical info from the binary file
# by seeing if filesize checks out with neuropixel 384 channels
if self.file_bin.stat().st_size / 384 % 2 == 0:
Expand Down Expand Up @@ -85,8 +85,8 @@ def __init__(self, sglx_file, open=True, nc=None, ns=None, fs=None, dtype='int16
self.channel_conversion_sample2v['samples'][-nsync:] = 1
else:
# normal case we continue reading and interpreting the metadata file
self.file_meta_data = file_meta_data
self.meta = read_meta_data(file_meta_data)
self.file_meta_data = meta_file
self.meta = read_meta_data(meta_file)
self.channel_conversion_sample2v = _conversion_sample2v_from_meta(self.meta)
self._raw = None
if open and self.file_bin:
Expand Down

0 comments on commit 971f501

Please sign in to comment.