Skip to content

Commit

Permalink
Filenames (#11)
Browse files Browse the repository at this point in the history
* account for filenames not being string

* fix docstr
  • Loading branch information
sappelhoff authored Oct 9, 2024
1 parent eb24384 commit 3cd1683
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion eeglabio/raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def export_set(fname, data, sfreq, ch_names, ch_locs=None, annotations=None,
EEGLAB of the existing reference, this method will not reference the
data for you.
ch_types : list of str | None
Channel types e.g. ‘EEG’, ‘MEG’, ‘EMG’, ‘ECG’, ‘Events’, ..
List of channel types, for example ``"EEG"``, ``"MEG"``, ``"ECG"``,
``"Events"``.
precision : "single" or "double"
Precision of the exported data (specifically EEG.data in EEGLAB)
Expand Down
16 changes: 13 additions & 3 deletions eeglabio/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pathlib
import logging

import numpy as np
Expand Down Expand Up @@ -178,18 +179,27 @@ def export_mne_raw(inst, fname, precision="single"):
Parameters
----------
inst : mne.io.BaseRaw
Raw instance to save
Raw instance to save.
fname : str
Name of the export file.
"""
from .raw import export_set

# load data first
inst.load_data()

# remove extra epoc and STI channels
chs_drop = [ch for ch in ['epoc'] if ch in inst.ch_names]
if 'STI 014' in inst.ch_names and \
not (inst.filenames[0].endswith('.fif')):

if isinstance(inst.filenames[0], pathlib.Path):
notfif = not (inst.filenames[0].suffix.endswith('.fif'))
elif isinstance(inst.filenames[0], str):
notfif = not inst.filenames[0].endswith('.fif')
else:
# assume not fif
notfif = True

if 'STI 014' in inst.ch_names and notfif:
chs_drop.append('STI 014')
inst.drop_channels(chs_drop)

Expand Down

0 comments on commit 3cd1683

Please sign in to comment.