Skip to content

Commit 21efc0e

Browse files
committed
docstring edits more rawios
1 parent 727d4f2 commit 21efc0e

File tree

9 files changed

+211
-73
lines changed

9 files changed

+211
-73
lines changed

neo/rawio/neuralynxrawio/neuralynxrawio.py

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,48 @@ class NeuralynxRawIO(BaseRawIO):
7070
This version works with rawmode of one-dir for a single directory of files or one-file for
7171
a single file.
7272
73-
Examples:
74-
>>> reader = NeuralynxRawIO(dirname='Cheetah_v5.5.1/original_data')
75-
>>> reader.parse_header()
76-
77-
Inspect all files in the directory.
78-
79-
>>> print(reader)
80-
81-
Display all information about signal channels, units, segment size....
73+
Parameters
74+
----------
75+
dirname: str, default: ''
76+
Name of directory containing all files for a dataset. If provided, filename is
77+
ignored. But one of either dirname or filename is required.
78+
filename: str, default: ''
79+
Name of a single ncs, nse, nev, or ntt file to include in dataset. Will be ignored,
80+
if dirname is provided. But one of either dirname or filename is required.
81+
exclude_filename: str | list | None, default: None
82+
Name of a single ncs, nse, nev or ntt file or list of such files. Expects plain
83+
filenames (without directory path).
84+
None will search for all file types
85+
keep_original_times: bool, default: False
86+
If True, keep original start time as in files,
87+
Otherwise set 0 of time to first time in dataset
88+
89+
Notes
90+
-----
91+
* This IO supports NCS, NEV, NSE and NTT file formats (not NVT or NRD yet)
92+
93+
* These variations of header format and possible differences between the stated sampling frequency
94+
and actual sampling frequency can create apparent time discrepancies in .Ncs files. Additionally,
95+
the Neuralynx recording software can start and stop recording while continuing to write samples
96+
to a single .Ncs file, which creates larger gaps in the time sequences of the samples.
97+
98+
* This RawIO attempts to correct for these deviations where possible and present a single section of
99+
contiguous samples with one sampling frequency, t_start, and length for each .Ncs file. These
100+
sections are determined by the NcsSectionsFactory class. In the
101+
event the gaps are larger, this RawIO only provides the samples from the first section as belonging
102+
to one Segment.
103+
104+
Examples
105+
--------
106+
>>> import neo.rawio
107+
>>> reader = neo.rawio.NeuralynxRawIO(dirname='Cheetah_v5.5.1/original_data')
108+
>>> reader.parse_header()
109+
110+
Inspect all files in the directory.
111+
112+
>>> print(reader)
113+
114+
Display all information about signal channels, units, segment size....
82115
"""
83116

84117
extensions = ["nse", "ncs", "nev", "ntt", "nvt", "nrd"] # nvt and nrd are not yet supported
@@ -93,24 +126,7 @@ class NeuralynxRawIO(BaseRawIO):
93126
]
94127

95128
def __init__(self, dirname="", filename="", exclude_filename=None, keep_original_times=False, **kargs):
96-
"""
97-
Initialize io for either a directory of Ncs files or a single Ncs file.
98-
99-
Parameters
100-
----------
101-
dirname: str
102-
name of directory containing all files for dataset. If provided, filename is
103-
ignored.
104-
filename: str
105-
name of a single ncs, nse, nev, or ntt file to include in dataset. Will be ignored,
106-
if dirname is provided.
107-
exclude_filename: str or list
108-
name of a single ncs, nse, nev or ntt file or list of such files. Expects plain
109-
filenames (without directory path).
110-
keep_original_times:
111-
if True, keep original start time as in files,
112-
otherwise set 0 of time to first time in dataset
113-
"""
129+
114130
if dirname != "":
115131
self.dirname = dirname
116132
self.rawmode = "one-dir"

neo/rawio/phyrawio.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,27 @@ class PhyRawIO(BaseRawIO):
2828
"""
2929
Class for reading Phy data.
3030
31-
Usage:
32-
>>> import neo.rawio
33-
>>> r = neo.rawio.PhyRawIO(dirname='/dir/to/phy/folder')
34-
>>> r.parse_header()
35-
>>> print(r)
36-
>>> spike_timestamp = r.get_spike_timestamps(block_index=0,
37-
... seg_index=0, spike_channel_index=0, t_start=None, t_stop=None)
38-
>>> spike_times = r.rescale_spike_timestamp(spike_timestamp, 'float64')
31+
Parameters
32+
----------
33+
dirname: str | Path, default: ''
34+
The dirname containing the phy data (.npy, .mat, .tsv. & .dat files)
35+
load_amplitudes: bool, default: False
36+
Whether to load the amplitude data
37+
load_pcs: bool, default: False
38+
Whether to load the pcs feature files (these are relatively big files)
39+
40+
Examples
41+
--------
42+
>>> import neo.rawio
43+
>>> r = neo.rawio.PhyRawIO(dirname='/dir/to/phy/folder')
44+
>>> r.parse_header()
45+
>>> print(r)
46+
>>> spike_timestamp = r.get_spike_timestamps(block_index=0,
47+
seg_index=0,
48+
spike_channel_index=0,
49+
t_start=None,
50+
t_stop=None)
51+
>>> spike_times = r.rescale_spike_timestamp(spike_timestamp, dtype='float64')
3952
4053
"""
4154

neo/rawio/plexon2rawio/plexon2rawio.py

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,42 @@ class Plexon2RawIO(BaseRawIO):
4646
"""
4747
Class for "reading" data from a PL2 file
4848
49-
Usage:
50-
>>> import neo.rawio
51-
>>> r = neo.rawio.Plexon2RawIO(filename='my_data.pl2')
52-
>>> r.parse_header()
53-
>>> print(r)
54-
>>> raw_chunk = r.get_analogsignal_chunk(block_index=0, seg_index=0,
55-
i_start=0, i_stop=1024, stream_index=0, channel_indexes=range(10))
56-
>>> float_chunk = r.rescale_signal_raw_to_float(raw_chunk, dtype='float64',
57-
channel_indexes=[0, 3, 6])
58-
>>> spike_timestamp = r.get_spike_timestamps(spike_channel_index=0, t_start=None,
59-
t_stop=None)
60-
>>> spike_times = r.rescale_spike_timestamp(spike_timestamp, 'float64')
61-
>>> ev_timestamps, _, ev_labels = r.get_event_timestamps(event_channel_index=0)
49+
Parameters
50+
----------
51+
filename: str | Path
52+
The *.pl2 file to be loaded
53+
pl2_dll_file_path: str | Path | None, default: None
54+
The path to the necessary dll for loading pl2 files
55+
If None will find correct dll for architecture and if it does not exist will download it
56+
57+
Notes
58+
-----
59+
* This IO is only partially lazy
60+
* The IO only considers enabled channels and will not list disabled channels in its header.
61+
* There is no 1-1 correspondence of PL2 spike channels and neo spike channels as each unit of
62+
a PL2 spike channel will be represented as an individual neo spike channel.
63+
64+
Examples
65+
--------
66+
>>> import neo.rawio
67+
>>> r = neo.rawio.Plexon2RawIO(filename='my_data.pl2')
68+
>>> r.parse_header()
69+
>>> print(r)
70+
>>> raw_chunk = r.get_analogsignal_chunk(block_index=0,
71+
seg_index=0,
72+
i_start=0,
73+
i_stop=1024,
74+
stream_index=0,
75+
channel_indexes=range(10))
76+
>>> float_chunk = r.rescale_signal_raw_to_float(raw_chunk,
77+
dtype='float64',
78+
stream_index=0,
79+
channel_indexes=[0, 3, 6])
80+
>>> spike_timestamp = r.get_spike_timestamps(spike_channel_index=0,
81+
t_start=None,
82+
t_stop=None)
83+
>>> spike_times = r.rescale_spike_timestamp(spike_timestamp, dtype='float64')
84+
>>> ev_timestamps, _, ev_labels = r.get_event_timestamps(event_channel_index=0)
6285
6386
"""
6487

neo/rawio/plexonrawio.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,27 @@ class PlexonRawIO(BaseRawIO):
5050
def __init__(self, filename="", progress_bar=True):
5151
"""
5252
53+
Class for reading non-pl2 plexon files
54+
5355
Parameters
5456
----------
55-
filename: str
56-
The filename.
57+
filename: str, default: ''
58+
The *.plx file to be loaded
5759
progress_bar: bool, default True
5860
Display progress bar using tqdm (if installed) when parsing the file.
5961
62+
Notes
63+
-----
64+
* Compatible with versions 100 to 106. Other versions have not been tested.
65+
* Note that Plexon now use a new format PL2 which is NOT supported by this IO.
66+
67+
Examples
68+
--------
69+
>>> import neo.rawio
70+
>>> r = neo.rawio.PlexonRawIO(filename='data.plx')
71+
>>> r.parse_header()
72+
>>> print(r)
73+
6074
"""
6175
BaseRawIO.__init__(self)
6276
self.filename = filename

neo/rawio/spikegadgetsrawio.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
1010
Note :
1111
* this file format have multiple version. news version include the gain for scaling.
12-
The actual implementation do not contain this feature because we don't have
13-
files to test this. So now the gain is "hardcoded" to 1. and so units
14-
is not handled correctly.
12+
The actual implementation does not contain this feature because we don't have
13+
files to test this. So now the gain is "hardcoded" to 1. and so units are
14+
not handled correctly.
1515
1616
The ".rec" file format contains:
17-
* a first text part with information in an XML structure
17+
* a first text part with information in an XML structure
1818
* a second part for the binary buffer
1919
2020
Author: Samuel Garcia
@@ -44,14 +44,30 @@ def __init__(self, filename="", selected_streams=None):
4444
4545
Initialize a SpikeGadgetsRawIO for a single ".rec" file.
4646
47-
Args:
48-
filename: str
49-
The filename
50-
selected_streams: None, list, str
51-
sublist of streams to load/expose to API
52-
useful for spikeextractor when one stream only is needed.
53-
For instance streams = ['ECU', 'trodes']
54-
'trodes' is name for ephy channel (ntrodes)
47+
Parameters
48+
----------
49+
filename: str, default: ''
50+
The *.rec file to be loaded
51+
selected_streams: str | list | None, default: None
52+
sublist of streams to load/expose to API, e.g., ['ECU', 'trodes']
53+
'trodes' is name for ephy channel (ntrodes)
54+
None will keep all streams
55+
56+
Notes
57+
-----
58+
This file format has multiple version. New versions include the gain for scaling.
59+
The current implementation does not contain this feature because we don't have
60+
files to test this. So now the gain is "hardcoded" to 1, and so units are
61+
not handled correctly.
62+
63+
Examples
64+
--------
65+
>>> import neo.rawio
66+
>>> reader = neo.rawio.SpikeGadgetRawIO(filename='data.rec') # all streams
67+
# just the electrode channels
68+
>>> reader_trodes = neo.rawio.SpikeGadgetRawIO(filename='data.rec', selected_streams='trodes')
69+
70+
5571
"""
5672
BaseRawIO.__init__(self)
5773
self.filename = filename

