Skip to content

Commit 624b3c9

Browse files
committed
check if filenames is None and change them to list
1 parent 62a5512 commit 624b3c9

File tree

2 files changed

+13
-24
lines changed

2 files changed

+13
-24
lines changed

neo/io/neuralynxio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ def __init__(
6969
Default: False
7070
"""
7171

72-
if filename:
72+
if filename is not None:
7373
warnings.warn('Deprecated and will be removed. Please use `include_filenames` instead')
7474
include_filenames = [filename]
7575

76-
if exclude_filename:
76+
if exclude_filename is not None:
7777
warnings.warn('Deprecated and will be removed. Please use `exclude_filenames` instead')
7878
exclude_filenames = exclude_filename
7979

neo/rawio/neuralynxrawio/neuralynxrawio.py

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -149,44 +149,33 @@ def __init__(
149149
if not dirname:
150150
raise ValueError("`dirname` cannot be empty.")
151151

152-
if filename:
153-
include_filenames = filename
152+
if filename is not None:
153+
include_filenames = [filename]
154154
warnings.warn("`filename` is deprecated and will be removed. Please use `include_filenames` instead")
155155

156-
if exclude_filename:
157-
exclude_filenames = exclude_filename
156+
if exclude_filename is not None:
157+
if isinstance(exclude_filename, str):
158+
exclude_filenames = [exclude_filename]
159+
else:
160+
exclude_filenames = exclude_filename
158161
warnings.warn("`exclude_filename` is deprecated and will be removed. Please use `exclude_filenames` instead")
159162

160163
if include_filenames is None:
161164
include_filenames = []
162-
elif not isinstance(include_filenames, (list, set, np.ndarray)):
163-
include_filenames = [include_filenames]
164165

165166
if exclude_filenames is None:
166167
exclude_filenames = set()
167168
elif not isinstance(exclude_filenames, (list, set, np.ndarray)):
168169
exclude_filenames = {exclude_filenames}
169170

170-
if include_filenames:
171-
include_filepath = {os.path.dirname(f) for f in include_filenames}
172-
if len(include_filepath) > 1:
173-
raise ValueError("Files in include_filename must be in a single path!")
174-
175-
if dirname and include_filenames:
176-
dirname = os.path.join(dirname, os.path.dirname(include_filenames[0]))
177-
include_filenames = [os.path.basename(f) for f in include_filenames]
178-
179-
if exclude_filenames:
180-
exclude_filenames = {os.path.join(dirname, os.path.basename(f)) for f in exclude_filenames}
181-
182171
if include_filenames:
183172
self.rawmode = 'multiple-files'
184173
else:
185174
self.rawmode = "one-dir"
186175

187176
self.dirname = dirname
188177
self.include_filenames = include_filenames
189-
self.execlude_filenames = exclude_filenames
178+
self.exclude_filenames = exclude_filenames
190179
self.keep_original_times = keep_original_times
191180
self.strict_gap_mode = strict_gap_mode
192181
BaseRawIO.__init__(self, **kargs)
@@ -222,12 +211,11 @@ def _parse_header(self):
222211
event_annotations = []
223212

224213
if self.rawmode == "one-dir":
225-
filenames = sorted([os.path.join(self.dirname, f) for f in os.listdir(self.dirname)
226-
if os.path.isfile(os.path.join(self.dirname, f)) and not f.startswith('.')])
214+
filenames = [os.path.join(self.dirname, f) for f in os.listdir(self.dirname)]
227215
else:
228216
filenames = [os.path.join(self.dirname, f) for f in self.include_filenames]
229217

230-
filenames = [f for f in filenames if f not in self.execlude_filenames]
218+
filenames = [f for f in filenames if f not in self.exclude_filenames]
231219

232220
for filename in filenames:
233221
if not os.path.isfile(filename):
@@ -240,6 +228,7 @@ def _parse_header(self):
240228
stream_props = {} # {(sampling_rate, n_samples, t_start): {stream_id: [filenames]}
241229

242230
for filename in filenames:
231+
filename = os.path.join(self.dirname, filename)
243232
_, ext = os.path.splitext(filename)
244233
ext = ext[1:] # remove dot
245234
ext = ext.lower() # make lower case for comparisons

0 commit comments

Comments
 (0)