@@ -59,7 +59,7 @@ you can replace :class:`MyFormatIO` by any implemented class, see :ref:`list_of_
59
59
Modes
60
60
======
61
61
62
- IO can be based on a single file, a directory containing files, or a database.
62
+ An IO module can be based on a single file, a directory containing files, or a database.
63
63
This is described in the :attr: `mode ` attribute of the IO class.
64
64
65
65
>>> from neo.io import MyFormatIO
@@ -108,84 +108,81 @@ All IOs have a read() method that returns a list of :class:`Block` objects (repr
108
108
>>> print bl[0].segments[0]
109
109
neo.core.Segment
110
110
111
-
111
+
112
112
Read a time slice of Segment
113
113
============================
114
114
115
- Some object support ``time_slice `` arguments in ``read_segment() ``.
116
- This is usefull to read only a subset of a dataset clipped in time.
115
+ Some objects support the ``time_slice `` argument in ``read_segment() ``.
116
+ This is useful to read only a subset of a dataset clipped in time.
117
117
By default ``time_slice=None `` meaning load eveything.
118
118
119
- This read everything::
119
+ This reads everything::
120
120
121
- seg = reader.load_segment(time_slice=None)
122
- shape0 = seg.analogsignals[0].shape # total shape
123
- shape1 = seg.spiketrains[0].shape # total shape
121
+ seg = reader.read_segment(time_slice=None)
124
122
125
-
126
- This read only the first 5 seconds::
123
+ This reads only the first 5 seconds::
127
124
128
- seg = reader.load_segment(time_slice=(0*pq.s, 5.*pq.s))
129
- shape0 = seg.analogsignals[0].shape # more small shape
130
- shape1 = seg.spiketrains[0].shape # more small shape
125
+ seg = reader.read_segment(time_slice=(0*pq.s, 5.*pq.s))
131
126
132
127
133
- Lazy option and proxy object
134
- ============================
128
+ .. _section-lazy :
129
+
130
+ Lazy option and proxy objects
131
+ =============================
135
132
136
133
In some cases you may not want to load everything in memory because it could be too big.
137
- For this scenario, some IOs implement ``lazy=True/False ``.
138
- Since neo 0.7, a new lazy sytem have been added for some IOs (all IOs that inherits rawio).
134
+ For this scenario, some IOs implement ``lazy=True/False ``.
135
+ Since neo 0.7, a new lazy sytem have been added for some IO modules (all IO classes that inherit from rawio).
139
136
To know if a class supports lazy mode use ``ClassIO.support_lazy ``.
140
137
141
- With ``lazy=True `` all data object (AnalogSignal/SpikeTrain/Event/Epoch) are replace by
142
- ProxyObjects (AnalogSignalProxy/SpikeTrainProxy/EventProxy/EpochProxy).
143
-
138
+ With ``lazy=True `` all data objects (AnalogSignal/SpikeTrain/Event/Epoch) are replaced by
139
+ proxy objects (AnalogSignalProxy/SpikeTrainProxy/EventProxy/EpochProxy).
144
140
145
141
By default (if not specified), ``lazy=False ``, i.e. all data is loaded.
146
142
147
- Theses ProxyObjects contain metadata (name, sampling_rate, id, ...) so they can be inspected
143
+ These proxy objects contain metadata (name, sampling_rate, id, ...) so they can be inspected
148
144
but they do not contain any array-like data.
149
- All ProxyObjects contain a ``load() `` method to postpone the real load of array like data.
145
+ All proxy objects contain a ``load() `` method to postpone the real load of array like data.
150
146
151
- Further more the ``load() `` method have a ``time_slice `` arguments to load only a slice
152
- from the file. So the consumption of memory can be finely controlled.
147
+ Further more the ``load() `` method has a ``time_slice `` argument to load only a slice
148
+ from the file. In this way the consumption of memory can be finely controlled.
153
149
154
150
155
- Here 2 examples that do read a dataset, load triggers a do trigger averaging on signals.
151
+ Here are two examples that read a dataset, extract sections of the signal based on recorded events,
152
+ and averages the sections.
156
153
157
- The first example is without lazy, so it consume more memory::
158
-
159
- lim0, lim1 = -500* pq.ms, +1500* pq.ms
154
+ The first example is without lazy mode , so it consumes more memory::
155
+
156
+ lim0, lim1 = -500 * pq.ms, +1500 * pq.ms
160
157
seg = reader.read_segment(lazy=False)
161
158
triggers = seg.events[0]
162
- anasig = seg.analogsignals[0] # here anasig contain the whole recording in memory
159
+ sig = seg.analogsignals[0] # here sig contain the whole recording in memory
163
160
all_sig_chunks = []
164
161
for t in triggers.times:
165
162
t0, t1 = (t + lim0), (t + lim1)
166
- anasig_chunk = anasig .time_slice(t0, t1)
167
- all_sig_chunks.append(anasig_chunk )
163
+ sig_chunk = sig .time_slice(t0, t1)
164
+ all_sig_chunks.append(sig_chunk )
168
165
apply_my_fancy_average(all_sig_chunks)
169
-
170
- The second example use lazy so it consume fewer memory::
166
+
167
+ The second example uses lazy mode, so it consumes less memory::
171
168
172
169
lim0, lim1 = -500*pq.ms, +1500*pq.ms
173
170
seg = reader.read_segment(lazy=True)
174
- triggers = seg.events[0].load(time_slice=None) # this load all trigers in memory
175
- anasigproxy = seg.analogsignals[0] # this is a proxy
171
+ triggers = seg.events[0].load(time_slice=None) # this loads all triggers in memory
172
+ sigproxy = seg.analogsignals[0] # this is a proxy
176
173
all_sig_chunks = []
177
174
for t in triggers.times:
178
175
t0, t1 = (t + lim0), (t + lim1)
179
- anasig_chunk = anasigproxy .load(time_slice=(t0, t1)) # here real data are loaded
180
- all_sig_chunks.append(anasig_chunk )
176
+ sig_chunk = sigproxy .load(time_slice=(t0, t1)) # here real data are loaded
177
+ all_sig_chunks.append(sig_chunk )
181
178
apply_my_fancy_average(all_sig_chunks)
182
179
183
- In addition to ``time_slice `` AnalogSignalProxy contains ``channel_indexes `` arguments .
184
- This control also slicing in channel . This is usefull in case the channel count is very high.
180
+ In addition to ``time_slice ``, AnalogSignalProxy supports the ``channel_indexes `` argument .
181
+ This allows loading only a subset of channels . This is useful where the channel count is very high.
185
182
186
183
.. TODO: add something about magnitude mode when implemented for all objects.
187
184
188
- In this example, we read only 3 selected channels::
185
+ In this example, we read only three selected channels::
189
186
190
187
seg = reader.read_segment(lazy=True)
191
188
anasig = seg.analogsignals[0].load(time_slice=None, channel_indexes=[0, 2, 18])
0 commit comments