Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def import_bads(self, fname):
"""Import bad channels info from a CSV file."""
with open(fname) as f:
bads = f.read().replace(" ", "").strip().split(",")
unknown = set(bads) - set(self.current["data"].info["ch_names"])
if unknown:
msg = ("The following imported channel labels are not " +
"present in the data: " + ",".join(unknown))
raise LabelsNotFoundError(msg)
else:
self.current["data"].info["bads"] = bads
def import_file(self, f, text, ffilter="*"):
"""Import file."""
fname = QFileDialog.getOpenFileName(self, text, filter=ffilter)[0]
if fname:
try:
f(fname)
except LabelsNotFoundError as e:
QMessageBox.critical(self, "Channel labels not found", str(e))
except InvalidAnnotationsError as e:
QMessageBox.critical(self, "Invalid annotations", str(e))