Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions neo/io/blackrockio_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,22 +232,22 @@ def __init__(self, filename, nsx_override=None, nev_override=None,
self._filenames = {}
if nsx_override:
self._filenames['nsx'] = re.sub(
os.path.extsep + 'ns[1,2,3,4,5,6]$', '', nsx_override)
os.path.extsep + r'ns[1,2,3,4,5,6]$', '', nsx_override)
else:
self._filenames['nsx'] = self.filename
if nev_override:
self._filenames['nev'] = re.sub(
os.path.extsep + 'nev$', '', nev_override)
os.path.extsep + r'nev$', '', nev_override)
else:
self._filenames['nev'] = self.filename
if sif_override:
self._filenames['sif'] = re.sub(
os.path.extsep + 'sif$', '', sif_override)
os.path.extsep + r'sif$', '', sif_override)
else:
self._filenames['sif'] = self.filename
if ccf_override:
self._filenames['ccf'] = re.sub(
os.path.extsep + 'ccf$', '', ccf_override)
os.path.extsep + r'ccf$', '', ccf_override)
else:
self._filenames['ccf'] = self.filename

Expand Down
2 changes: 1 addition & 1 deletion neo/io/elphyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -2985,7 +2985,7 @@ class LayoutFactory(object):

def __init__(self, elphy_file):
self.elphy_file = elphy_file
self.pattern = "\d{4}(\d+|\D)\D"
self.pattern = r"\d{4}(\d+|\D)\D"
self.block_subclasses = dict()

@property
Expand Down
2 changes: 1 addition & 1 deletion neo/io/neomatlabio.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def create_ob_from_struct(self, struct, classname):
if attrname in dict_attributes:
attrtype = dict_attributes[attrname][0]
if attrtype == datetime:
m = '(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+).(\d+)'
m = r'(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+).(\d+)'
r = re.findall(m, str(item))
if len(r) == 1:
item = datetime(*[int(e) for e in r[0]])
Expand Down
40 changes: 20 additions & 20 deletions neo/io/neuralynxio_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -1901,9 +1901,9 @@ def __read_text_header(self, filename, parameter_dict):
'Successfully decoded text header of file (%s).' % filename)

def __get_cheetah_version_from_txt_header(self, text_header, filename):
version_regex = re.compile('((-CheetahRev )|'
'(ApplicationName Cheetah "))'
'(?P<version>\d{1,3}\.\d{1,3}\.\d{1,3})')
version_regex = re.compile(r'((-CheetahRev )|'
r'(ApplicationName Cheetah "))'
r'(?P<version>\d{1,3}\.\d{1,3}\.\d{1,3})')
match = version_regex.search(text_header)
if match:
return match.groupdict()['version']
Expand All @@ -1913,27 +1913,27 @@ def __get_cheetah_version_from_txt_header(self, text_header, filename):

def __get_filename_and_times_from_txt_header(self, text_header, version):
if parse_version(version) <= parse_version('5.6.4'):
datetime1_regex = re.compile('## Time Opened \(m/d/y\): '
'(?P<date>\S+)'
' \(h:m:s\.ms\) '
'(?P<time>\S+)')
datetime2_regex = re.compile('## Time Closed \(m/d/y\): '
'(?P<date>\S+)'
' \(h:m:s\.ms\) '
'(?P<time>\S+)')
filename_regex = re.compile('## File Name (?P<filename>\S+)')
datetime1_regex = re.compile(r'## Time Opened \(m/d/y\): '
r'(?P<date>\S+)'
r' \(h:m:s\.ms\) '
r'(?P<time>\S+)')
datetime2_regex = re.compile(r'## Time Closed \(m/d/y\): '
r'(?P<date>\S+)'
r' \(h:m:s\.ms\) '
r'(?P<time>\S+)')
filename_regex = re.compile(r'## File Name (?P<filename>\S+)')

datetimeformat = '%m/%d/%Y %H:%M:%S.%f'

