Skip to content

Commit 1792d69

Browse files
Merge branch 'master' into fix/neuralynxrawio_import
2 parents c3ae22d + 680c057 commit 1792d69

File tree

13 files changed

+456
-24
lines changed

13 files changed

+456
-24
lines changed

.circleci/config.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@ jobs:
5555
# run tests!
5656
- run:
5757
name: run tests
58+
no_output_timeout: 20m
5859
command: |
5960
. venv/bin/activate
60-
nosetests -v --with-coverage --cover-package=neo
61+
nosetests -v --with-coverage --cover-package=neo --debug=neo.test
62+
# note that we use --debug to get output while downloading files
63+
# without this, CircleCI tends to time out because there's no output for a long time
6164

6265
- run:
6366
name: coveralls

doc/source/grouping.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Each :class:`ChannelIndex` also contains the list of channels on which that neur
111111
block.channel_indexes.extend((chx0, chx1))
112112

113113

114-
Using :class:`ChannelView` and :class`Group`::
114+
Using :class:`ChannelView` and :class:`Group`::
115115

116116
import numpy as np
117117
from quantities import ms, mV, kHz
@@ -136,7 +136,7 @@ Using :class:`ChannelView` and :class`Group`::
136136
# assign each spiketrain to a neuron (now using Group)
137137
units = []
138138
for i, spiketrain in enumerate(spiketrains):
139-
unit = Group(spiketrain, name=f"Neuron #{i + 1}")
139+
unit = Group([spiketrain], name=f"Neuron #{i + 1}")
140140
units.append(unit)
141141

142142
# create a ChannelView of the signal for each unit, to show which channels the spikes come from
@@ -150,4 +150,4 @@ Using :class:`ChannelView` and :class`Group`::
150150

151151

152152
Now each putative neuron is represented by a :class:`Group` containing the spiktrains of that neuron
153-
and a view of the signal selecting only those channels from which the spikes were obtained.
153+
and a view of the signal selecting only those channels from which the spikes were obtained.

doc/source/rawio.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,17 @@ Read signal chunks of data and scale them::
114114

115115

116116
There are 3 ways to select a subset of channels: by index (0 based), by id or by name.
117-
By index is not ambiguous 0 to n-1 (included), for some IOs channel_names (and sometimes channel_ids) have no guarantees to
118-
be unique, in such cases it would raise an error.
117+
By index is unambiguous 0 to n-1 (included), whereas for some IOs channel_names
118+
(and sometimes channel_ids) have no guarantees to
119+
be unique. In such cases, using names or ids may raise an error.
120+
121+
A selected subset of channels which is passed to get_analog_signal_chunk, get_analog_signal_size,
122+
or get_analog_signal_t_start has the additional restriction that all such channels must have
123+
the same t_start and signal_size.
124+
125+
Such subsets of channels may be available in specific RawIOs by using the
126+
get_group_signal_channel_indexes method, if the RawIO has defined separate
127+
group_ids for each group with those common characteristics.
119128

120129
Example with BlackrockRawIO for the file FileSpec2.3001::
121130

neo/io/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
* :attr:`RawBinarySignalIO`
4949
* :attr:`RawMCSIO`
5050
* :attr:`Spike2IO`
51+
* :attr:`SpikeGLXIO`
5152
* :attr:`StimfitIO`
5253
* :attr:`TdtIO`
5354
* :attr:`TiffIO`
@@ -195,6 +196,10 @@
195196
196197
.. autoattribute:: extensions
197198
199+
.. autoclass:: SpikeGLXIO
200+
201+
.. autoattribute:: extensions
202+
198203
.. autoclass:: neo.io.StimfitIO
199204
200205
.. autoattribute:: extensions
@@ -273,6 +278,7 @@
273278
from neo.io.rawbinarysignalio import RawBinarySignalIO
274279
from neo.io.rawmcsio import RawMCSIO
275280
from neo.io.spike2io import Spike2IO
281+
from neo.io.spikeglxio import SpikeGLXIO
276282
from neo.io.stimfitio import StimfitIO
277283
from neo.io.tdtio import TdtIO
278284
from neo.io.tiffio import TiffIO
@@ -316,6 +322,7 @@
316322
RawBinarySignalIO,
317323
RawMCSIO,
318324
Spike2IO,
325+
SpikeGLXIO,
319326
StimfitIO,
320327
TdtIO,
321328
TiffIO,

neo/io/spikeglxio.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from neo.io.basefromrawio import BaseFromRaw
2+
from neo.rawio.spikeglxrawio import SpikeGLXRawIO
3+
4+
5+
class SpikeGLXIO(SpikeGLXRawIO, BaseFromRaw):
6+
__doc__ = SpikeGLXRawIO.__doc__
7+
mode = 'dir'
8+
9+
def __init__(self, dirname):
10+
SpikeGLXRawIO.__init__(self, dirname=dirname)
11+
BaseFromRaw.__init__(self, dirname)

