From 662a5cc680554aa7db327a625a59733010361134 Mon Sep 17 00:00:00 2001 From: sametSeckiiin Date: Mon, 6 Jul 2026 18:52:37 +0300 Subject: [PATCH 1/3] FIX: Preserve FIFF_NAME and allow None for active in proj I/O --- mne/_fiff/proj.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mne/_fiff/proj.py b/mne/_fiff/proj.py index cf01df3fdfb..708c96747e9 100644 --- a/mne/_fiff/proj.py +++ b/mne/_fiff/proj.py @@ -706,7 +706,14 @@ def _write_proj(fid, projs, *, ch_names_mapping=None): write_float(fid, FIFF.FIFF_PROJ_ITEM_TIME, 0.0) write_int(fid, FIFF.FIFF_PROJ_ITEM_NVEC, proj["data"]["nrow"]) - write_int(fid, FIFF.FIFF_MNE_PROJ_ITEM_ACTIVE, proj["active"]) + + if proj.get("desc") is not None: + write_string(fid, FIFF.FIFF_NAME, proj["desc"]) + + + if proj["active"] is not None: + val = 1 if proj["active"] else 0 + write_int(fid, FIFF.FIFF_MNE_PROJ_ITEM_ACTIVE, val) write_float_matrix(fid, FIFF.FIFF_PROJ_ITEM_VECTORS, proj["data"]["data"]) if proj["explained_var"] is not None: write_float(fid, FIFF.FIFF_MNE_ICA_PCA_EXPLAINED_VAR, proj["explained_var"]) From 4089c7594e974f570382d4cefbaa886e86ec41c8 Mon Sep 17 00:00:00 2001 From: sametSeckiiin Date: Wed, 8 Jul 2026 14:36:52 +0300 Subject: [PATCH 2/3] Fix round-trip descriptor preservation and remove redundant check --- mne/_fiff/proj.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mne/_fiff/proj.py b/mne/_fiff/proj.py index 708c96747e9..026d3f3bca5 100644 --- a/mne/_fiff/proj.py +++ b/mne/_fiff/proj.py @@ -585,11 +585,11 @@ def _read_proj(fid, node, *, ch_names_mapping=None, verbose=None): # else: # nchan = global_nchan - tag = find_tag(fid, item, FIFF.FIFF_DESCRIPTION) + tag = find_tag(fid, item, FIFF.FIFF_NAME) if tag is not None: desc = tag.data else: - tag = find_tag(fid, item, FIFF.FIFF_NAME) + tag = find_tag(fid, item, FIFF.FIFF_DESCRIPTION) if tag is not None: desc = tag.data else: @@ -707,9 +707,7 @@ def _write_proj(fid, projs, *, ch_names_mapping=None): write_int(fid, FIFF.FIFF_PROJ_ITEM_NVEC, proj["data"]["nrow"]) - if proj.get("desc") is not None: - write_string(fid, FIFF.FIFF_NAME, proj["desc"]) - + if proj["active"] is not None: val = 1 if proj["active"] else 0 From 90e01cb845a2f210333235539672fe0890a58c93 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 8 Jul 2026 11:40:31 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mne/_fiff/proj.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mne/_fiff/proj.py b/mne/_fiff/proj.py index 026d3f3bca5..c5f8ae5eb2c 100644 --- a/mne/_fiff/proj.py +++ b/mne/_fiff/proj.py @@ -706,9 +706,7 @@ def _write_proj(fid, projs, *, ch_names_mapping=None): write_float(fid, FIFF.FIFF_PROJ_ITEM_TIME, 0.0) write_int(fid, FIFF.FIFF_PROJ_ITEM_NVEC, proj["data"]["nrow"]) - - - + if proj["active"] is not None: val = 1 if proj["active"] else 0 write_int(fid, FIFF.FIFF_MNE_PROJ_ITEM_ACTIVE, val)