Skip to content

Commit e40c547

Browse files
committed
fix neuralynixio bug
1 parent e3cef2c commit e40c547

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

neo/rawio/neuralynxrawio/neuralynxrawio.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ class NeuralynxRawIO(BaseRawIO):
7979
filename: str, default: ''
8080
Name of a single ncs, nse, nev, or ntt file to include in dataset. Will be ignored,
8181
if dirname is provided. But one of either dirname or filename is required.
82+
include_filename: str | list | None, default: None
83+
Name of a single ncs, nse, nev or ntt file or list of such files. Will only include
84+
file names in the list. If this is full path, the direname will be sent to self.dirname.
85+
All files should be in a single path.
8286
exclude_filename: str | list | None, default: None
8387
Name of a single ncs, nse, nev or ntt file or list of such files. Expects plain
8488
filenames (without directory path).
@@ -143,8 +147,12 @@ def __init__(
143147
**kargs
144148
):
145149

146-
if (include_filename is not None) and (filename != ""):
147-
raise ValueError("filename and include_filenames cannot be both assigned")
150+
if include_filename is not None:
151+
if filename != "":
152+
raise ValueError("filename and include_filenames cannot be both assigned")
153+
include_filepath = [os.path.dirname(f) for f in include_filename]
154+
if len(include_filepath) > 1:
155+
raise ValueError("Files in include_filename must be in a single path!")
148156
if (include_filename is None) and (filename == "") and (dirname == ""):
149157
raise ValueError("One of dirname or filename or include_files must be provided.")
150158

@@ -177,7 +185,7 @@ def _source_name(self):
177185
return self.filename
178186
elif self.rawmode == "multiple-files":
179187
dirname = [os.path.dirname(x) for x in self.include_files]
180-
return dirname[0]
188+
return os.path.join(self.dirname, dirname[0])
181189
else:
182190
return self.dirname
183191

@@ -209,7 +217,8 @@ def _parse_header(self):
209217
event_annotations = []
210218

211219
if self.rawmode == "one-dir":
212-
filenames = sorted([f for f in os.listdir(self.dirname) if os.path.isfile(f) and not f.startswith('.')])
220+
filenames = sorted([os.path.join(self.dirname, f) for f in os.listdir(self.dirname)
221+
if os.path.isfile(os.path.join(self.dirname, f)) and not f.startswith('.')])
213222
elif self.rawmode == "one-file":
214223
filenames = [self.filename]
215224
else:

0 commit comments

Comments
 (0)