-
Notifications
You must be signed in to change notification settings - Fork 271
Expand file tree
/
Copy pathneuralynxio.py
More file actions
104 lines (90 loc) · 3.73 KB
/
neuralynxio.py
File metadata and controls
104 lines (90 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
"""
Class for reading data from Neuralynx files.
This IO supports NCS, NEV and NSE file formats.
Depends on: numpy
Supported: Read
Author: Julia Sprenger, Carlos Canova
"""
import warnings
from neo.io.basefromrawio import BaseFromRaw
from neo.rawio.neuralynxrawio.neuralynxrawio import NeuralynxRawIO
class NeuralynxIO(NeuralynxRawIO, BaseFromRaw):
"""
Class for reading data from Neuralynx files.
This IO supports NCS, NEV, NSE and NTT file formats.
NCS contains signals for one channel
NEV contains events
NSE contains spikes and waveforms for mono electrodes
NTT contains spikes and waveforms for tetrodes
"""
_prefered_signal_group_mode = "group-by-same-units"
mode = "dir"
def __init__(
self,
dirname,
use_cache=False,
cache_path="same_as_resource",
include_filenames=None,
exclude_filenames=None,
keep_original_times=False,
gap_tolerance_ms=None,
strict_gap_mode=None,
filename=None,
exclude_filename=None,
):
"""
Initialise IO instance
Parameters
----------
dirname : str
Directory containing data files
filename : str
Deprecated and will be removed. Please use `include_filenames` instead
Name of a single ncs, nse, nev, or ntt file to include in dataset. Will be ignored,
if dirname is provided.
use_cache : bool, optional
Cache results of initial file scans for faster loading in subsequent runs.
Default: False
cache_path : str, optional
Folder path to use for cache files.
Default: 'same_as_resource'
exclude_filename: None,
Deprecated and will be removed. Please use `exclude_filenames` instead
include_filenames: str or list
Filename or list of filenames to be included. This can be absolute path or path relative to dirname.
exclude_filenames: str or list
Filename or list of filenames to be excluded. Expects base filenames without
directory path.
keep_original_times : bool
Preserve original time stamps as in data files. By default datasets are
shifted to begin at t_start = 0*pq.second.
Default: False
gap_tolerance_ms : float | None, default: None
Controls how timestamp gaps in NCS files are handled.
If None (default), a ValueError is raised when gaps are detected, with a
detailed gap report. If a float value is provided, gaps smaller than this
threshold (in milliseconds) are ignored, and gaps larger create new segments.
strict_gap_mode : bool | None, default: None
Deprecated. Use gap_tolerance_ms instead.
"""
if filename is not None:
warnings.warn("Deprecated and will be removed. Please use `include_filenames` instead")
include_filenames = [filename]
if exclude_filename is not None:
warnings.warn("Deprecated and will be removed. Please use `exclude_filenames` instead")
exclude_filenames = exclude_filename
NeuralynxRawIO.__init__(
self,
dirname=dirname,
include_filenames=include_filenames,
exclude_filenames=exclude_filenames,
keep_original_times=keep_original_times,
gap_tolerance_ms=gap_tolerance_ms,
strict_gap_mode=strict_gap_mode,
use_cache=use_cache,
cache_path=cache_path,
)
if self.rawmode == "one-dir":
BaseFromRaw.__init__(self, dirname)
elif self.rawmode == "multiple-files":
BaseFromRaw.__init__(self, include_filenames=include_filenames)