MCPcopy
hub / github.com/mne-tools/mne-python / _write_annotations_csv

Function _write_annotations_csv

mne/annotations.py:1737–1756  ·  view source on GitHub ↗
(fname, annot)

Source from the content-addressed store, hash-verified

1735
1736
1737def _write_annotations_csv(fname, annot):
1738 annot = annot.to_data_frame()
1739 if "ch_names" in annot:
1740 annot["ch_names"] = [
1741 _safe_name_list(ch, "write", name=f'annot["ch_names"][{ci}')
1742 for ci, ch in enumerate(annot["ch_names"])
1743 ]
1744 extras_columns = set(annot.columns) - {
1745 "onset",
1746 "duration",
1747 "description",
1748 "ch_names",
1749 }
1750 for col in extras_columns:
1751 if len(dtypes := annot[col].apply(type).unique()) > 1:
1752 warn(
1753 f"Extra field '{col}' contains heterogeneous dtypes ({dtypes}). "
1754 "Loading these CSV annotations may not return the original dtypes."
1755 )
1756 annot.to_csv(fname, index=False)
1757
1758
1759def _write_annotations_txt(fname, annot):

Callers 1

saveMethod · 0.85

Calls 5

_safe_name_listFunction · 0.85
setFunction · 0.85
warnFunction · 0.85
to_data_frameMethod · 0.45
applyMethod · 0.45

Tested by

no test coverage detected