else:
datetime1_regex = re.compile('-TimeCreated '
'(?P<date>\S+) '
'(?P<time>\S+)')
datetime2_regex = re.compile('-TimeClosed '
'(?P<date>\S+) '
'(?P<time>\S+)')
filename_regex = re.compile('-OriginalFileName '
'"?(?P<filename>\S+)"?')
datetime1_regex = re.compile(r'-TimeCreated '
r'(?P<date>\S+) '
r'(?P<time>\S+)')
datetime2_regex = re.compile(r'-TimeClosed '
r'(?P<date>\S+) '
r'(?P<time>\S+)')
filename_regex = re.compile(r'-OriginalFileName '
r'"?(?P<filename>\S+)"?')

datetimeformat = '%Y/%m/%d %H:%M:%S'

Expand Down
2 changes: 1 addition & 1 deletion neo/rawio/brainvisionrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def read_brainvsion_soup(filename):
for line in f:
line = line.strip('\n').strip('\r')
if line.startswith('['):
section = re.findall('\[([\S ]+)\]', line)[0]
section = re.findall(r'\[([\S ]+)\]', line)[0]
all_info[section] = {}
continue
if line.startswith(';'):
Expand Down
14 changes: 7 additions & 7 deletions neo/rawio/elanrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def _parse_header(self):
# strange 2 line for datetime
# line1
l = f.readline()
r1 = re.findall('(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)', l)
r2 = re.findall('(\d+):(\d+):(\d+)', l)
r3 = re.findall('(\d+)-(\d+)-(\d+)', l)
r1 = re.findall(r'(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)', l)
r2 = re.findall(r'(\d+):(\d+):(\d+)', l)
r3 = re.findall(r'(\d+)-(\d+)-(\d+)', l)
YY, MM, DD, hh, mm, ss = (None,) * 6
if len(r1) != 0:
DD, MM, YY, hh, mm, ss = r1[0]
Expand All @@ -65,9 +65,9 @@ def _parse_header(self):

# line2
l = f.readline()
r1 = re.findall('(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)', l)
r2 = re.findall('(\d+):(\d+):(\d+)', l)
r3 = re.findall('(\d+)-(\d+)-(\d+)', l)
r1 = re.findall(r'(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)', l)
r2 = re.findall(r'(\d+):(\d+):(\d+)', l)
r3 = re.findall(r'(\d+)-(\d+)-(\d+)', l)
if len(r1) != 0:
DD, MM, YY, hh, mm, ss = r1[0]
elif len(r2) != 0:
Expand Down Expand Up @@ -146,7 +146,7 @@ def _parse_header(self):
self._event_labels = []
self._reject_codes = []
for l in f.readlines():
r = re.findall(' *(\d+) *(\d+) *(\d+) *', l)
r = re.findall(r' *(\d+) *(\d+) *(\d+) *', l)
self._raw_event_timestamps.append(int(r[0][0]))
self._event_labels.append(str(r[0][1]))
self._reject_codes.append(str(r[0][2]))
Expand Down
22 changes: 11 additions & 11 deletions neo/rawio/neuralynxrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ def read_txt_header(filename):
# find keys
info = OrderedDict()
for k1, k2, type_ in txt_header_keys:
pattern = '-(?P<name>' + k1 + ') (?P<value>[\S ]*)'
pattern = r'-(?P<name>' + k1 + r') (?P<value>[\S ]*)'
matches = re.findall(pattern, txt_header)
for match in matches:
if k2 == '':
Expand All @@ -583,14 +583,14 @@ def read_txt_header(filename):

# convert channel ids
if 'channel_ids' in info:
chid_entries = re.findall('\w+', info['channel_ids'])
chid_entries = re.findall(r'\w+', info['channel_ids'])
info['channel_ids'] = [int(c) for c in chid_entries]
else:
info['channel_ids'] = [name]

# convert channel names
if 'channel_names' in info:
name_entries = re.findall('\w+', info['channel_names'])
name_entries = re.findall(r'\w+', info['channel_names'])
if len(name_entries) == 1:
info['channel_names'] = name_entries * len(info['channel_ids'])
assert len(info['channel_names']) == len(info['channel_ids']), \
Expand All @@ -603,15 +603,15 @@ def read_txt_header(filename):

