Read a blank dat_path as "no raw data file" - #61
Merged
Conversation
A dataset with no raw data file on disk has a blank dat_path in params.py.
SpikeInterface writes one for recordings with an unknown source, such as
simulated recordings.
Path('') is Path('.'), so a blank entry was resolved against dir_path and
silently became the dataset directory itself. The model then reported the
directory as its raw data file, and get_ephys_reader() warned twice about an
unknown file extension before giving up.
Drop blank entries instead, so dat_path ends up empty, which is the path the
model already supports for datasets with no raw data.
adityasingh2400
force-pushed
the
fix-57-empty-dat-path
branch
from
August 9, 2026 11:33
f32e426 to
45be9a2
Compare
rossant
approved these changes
Aug 9, 2026
rossant
left a comment
Contributor
There was a problem hiding this comment.
Reviewed the blank-path normalization and focused regressions. The implementation preserves existing non-empty path handling while preventing Path('') from resolving to the dataset directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #57.
A dataset with no raw data file on disk carries a blank
dat_pathinparams.py. SpikeInterface writes one when theRecordingobject has an unknown source, a simulated recording being the usual case, and this issue links SpikeInterface/spikeinterface#4569 for the downstream report.The
assert extthe issue points at is already gone, #58 turned it into a warning. What is left is quieter and, I think, the actual problem.Path('')isPath('.'), so_make_abs_path()resolves a blank entry againstdir_pathand it becomes the dataset directory. On current master, loading such a dataset gives you a model whosedat_pathis the directory it was loaded from,describe()reports that directory as the raw data file, andget_ephys_reader()logs "Unknown file extension" twice on a directory before returningNone. Downstream code that testsmodel.dat_pathto decide whether raw data exists gets the wrong answer.I read the surrounding code as already having an answer for this case.
_load_traces()returns early on an emptydat_path,merge.pysetsdat_path = []on purpose, andTemplateModel(dat_path='')already lands in that path because''is falsy. So a blankdat_pathis best read as "this dataset has no raw data file", which is a state phylib supports, rather than as an error. That also matters practically: raising here would stop phy from opening SpikeInterface outputs that it can open today, which is the "lots of sorting outputs which currently can't be read" concern in the issue.So this drops blank entries instead of resolving them.
_clean_dat_path()is shared betweenget_template_params()andTemplateModel.__init__()so theparams.pyroute and the direct kwargs route agree, and it handles blank entries inside a list too, for exampledat_path = ['', 'recording.dat']. The original non list wrapping semantics are kept exactly, this only adds the blank filter.Tests cover both the scalar and the list form, at the
get_template_params()level and end to end throughload_model(). Revertingphylib/io/model.pyto master makes both fail, the first asserting the dataset directory against an expected empty list.pytest phylibis green at 275, which is the 273 baseline plus these two.flake8 phylibreports 16 errors against a baseline of 17, so zero new. The one that disappeared is a pre-existing E501 on the oldself.dat_pathone liner, which had to be rewritten anyway.Disclosure: this change was prepared with AI assistance. I have reviewed and tested it.