Skip to content

Commit 727d4f2

Browse files
committed
add more docstrings
1 parent e121ed9 commit 727d4f2

25 files changed

+497
-236
lines changed

neo/io/basefromrawio.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def read_block(
8787
block_index: int, default: 0
8888
In the case of multiple blocks, the block_index specifies which block to read
8989
lazy: bool, default: False
90-
Whether to read the block lazily (True) or load into memory (false)
90+
Whether to read the block lazily (True) or load into memory (False)
9191
create_group_across_segment: bool | dict | None, default: None
9292
If True :
9393
* Create a neo.Group to group AnalogSignal segments
@@ -98,9 +98,8 @@ def read_block(
9898
* for example: create_group_across_segment = { 'AnalogSignal': True, 'SpikeTrain': False, ...}
9999
signal_group_mode: 'split-all' | 'group-by-same-units' | None, default: None
100100
This control behavior for grouping channels in AnalogSignal.
101-
* 'split-all': each channel will give an AnalogSignal
102-
* 'group-by-same-units' all channel sharing the same quantity units ar grouped in
103-
a 2D AnalogSignal
101+
* 'split-all': each channel will be give an AnalogSignal
102+
* 'group-by-same-units' all channel sharing the same quantity units are grouped in a 2D AnalogSignal
104103
By default None since the default is dependant on the IO
105104
load_waveforms: bool, default: False
106105
Determines whether SpikeTrains.waveforms is created
@@ -221,20 +220,19 @@ def read_segment(
221220
Whether to lazily load the segment (True) or to load the segment into memory (False)
222221
signal_group_mode: 'split-all' | 'group-by-same-units' | None, default: None
223222
This control behavior for grouping channels in AnalogSignal.
224-
* 'split-all': each channel will give an AnalogSignal
225-
* 'group-by-same-units' all channel sharing the same quantity units ar grouped in
226-
a 2D AnalogSignal
223+
* 'split-all': each channel will be give an AnalogSignal
224+
* 'group-by-same-units' all channel sharing the same quantity units are grouped in a 2D AnalogSignal
227225
load_waveforms: bool, default: False
228226
Determines whether SpikeTrains.waveforms is created
229-
time_slice: tuple[float | None] | None, default: None
227+
time_slice: tuple[quantity.Quantities | None] | None, default: None
230228
Whether to take a time slice of the data
231-
* None: indicates from beginning of segment to the end of the segment
229+
* None: indicates from beginning of the segment to the end of the segment
232230
* tuple: (t_start, t_stop) with t_start and t_stop being quantities in seconds
233231
* tuple: (None, t_stop) indicates the beginning of the segment to t_stop
234232
* tuple: (t_start, None) indicates from t_start to the end of the segment
235233
strict_slicing: bool, default: True
236234
Control if an error is raised or not when t_start or t_stop
237-
is outside the real time range of the segment.
235+
is outside of the real time range of the segment.
238236
239237
Returns
240238
-------
@@ -243,7 +241,7 @@ def read_segment(
243241
"""
244242

245243
if lazy:
246-
assert time_slice is None, "For lazy=True you must specify time_slice when LazyObject.load(time_slice=...)"
244+
assert time_slice is None, "For lazy=True you must specify a time_slice when LazyObject.load(time_slice=...)"
247245

248246
assert (
249247
not load_waveforms

neo/io/baseio.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def read(self, lazy: bool = False, **kargs):
135135
136136
Returns
137137
------
138-
block_list: list[neo.Block]
138+
block_list: list[neo.core.Block]
139139
Returns all the data from the file as Blocks
140140
"""
141141
if lazy and not self.support_lazy:
@@ -154,6 +154,17 @@ def read(self, lazy: bool = False, **kargs):
154154
raise NotImplementedError
155155

156156
def write(self, bl, **kargs):
157+
"""
158+
Writes a given block if IO supports writing
159+
160+
Parameters
161+
----------
162+
bl: neo.core.Block
163+
The neo Block to be written
164+
kargs: dict
165+
IO specific additional arguments
166+
167+
"""
157168
if Block in self.writeable_objects:
158169
if isinstance(bl, Sequence):
159170
assert hasattr(self, "write_all_blocks"), (

neo/rawio/alphaomegarawio.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,21 @@
4747
class AlphaOmegaRawIO(BaseRawIO):
4848
"""
4949
AlphaOmega MPX file format 4 reader. Handles several segments.
50-
51-
A segment is a continuous record (when record starts/stops).
52-
50+
A segment is a continuous recording (when recording starts/stops).
5351
Only files in current `dirname` are loaded, subfolders are not explored.
5452
55-
:param dirname: folder from where to load the data
56-
:type dirname: str or Path-like
57-
:param lsx_files: list of lsx files in `dirname` referencing mpx files to
58-
load (optional). If None (default), read all mpx files in `dirname`
59-
:type lsx_files: list of strings or None
60-
:param prune_channels: if True removes the empty channels, defaults to True
61-
:type prune_channels: bool
62-
63-
.. warning::
53+
Parameters
54+
----------
55+
dirname: str | Path
56+
The folder from which the data will be loaded
57+
lsx_files: list[str] | None, default: None
58+
List of lsx files in `dirname` referencing mpx files to load (optional)
59+
If None all mpx files will be read
60+
prune_channels: bool, default: True
61+
If True removes the empty channels
62+
63+
Notes
64+
-----
6465
Because channels must be gathered into coherent streams, channels names
6566
**must** be the default channel names in AlphaRS or Alpha LAB SNR
6667
software.

neo/rawio/axographrawio.py

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -174,52 +174,50 @@ class AxographRawIO(BaseRawIO):
174174
"""
175175
RawIO class for reading AxoGraph files (.axgd, .axgx)
176176
177-
Args:
178-
filename (string):
179-
File name of the AxoGraph file to read.
180-
force_single_segment (bool):
181-
Episodic files are normally read as multi-Segment Neo objects. This
182-
parameter can force AxographRawIO to put all signals into a single
183-
Segment. Default: False.
184-
185-
Example:
177+
Parameters
178+
----------
179+
filename: str
180+
File name of the AxoGraph file to read.
181+
force_single_segment: bool, default: False
182+
Episodic files are normally read as multi-Segment Neo objects. This
183+
parameter can force AxographRawIO to put all signals into a single
184+
Segment.
185+
186+
Examples
187+
--------
186188
>>> import neo
187-
>>> r = neo.rawio.AxographRawIO(filename=filename)
188-
>>> r.parse_header()
189-
>>> print(r)
189+
>>> reader = neo.rawio.AxographRawIO(filename=filename)
190+
>>> reader.parse_header()
191+
>>> print(reader)
190192
191193
>>> # get signals
192-
>>> raw_chunk = r.get_analogsignal_chunk(
193-
... block_index=0, seg_index=0,
194-
... i_start=0, i_stop=1024,
195-
... channel_names=channel_names)
196-
>>> float_chunk = r.rescale_signal_raw_to_float(
197-
... raw_chunk,
198-
... dtype='float64',
199-
... channel_names=channel_names)
194+
>>> raw_chunk = reader.get_analogsignal_chunk(block_index=0,
195+
... seg_index=0,
196+
... i_start=0,
197+
... i_stop=1024,
198+
... channel_names=channel_names)
199+
200+
>>> float_chunk = r.rescale_signal_raw_to_float(raw_chunk,
201+
... dtype='float64',
202+
... channel_names=channel_names)
200203
>>> print(float_chunk)
201204
202205
>>> # get event markers
203-
>>> ev_raw_times, _, ev_labels = r.get_event_timestamps(
204-
... event_channel_index=0)
205-
>>> ev_times = r.rescale_event_timestamp(
206-
... ev_raw_times, dtype='float64')
206+
>>> ev_raw_times, _, ev_labels = reader.get_event_timestamps(event_channel_index=0)
207+
>>> ev_times = reader.rescale_event_timestamp(ev_raw_times, dtype='float64')
207208
>>> print([ev for ev in zip(ev_times, ev_labels)])
208209
209210
>>> # get interval bars
210-
>>> ep_raw_times, ep_raw_durations, ep_labels = r.get_event_timestamps(
211-
... event_channel_index=1)
212-
>>> ep_times = r.rescale_event_timestamp(
213-
... ep_raw_times, dtype='float64')
214-
>>> ep_durations = r.rescale_epoch_duration(
215-
... ep_raw_durations, dtype='float64')
211+
>>> ep_raw_times, ep_raw_durations, ep_labels = reader.get_event_timestamps(event_channel_index=1)
212+
>>> ep_times = reader.rescale_event_timestamp(ep_raw_times, dtype='float64')
213+
>>> ep_durations = reader.rescale_epoch_duration(ep_raw_durations, dtype='float64')
216214
>>> print([ep for ep in zip(ep_times, ep_durations, ep_labels)])
217215
218216
>>> # get notes
219-
>>> print(r.info['notes'])
217+
>>> print(reader.info['notes'])
220218
221219
>>> # get other miscellaneous info
222-
>>> print(r.info)
220+
>>> print(reader.info)
223221
"""
224222

225223
name = "AxographRawIO"

neo/rawio/axonarawio.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,36 @@
3232

3333
class AxonaRawIO(BaseRawIO):
3434
"""
35-
Class for reading raw, continuous data from the Axona dacqUSB system:
35+
Class for reading raw, continuous data from the Axona dacqUSB system
36+
37+
Parameters
38+
----------
39+
filename: str
40+
The name of the *.bin file containing the data
41+
42+
Notes
43+
-----
44+
3645
http://space-memory-navigation.org/DacqUSBFileFormats.pdf
3746
3847
The raw data is saved in .bin binary files with an accompanying .set
3948
file about the recording setup (see the above manual for details).
4049
41-
Usage::
42-
43-
import neo.rawio
44-
r = neo.rawio.AxonaRawIO(filename=os.path.join(dir_name, base_filename))
45-
r.parse_header()
46-
print(r)
47-
raw_chunk = r.get_analogsignal_chunk(block_index=0, seg_index=0,
48-
i_start=0, i_stop=1024,
49-
channel_names=channel_names)
50-
float_chunk = reader.rescale_signal_raw_to_float(
51-
raw_chunk, dtype='float64',
52-
channel_indexes=[0, 3, 6]
53-
)
50+
Examples
51+
--------
52+
53+
>>> import neo.rawio
54+
>>> r = neo.rawio.AxonaRawIO(filename=os.path.join(dir_name, base_filename))
55+
>>> r.parse_header()
56+
>>> print(r)
57+
>>> raw_chunk = r.get_analogsignal_chunk(block_index=0,
58+
seg_index=0,
59+
i_start=0,
60+
i_stop=1024,
61+
channel_names=channel_names)
62+
>>> float_chunk = reader.rescale_signal_raw_to_float(raw_chunk,
63+
dtype='float64',
64+
channel_indexes=[0, 3, 6])
5465
5566
"""
5667

neo/rawio/axonrawio.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,29 @@
5353

5454

5555
class AxonRawIO(BaseRawIO):
56+
"""
57+
Class for Class for reading data from pCLAMP and AxoScope files (.abf version 1 and 2)
58+
59+
Parameters
60+
----------
61+
filename: str, default: ''
62+
The *.abf file to be read
63+
64+
Notes
65+
-----
66+
This code is a port of abfload and abf2load written in Matlab (BSD-2-Clause licence) by
67+
Copyright (c) 2009, Forrest Collman, [email protected]
68+
Copyright (c) 2004, Harald Hentschke
69+
70+
Examples
71+
--------
72+
73+
>>> import neo.rawio
74+
>>> reader = neo.rawio.AxonRawIO(filename='mydata.abf')
75+
>>> reader.parse_header()
76+
>>> print(reader)
77+
78+
"""
5679
extensions = ["abf"]
5780
rawmode = "one-file"
5881

0 commit comments

Comments
 (0)