Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
else:
events = events[:, [0, 2]]
pybv.write_brainvision(data, fs, ch_names, name, parent, events=events)
# supported write file formats
# this dict contains each supported file extension as a key
# the corresponding value is a list with three elements: (1) the writer
# function, (2) the full file format name, and (3) a (comma-separated) string
# indicating the supported objects (currently either raw or epoch)
writers = {".fif": [write_fif, "Elekta Neuromag", "raw,epoch"],
".fif.gz": [write_fif, "Elekta Neuromag", "raw,epoch"],
".set": [write_set, "EEGLAB", "raw"]}
if have["pybv"]:
writers.update({".eeg": [write_bv, "BrainVision", "raw"]})
if have["pyedflib"]:
writers.update({".edf": [write_edf, "European Data Format", "raw"],
".bdf": [write_edf, "Biosemi Data Format", "raw"]})
def write_raw(fname, raw):
ext = "".join(Path(fname).suffixes)
if ext in writers:
writers[ext][0](fname, raw)
else:
raise ValueError(f"Unknown file type {ext}.")
"Elekta Neuromag": [".fif", ".fif.gz"],
"BrainVision": ".vhdr",
"EEGLAB": ".set",
"Neuroscan": ".cnt",
"EGI Netstation": ".mff",
"Nexstim eXimia": ".nxe"}
if have["pyxdf"]:
IMPORT_FORMATS["Extensible Data Format"] = [".xdf", ".xdfz", ".xdf.gz"]
EXPORT_FORMATS = {"Elekta Neuromag": ".fif",
"Elekta Neuromag compressed": ".fif.gz",
"EEGLAB": ".set"}
if have["pyedflib"]:
EXPORT_FORMATS["European Data Format"] = ".edf"
EXPORT_FORMATS["BioSemi Data Format"] = ".bdf"
if have["pybv"]:
EXPORT_FORMATS["BrainVision"] = ".eeg"
def image_path(fname):
"""Return absolute path to image fname."""
root = Path(__file__).parent.parent
return str((root / "images" / Path(fname)).resolve())
def split_fname(fname, ffilter):
"""Split file name into name and known extension parts.
Parameters
----------
fname : str or pathlib.Path
File name (can include full path).
def run_ica(self):
"""Run ICA calculation."""
methods = ["Infomax"]
if have["picard"]:
methods.insert(0, "Picard")
if have["sklearn"]:
methods.append("FastICA")
dialog = RunICADialog(self,
self.model.current["data"].info["nchan"],
methods)
if dialog.exec_():
calc = CalcDialog(self, "Calculating ICA", "Calculating ICA.")
method = dialog.method.currentText().lower()
exclude_bad_segments = dialog.exclude_bad_segments.isChecked()
fit_params = {}
if dialog.extended.isEnabled():
fit_params["extended"] = dialog.extended.isChecked()
if dialog.ortho.isEnabled():
def run_ica(self):
"""Run ICA calculation."""
methods = ["Infomax"]
if have["picard"]:
methods.insert(0, "Picard")
if have["sklearn"]:
methods.append("FastICA")
dialog = RunICADialog(self,
self.model.current["data"].info["nchan"],
methods)
if dialog.exec_():
calc = CalcDialog(self, "Calculating ICA", "Calculating ICA.")
method = dialog.method.currentText().lower()
exclude_bad_segments = dialog.exclude_bad_segments.isChecked()
fit_params = {}
if dialog.extended.isEnabled():