neo/rawio/spikeglxrawio.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,37 @@ class SpikeGLXRawIO(BaseRawIO):
6969
"""
7070
Class for reading data from a SpikeGLX system
7171
72-
dirname:
72+
Parameters
73+
----------
74+
dirname: str, default: ''
7375
The spikeglx folder containing meta/bin files
74-
load_sync_channel=False/True
75-
The last channel (SY0) of each stream is a fake channel used for synchronisation.
76+
load_sync_channel: bool, default: False
77+
The last channel (SY0) of each stream is a fake channel used for synchronisation
78+
load_channel_location: bool, default: False
79+
If True probeinterface is used to load the channel locations from the directory
80+
81+
Notes
82+
-----
83+
* Contrary to other implementations this IO reads the entire folder and subfolders and:
84+
deals with several segments based on the `_gt0`, `_gt1`, `_gt2`, etc postfixes
85+
deals with all signals "imec0", "imec1" for neuropixel probes and also
86+
external signal like"nidq". This is the "device"
87+
* For imec device both "ap" and "lf" are extracted so one device have several "streams"
88+
* There are several versions depending the neuropixel probe generation (`1.x`/`2.x`/`3.x`)
89+
* Here, we assume that the `meta` file has the same structure across all generations.
90+
* This IO is developed based on neuropixel generation 2.0, single shank recordings.
91+
92+
Examples
93+
--------
94+
>>> import neo.rawio
95+
>>> reader = neo.rawio.SpikeGLXRawIO(dirname='path/to/data/')
96+
>>> reader.parse_header()
97+
>>> print(reader)
98+
>>> raw_chunk = reader.get_analogsignal_chunk(block_index=0,
99+
seg_index=0,
100+
i_start=None,
101+
i_stop=None,
102+
stream_index=0)
76103
"""
77104

