(fname, annot)
| 1735 | |
| 1736 | |
| 1737 | def _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 | |
| 1759 | def _write_annotations_txt(fname, annot): |
no test coverage detected