# convert bit_to_microvolt
if 'bit_to_microVolt' in info:
btm_entries = re.findall('\S+', info['bit_to_microVolt'])
btm_entries = re.findall(r'\S+', info['bit_to_microVolt'])
if len(btm_entries) == 1:
btm_entries = btm_entries * len(info['channel_ids'])
info['bit_to_microVolt'] = [float(e) * 1e6 for e in btm_entries]
assert len(info['bit_to_microVolt']) == len(info['channel_ids']), \
'Number of channel ids does not match bit_to_microVolt conversion factors.'

if 'InputRange' in info:
ir_entries = re.findall('\w+', info['InputRange'])
ir_entries = re.findall(r'\w+', info['InputRange'])
if len(ir_entries) == 1:
info['InputRange'] = [int(ir_entries[0])] * len(chid_entries)
else:
Expand All @@ -621,14 +621,14 @@ def read_txt_header(filename):

# filename and datetime
if info['version'] <= distutils.version.LooseVersion('5.6.4'):
datetime1_regex = '## Time Opened \(m/d/y\): (?P<date>\S+) \(h:m:s\.ms\) (?P<time>\S+)'
datetime2_regex = '## Time Closed \(m/d/y\): (?P<date>\S+) \(h:m:s\.ms\) (?P<time>\S+)'
filename_regex = '## File Name (?P<filename>\S+)'
datetime1_regex = r'## Time Opened \(m/d/y\): (?P<date>\S+) \(h:m:s\.ms\) (?P<time>\S+)'
datetime2_regex = r'## Time Closed \(m/d/y\): (?P<date>\S+) \(h:m:s\.ms\) (?P<time>\S+)'
filename_regex = r'## File Name (?P<filename>\S+)'
datetimeformat = '%m/%d/%Y %H:%M:%S.%f'
else:
datetime1_regex = '-TimeCreated (?P<date>\S+) (?P<time>\S+)'
datetime2_regex = '-TimeClosed (?P<date>\S+) (?P<time>\S+)'
filename_regex = '-OriginalFileName "?(?P<filename>\S+)"?'
datetime1_regex = r'-TimeCreated (?P<date>\S+) (?P<time>\S+)'
datetime2_regex = r'-TimeClosed (?P<date>\S+) (?P<time>\S+)'
filename_regex = r'-OriginalFileName "?(?P<filename>\S+)"?'
datetimeformat = '%Y/%m/%d %H:%M:%S'

original_filename = re.search(filename_regex, txt_header).groupdict()['filename']
Expand Down
2 changes: 1 addition & 1 deletion neo/rawio/neuroexplorerrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def read_as_dict(fid, dtype, offset=None):
if offset is not None:
fid.seek(offset)
dt = np.dtype(dtype)
h = np.fromstring(fid.read(dt.itemsize), dt)[0]
h = np.frombuffer(fid.read(dt.itemsize), dt)[0]
info = OrderedDict()
for k in dt.names:
v = h[k]
Expand Down
2 changes: 1 addition & 1 deletion neo/rawio/plexonrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def read_as_dict(fid, dtype, offset=None):
if offset is not None:
fid.seek(offset)
dt = np.dtype(dtype)
h = np.fromstring(fid.read(dt.itemsize), dt)[0]
h = np.frombuffer(fid.read(dt.itemsize), dt)[0]
info = OrderedDict()
for k in dt.names:
v = h[k]
Expand Down
2 changes: 1 addition & 1 deletion neo/rawio/spike2rawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def read_as_dict(fid, dtype):
Make conversion for strings.
"""
dt = np.dtype(dtype)
h = np.fromstring(fid.read(dt.itemsize), dt)[0]
h = np.frombuffer(fid.read(dt.itemsize), dt)[0]
info = OrderedDict()
for k in dt.names:
v = h[k]
Expand Down