78105
# file formats used by spikeglxio

neo/rawio/tdtrawio.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,27 @@ class TdtRawIO(BaseRawIO):
4747

4848
def __init__(self, dirname="", sortname=""):
4949
"""
50-
Initialize reader for one or multiple TDT data blocks.
51-
52-
dirname (str, pathlib.Path):
53-
tank-directory of a dataset to be read as multiple segments OR single file of dataset.
54-
In the latter case only the corresponding segment will considered.
55-
sortname (str):
50+
Class for reading one or multiple TDT data blocks.
51+
52+
Parameters
53+
----------
54+
dirname: str | Path, default: None
55+
Tank-directory of a dataset to be read as multiple segments OR single file of dataset.
56+
In the latter case only the corresponding segment will be considered.
57+
sortname: str, default: ''
5658
'sortname' is used to specify the external sortcode generated by offline spike sorting.
5759
if sortname=='PLX', there should be a ./sort/PLX/*.SortResult file in the tdt block,
5860
which stores the sortcode for every spike
59-
Default: '', uses the original online sort.
60-
61+
'' will use original online sorting
62+
63+
Notes
64+
-----
65+
In a directory there are several files:
66+
* TSQ timestamp index of data
67+
* TBK some kind of channel info and maybe more
68+
* TEV contains data : spike + event + signal (for old version)
69+
* SEV contains signals (for new version)
70+
* ./sort/ can contain offline spikesorting label for spike and can be use place of TEV.
6171
6272
"""
6373
BaseRawIO.__init__(self)

neo/rawio/winedrrawio.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ class WinEdrRawIO(BaseRawIO):
2929
rawmode = "one-file"
3030

3131
def __init__(self, filename=""):
32+
"""
33+
Class for reading WinEdr data
34+
35+
Parameters
36+
----------
37+
filename: str, default: ''
38+
The *.edr file to be loaded
39+
40+
"""
3241
BaseRawIO.__init__(self)
3342
self.filename = filename
3443

neo/rawio/winwcprawio.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@
2323

2424

2525
class WinWcpRawIO(BaseRawIO):
26+
"""
27+
Class for reading WinWCP data
28+
29+
Parameters
30+
----------
31+
filename: str, default: ''
32+
The *.wcp file to load
33+
34+
"""
35+
2636
extensions = ["wcp"]
2737
rawmode = "one-file"
2838

0 commit comments

Comments
 (0)