Skip to content

Commit

Permalink
Renamed the channelindex attribute to channel_index
Browse files Browse the repository at this point in the history
  • Loading branch information
apdavison committed Feb 19, 2016
1 parent abca22f commit 185ac01
Show file tree
Hide file tree
Showing 27 changed files with 72 additions and 72 deletions.
6 changes: 3 additions & 3 deletions examples/generated_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def generate_block(n_segments=3, n_channels=8, n_units=3,

block = neo.Block()
block.segments = segments
block.channelindexes = [rcg]
block.channel_indexes = [rcg]

# Create synthetic data
for seg in segments:
Expand Down Expand Up @@ -87,7 +87,7 @@ def generate_block(n_segments=3, n_channels=8, n_units=3,

# We assume that our block has only 1 ChannelIndex and each
# RecordingChannel only has 1 AnalogSignal.
rcg = block.channelindexes[0]
rcg = block.channel_indexes[0]
for rc in rcg.recordingchannels:
print("Analysing channel %d: %s" % (rc.index, rc.name))

Expand Down Expand Up @@ -123,7 +123,7 @@ def generate_block(n_segments=3, n_channels=8, n_units=3,

# By ChannelIndex. Here we calculate a PSTH averaged over trials by
# channel location, blending all Units:
for rcg in block.channelindexes:
for rcg in block.channel_indexes:
stlist = []
for unit in rcg.units:
stlist.extend([st - st.t_start for st in unit.spiketrains])
Expand Down
6 changes: 3 additions & 3 deletions neo/core/analogsignal.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def __new__(cls, signal, units=None, dtype=None, copy=True,
obj._sampling_rate = _get_sampling_rate(sampling_rate, sampling_period)

obj.segment = None
obj.channelindex = None
obj.channel_index = None
return obj

def __init__(self, signal, units=None, dtype=None, copy=True,
Expand Down Expand Up @@ -258,8 +258,8 @@ def __repr__(self):
def get_channel_index(self):
"""
"""
if self.channelindex:
return self.channelindex.channel_indexes
if self.channel_index:
return self.channel_index.channel_indexes
else:
return None

Expand Down
4 changes: 2 additions & 2 deletions neo/core/baseneo.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def _reference_name(class_name):
`_container_name("Block")`.
"""
name_map = {
"ChannelIndex": "channelindex"
"ChannelIndex": "channel_index"
}
return name_map.get(class_name, class_name.lower())

Expand All @@ -141,7 +141,7 @@ def _container_name(class_name):
obtained by calling `_container_name_plural("Segment")`.
"""
name_map = {
"ChannelIndex": "channelindexes"
"ChannelIndex": "channel_indexes"
}
return name_map.get(class_name, _reference_name(class_name) + 's')

Expand Down
4 changes: 2 additions & 2 deletions neo/core/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class Block(Container):
>>> for ind in range(2):
... rcg = ChannelIndex(name='Array probe %d' % ind,
... channel_indexes=np.arange(64))
... blk.channelindexes.append(rcg)
... blk.channel_indexes.append(rcg)
...
>>> # Populate the Block with AnalogSignal objects
... for seg in blk.segments:
... for rcg in blk.channelindexes:
... for rcg in blk.channel_indexes:
... a = AnalogSignal(np.random.randn(10000, 64)*nA,
... sampling_rate=10*kHz)
... rcg.analogsignals.append(a)
Expand Down
2 changes: 1 addition & 1 deletion neo/core/irregularlysampledsignal.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def __new__(cls, times, signal, units=None, time_units=None, dtype=None,
obj.times = pq.Quantity(times, units=time_units,
dtype=float, copy=copy)
obj.segment = None
obj.channelindex = None
obj.channel_index = None

return obj

Expand Down
8 changes: 4 additions & 4 deletions neo/core/recordingchannelgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ class ChannelIndex(Container):
>>> for ind in range(2):
... rcg = ChannelIndex(name='Array probe %d' % ind,
... channel_indexes=np.arange(64))
... blk.channelindexes.append(rcg)
... blk.channel_indexes.append(rcg)
...
>>> # Populate the Block with AnalogSignal objects
... for seg in blk.segments:
... for rcg in blk.channelindexes:
... for rcg in blk.channel_indexes:
... a = AnalogSignal(np.random.randn(10000, 64)*nA,
... sampling_rate=10*kHz)
... rcg.analogsignals.append(a)
Expand All @@ -71,7 +71,7 @@ class ChannelIndex(Container):
... rcg = ChannelIndex(channel_names=np.array(['ch1', 'ch4', 'ch6']),
... channel_indexes = np.array([0, 3, 5])
>>> rcg.analogsignals.append(sig)
>>> blk.channelindexes.append(rcg)
>>> blk.channel_indexes.append(rcg)
*Usage 3* dealing with :class:`Unit` objects::
Expand All @@ -82,7 +82,7 @@ class ChannelIndex(Container):
>>>
>>> # Create a new ChannelIndex and add it to the Block
>>> rcg = ChannelIndex(name='octotrode A')
>>> blk.channelindexes.append(rcg)
>>> blk.channel_indexes.append(rcg)
>>>
>>> # create several Unit objects and add them to the
>>> # ChannelIndex
Expand Down
2 changes: 1 addition & 1 deletion neo/core/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def construct_subsegment_by_unit(self, unit_list=None):
>>>
>>> blk = Block()
>>> rcg = ChannelIndex(name='group0')
>>> blk.channelindexes = [rcg]
>>> blk.channel_indexes = [rcg]
>>>
>>> for ind in range(5):
... unit = Unit(name='Unit #%s' % ind, channel_index=ind)
Expand Down
6 changes: 3 additions & 3 deletions neo/core/unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ def __init__(self, name=None, description=None, file_origin=None,
'''
super(Unit, self).__init__(name=name, description=description,
file_origin=file_origin, **annotations)
self.channelindex = None
self.channel_index = None

def get_channel_indexes(self):
"""
"""
if self.channelindex:
return self.channelindex.channel_indexes
if self.channel_index:
return self.channel_index.channel_indexes
else:
return None
8 changes: 4 additions & 4 deletions neo/io/blackrockio.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def read_block(self, lazy=False, cascade=True, load_waveforms = False):
channel_id = st.annotations['channel_id']
index = None
for sig in seg.analogsignals:
if channel_id in sig.channelindex.channel_ids:
i = np.where(sig.channelindex.channel_ids==channel_id)[0][0]
if channel_id in sig.channel_index.channel_ids:
i = np.where(sig.channel_index.channel_ids==channel_id)[0][0]
index = sig.get_channel_index()[i]
break
if index is not None:
Expand All @@ -104,7 +104,7 @@ def read_block(self, lazy=False, cascade=True, load_waveforms = False):
unit = Unit(name=st.name)
unit.spiketrains.append(st)
rcg.units.append(unit)
bl.channelindexes.append(rcg)
bl.channel_indexes.append(rcg)

bl.create_many_to_one_relationship()

Expand Down Expand Up @@ -426,7 +426,7 @@ def read_nsx(self, filename_nsx, seg, lazy, cascade):
name=name,
file_origin=filename_nsx)
rcg.analogsignals.append(anasig)
anasig.channelindex = rcg
anasig.channel_index = rcg
seg.analogsignals.append(anasig)

def read_sif(self, filename_sif, seg, ):
Expand Down
4 changes: 2 additions & 2 deletions neo/io/blackrockio_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def read_block(self, lazy=False, cascade=True,
#~ # Add channel hierarchy
#~ rcg = ChannelIndex(name='allchannels',
#~ description='group of all channels', file_origin=self.filename)
#~ block.channelindexes.append(rcg)
#~ block.channel_indexes.append(rcg)
#~ self.channel_number_to_recording_channel = {}

#~ # Add each channel at a time to hierarchy
Expand Down Expand Up @@ -277,7 +277,7 @@ def channel_indexes_in_segment(seg):
channel_indices.append(sig.recordingchannel.index)

for asa in seg.analogsignals:
channel_indices.append(asa.channelindex.channel_indexes)
channel_indices.append(asa.channel_index.channel_indexes)

return channel_indices

Expand Down
4 changes: 2 additions & 2 deletions neo/io/brainwaredamio.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def read_block(self, lazy=False, cascade=True, **kargs):
channel_names=np.array(['Chan1'], dtype='S'))

# load objects into their containers
block.channelindexes.append(rcg)
block.channel_indexes.append(rcg)

# open the file
with open(self._path, 'rb') as fobject:
Expand All @@ -159,7 +159,7 @@ def read_block(self, lazy=False, cascade=True, **kargs):
break

# store the segment and signals
seg.analogsignals[0].channelindex = rcg
seg.analogsignals[0].channel_index = rcg
block.segments.append(seg)

# remove the file object
Expand Down
2 changes: 1 addition & 1 deletion neo/io/brainwaref32io.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def read_block(self, lazy=False, cascade=True, **kargs):
self.__unit = Unit(file_origin=self._filename)

# load objects into their containers
block.channelindexes.append(rcg)
block.channel_indexes.append(rcg)
rcg.units.append(self.__unit)

# initialize values
Expand Down
4 changes: 2 additions & 2 deletions neo/io/brainwaresrcio.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def __init__(self, filename=None):
self._blk = None

# This stores the current ChannelIndex for easy access
# It is equivalent to self._blk.channelindexes[0]
# It is equivalent to self._blk.channel_indexes[0]
self._rcg = None

# This stores the current Segment for easy access
Expand Down Expand Up @@ -296,7 +296,7 @@ def read_next_block(self, cascade=True, lazy=False, **kargs):
file_origin=self._file_origin,
elliptic=[], boundaries=[],
timestamp=[], max_valid=[])
self._blk.channelindexes.append(self._rcg)
self._blk.channel_indexes.append(self._rcg)
self._rcg.units.append(self._unit0)
self._blk.segments.append(self._seg0)

Expand Down
2 changes: 1 addition & 1 deletion neo/io/elphyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -4203,7 +4203,7 @@ def read_channelindex( self, episode ):
)
for spk in range(0, n_spikes) :
channel = self.read_channelindex(episode, spk)
group.channelindexes.append(channel)
group.channel_indexes.append(channel)
return group


Expand Down
22 changes: 11 additions & 11 deletions neo/io/hdf5io.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def _get_parent(self, path, ref, parent_type):

if parent_type.lower() in ('recordingchannel', 'unit'):
# We need to search all recording channels
path = block_path + '/channelindexes'
path = block_path + '/channel_indexes'
for n in self._data.iterNodes(path):
if not '_type' in n._v_attrs:
continue
Expand All @@ -547,9 +547,9 @@ def _get_parent(self, path, ref, parent_type):

if parent_type.lower() == 'segment':
path = block_path + '/segments'
elif parent_type.lower() in ('channelindex',
'channelindexes'):
path = block_path + '/channelindexes'
elif parent_type.lower() in ('channel_index',
'channel_indexes'):
path = block_path + '/channel_indexes'
else:
return ''

Expand All @@ -561,7 +561,7 @@ def _get_rcgs(self, path, ref):
parts = path.split('/')
object_folder = parts[-2]
block_path = '/'.join(parts[:-4])
path = block_path + '/channelindexes'
path = block_path + '/channel_indexes'
return self._search_parent(path, object_folder, ref, True)

def _search_parent(self, path, object_folder, ref, multi=False):
Expand Down Expand Up @@ -616,17 +616,17 @@ def load_lazy_cascade(self, path, lazy):
ppaths.append(None)
self.parent_paths[path] = ppaths
elif t == 'RecordingChannel':
if 'channelindexes' in node._v_attrs:
if 'channel_indexes' in node._v_attrs:
self.parent_paths[path] = node._f_getAttr(
'channelindexes')
'channel_indexes')

# Set parent objects
if path in self.parent_paths:
paths = self.parent_paths[path]

if t == 'RecordingChannel': # Set list of parnet channel groups
for rcg in self.parent_paths[path]:
o.channelindexes.append(
o.channel_indexes.append(
self.get(rcg, cascade='lazy', lazy=lazy))
else: # Set parents: Segment and another parent
if paths[0] is None:
Expand All @@ -650,7 +650,7 @@ def load_lazy_cascade(self, path, lazy):
if t == 'RecordingChannel':
rcg_paths = self._get_rcgs(path, ref)
for rcg in rcg_paths:
o.channelindexes.append(self.get(
o.channel_indexes.append(self.get(
rcg, cascade='lazy', lazy=lazy))
self.parent_paths[path] = rcg_paths
else:
Expand Down Expand Up @@ -812,15 +812,15 @@ def get_lazy_shape(obj, node):
# create at least One-to-Many
if obj_type == 'ChannelIndex' and not object_ref:
for r in relatives:
r.channelindexes = [obj]
r.channel_indexes = [obj]
# special processor for RC -> RCG
if obj_type == 'RecordingChannel':
if hasattr(node, '_v_parent'):
parent = node._v_parent
if hasattr(parent, '_v_parent'):
parent = parent._v_parent
if 'object_ref' in parent._v_attrs:
obj.channelindexes.append(self.get(
obj.channel_indexes.append(self.get(
parent._v_pathname, lazy=lazy))
return obj

Expand Down
4 changes: 2 additions & 2 deletions neo/io/kwikio.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ def read_block(self,

rcg = ChannelIndex(name='all channels',
channel_indexes=channel_index)
blk.channelindexes.append(rcg)
blk.channel_indexes.append(rcg)

ana = self.read_analogsignal(channel_index=channel_index,
lazy=lazy,
cascade=cascade)
ana.channelindex = rcg
ana.channel_index = rcg
seg.duration = (self._attrs['shape'][0]
/ self._attrs['kwik']['sample_rate']) * pq.s

Expand Down
2 changes: 1 addition & 1 deletion neo/io/neuroscopeio.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def read_block(self,
channel_indexes=np.arange(n_channels, dtype = int))
rcg.channel_ids = np.array([int(xml_rc.text) for xml_rc in xml_rcg])
rcg.channel_names = np.array(['Channel{0}'.format(id) for id in rcg.channel_ids], dtype = 'S')
bl.channelindexes.append(rcg)
bl.channel_indexes.append(rcg)

# AnalogSignals
reader = RawBinarySignalIO(filename = self.filename.replace('.xml', '.dat'))
Expand Down
6 changes: 3 additions & 3 deletions neo/io/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# Special case this tricky many-to-many relationship
# we still need links from recordingchannel to analogsignal
# for rcg in block.channelindexes:
# for rcg in block.channel_indexes:
# for rc in rcg.recordingchannels:
# rc.create_many_to_one_relationship()

Expand Down Expand Up @@ -65,11 +65,11 @@
# rcg = ChannelIndex(name='all channels',
# channel_indexes=indexes,
# channel_names=names)
# bl.channelindexes.append(rcg)
# bl.channel_indexes.append(rcg)
# for ind in indexes:
# # many to many relationship
# rcg.recordingchannels.append(recordingchannels[ind])
# recordingchannels[ind].channelindexes.append(rcg)
# recordingchannels[ind].channel_indexes.append(rcg)


def iteritems(D):
Expand Down
4 changes: 2 additions & 2 deletions neo/test/coretest/test_analogsignalarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,13 @@ def test__children(self):
self.assertEqual(signal._multi_parent_objects, ())

self.assertEqual(signal._single_parent_containers,
('segment', 'channelindex'))
('segment', 'channel_index'))
self.assertEqual(signal._multi_parent_containers, ())

self.assertEqual(signal._parent_objects,
('Segment', 'ChannelIndex'))
self.assertEqual(signal._parent_containers,
('segment', 'channelindex'))
('segment', 'channel_index'))

self.assertEqual(len(signal.parents), 2)
self.assertEqual(signal.parents[0].name, 'seg1')
Expand Down
Loading

0 comments on commit 185ac01

Please sign in to comment.