neo/rawio/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* :attr:`RawBinarySignalRawIO`
2929
* :attr:`RawMCSRawIO`
3030
* :attr:`Spike2RawIO`
31+
* :attr:`SpikeGLXRawIO`
3132
* :attr:`TdtRawIO`
3233
* :attr:`WinEdrRawIO`
3334
* :attr:`WinWcpRawIO`
@@ -97,6 +98,10 @@
9798
9899
.. autoattribute:: extensions
99100
101+
.. autoclass:: neo.rawio.SpikeGLXRawIO
102+
103+
.. autoattribute:: extensions
104+
100105
.. autoclass:: neo.rawio.TdtRawIO
101106
102107
.. autoattribute:: extensions
@@ -129,6 +134,7 @@
129134
from neo.rawio.rawbinarysignalrawio import RawBinarySignalRawIO
130135
from neo.rawio.rawmcsrawio import RawMCSRawIO
131136
from neo.rawio.spike2rawio import Spike2RawIO
137+
from neo.rawio.spikeglxrawio import SpikeGLXRawIO
132138
from neo.rawio.tdtrawio import TdtRawIO
133139
from neo.rawio.winedrrawio import WinEdrRawIO
134140
from neo.rawio.winwcprawio import WinWcpRawIO
@@ -150,6 +156,7 @@
150156
RawBinarySignalRawIO,
151157
RawMCSRawIO,
152158
Spike2RawIO,
159+
SpikeGLXRawIO,
153160
TdtRawIO,
154161
WinEdrRawIO,
155162
WinWcpRawIO,

neo/rawio/baserawio.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,12 +654,32 @@ def _segment_t_stop(self, block_index, seg_index):
654654
###
655655
# signal and channel zone
656656
def _get_signal_size(self, block_index, seg_index, channel_indexes):
657+
"""
658+
Return the size of a set of AnalogSignals indexed by channel_indexes.
659+
660+
All channels indexed must have the same size and t_start.
661+
"""
657662
raise (NotImplementedError)
658663

659664
def _get_signal_t_start(self, block_index, seg_index, channel_indexes):
665+
"""
666+
Return the t_start of a set of AnalogSignals indexed by channel_indexes.
667+
668+
All channels indexed must have the same size and t_start.
669+
"""
660670
raise (NotImplementedError)
661671

662672
def _get_analogsignal_chunk(self, block_index, seg_index, i_start, i_stop, channel_indexes):
673+
"""
674+
Return the samples from a set of AnalogSignals indexed by channel_indexes.
675+
676+
All channels indexed must have the same size and t_start.
677+
678+
RETURNS
679+
-------
680+
array of samples, with each requested channel in a column
681+
"""
682+
663683
raise (NotImplementedError)
664684

665685
###

neo/rawio/examplerawio.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
* copy paste neo/rawio/tests/test_examplerawio.py and do the same
2626
2727
3. Step 3 : Create the neo.io class with the wrapper
28-
* Create a file in neo/io/ that endith with "io.py"
29-
* Create a that inherits both your RawIO class and BaseFromRaw class
28+
* Create a file in neo/io/ that ends with "io.py"
29+
* Create a class that inherits both your RawIO class and BaseFromRaw class
3030
* copy/paste from neo/io/exampleio.py
3131
3232
4.Step 4 : IO test
@@ -47,7 +47,7 @@ class ExampleRawIO(BaseRawIO):
4747
"""
4848
Class for "reading" fake data from an imaginary file.
4949
50-
For the user, it give acces to raw data (signals, event, spikes) as they
50+
For the user, it gives access to raw data (signals, event, spikes) as they
5151
are in the (fake) file int16 and int64.
5252
5353
For a developer, it is just an example showing guidelines for someone who wants
@@ -58,11 +58,11 @@ class ExampleRawIO(BaseRawIO):
5858
* Follow the :ref:`io_guiline`
5959
6060
This fake IO:
61-
* have 2 blocks
61+
* has 2 blocks
6262
* blocks have 2 and 3 segments
63-
* have 16 signal_channel sample_rate = 10000
64-
* have 3 unit_channel
65-
* have 2 event channel: one have *type=event*, the other have
63+
* has 16 signal_channels sample_rate = 10000
64+
* has 3 unit_channels
65+
* has 2 event channels: one has *type=event*, the other has
6666
*type=epoch*
6767
6868
@@ -98,7 +98,7 @@ def _source_name(self):
9898
def _parse_header(self):
9999
# This is the central of a RawIO
100100
# we need to collect in the original format all
101-
# informations needed for further fast acces
101+
# informations needed for further fast access
102102
# at any place in the file
103103
# In short _parse_header can be slow but
104104
# _get_analogsignal_chunk need to be as fast as possible
@@ -107,12 +107,12 @@ def _parse_header(self):
107107
# This is mandatory!!!!
108108
# gain/offset/units are really important because
109109
# the scaling to real value will be done with that
110-
# at the end real_signal = (raw_signal* gain + offset) * pq.Quantity(units)
110+
# at the end real_signal = (raw_signal * gain + offset) * pq.Quantity(units)
111111
sig_channels = []
112112
for c in range(16):
113113
ch_name = 'ch{}'.format(c)
114114
# our channel id is c+1 just for fun
115-
# Note that chan_id should be realated to
115+
# Note that chan_id should be related to
116116
# original channel id in the file format
117117
# so that the end user should not be lost when reading datasets
118118
chan_id = c + 1
@@ -121,9 +121,9 @@ def _parse_header(self):
121121
units = 'uV'
122122
gain = 1000. / 2 ** 16
123123
offset = 0.
124-
# group_id isonly for special cases when channel have diferents
124+
# group_id is only for special cases when channels have different
125125
# sampling rate for instance. See TdtIO for that.
126-
# Here this is the general case :all channel have the same characteritics
126+
# Here this is the general case: all channel have the same characteritics
127127
group_id = 0
128128
sig_channels.append((ch_name, chan_id, sr, dtype, units, gain, offset, group_id))
129129
sig_channels = np.array(sig_channels, dtype=_signal_channel_dtype)

0 commit comments

Comments
 (0)