Skip to content

Commit

Permalink
Raise if file to be read doesn't exist - Tests still missing
Browse files Browse the repository at this point in the history
  • Loading branch information
hoechenberger committed Mar 22, 2021
1 parent 5abfc27 commit 60c47df
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions mne_bids/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
def _read_raw(raw_fpath, electrode=None, hsp=None, hpi=None,
allow_maxshield=False, config=None, verbose=None, **kwargs):
"""Read a raw file into MNE, making inferences based on extension."""
if not raw_fpath.exists():
raise FileNotFoundError(f'File or folder not found: {raw_fpath}')

_, ext = _parse_ext(raw_fpath)

# KIT systems
Expand Down Expand Up @@ -485,11 +488,11 @@ def read_raw_bids(bids_path, extra_params=None, verbose=True):
bids_fname = bids_path.fpath.name

if op.splitext(bids_fname)[1] == '.pdf':
bids_raw_folder = op.join(data_dir, f'{bids_path.basename}')
bids_fpath = glob.glob(op.join(bids_raw_folder, 'c,rf*'))[0]
config = op.join(bids_raw_folder, 'config')
bids_raw_folder = data_dir / f'{bids_path.basename}'
bids_fpath = list(bids_raw_folder.glob('c,rf*'))[0]
config = bids_raw_folder / 'config'
else:
bids_fpath = op.join(data_dir, bids_fname)
bids_fpath = data_dir / bids_fname
config = None

if extra_params is None:
Expand Down

0 comments on commit 60c47df

Please sign in to comment.