# Error: Compensation grade of ICA (3) and Raw (0) do not match

**URL:** <https://mne.discourse.group/t/error-compensation-grade-of-ica-3-and-raw-0-do-not-match/11731>\
**Category:** Support & Discussions\
**Tags:** mne-bids-pipeline\
**Created:** [March 6, 2026, 9:53am UTC](https://mne.discourse.group/t/error-compensation-grade-of-ica-3-and-raw-0-do-not-match/11731 "2026-03-06T09:53:35Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![LeonardoMelloni](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/leonardomelloni/32/4668_2.png) [@LeonardoMelloni](https://mne.discourse.group/u/LeonardoMelloni)\
**Post date:** [March 11, 2026, 5:55pm UTC](https://mne.discourse.group/t/error-compensation-grade-of-ica-3-and-raw-0-do-not-match/11731/9 "2026-03-11T17:55:09Z")

</div>

> [@LeonardoMelloni](#):
>
> I’m considering to first correct for it in the BIDSification

I’m working on making a script for “re-BIDSifying” the data imposing the compensation grade to 0 for experimental data. Now I’m running into a strange behavior that I think can be summed up with the following MWE:

```python
from pathlib import Path

import mne

from mne_bids import (

    BIDSPath,

    read_raw_bids,

    write_raw_bids

)

old_bids_root = Path("/home/.../BIDS")

new_bids_root = Path("/home/.../BIDS_for_MNE-BIDS-Pipeline")

target_grade = 0

bp = BIDSPath(

    root=old_bids_root,

    subject="063",

    session="01",

    task="rest",

    run="01",

    datatype="meg"

)

raw = read_raw_bids(bids_path=bp, verbose=False)

print(f"Initial compensation grade: {raw.compensation_grade}")

raw.apply_gradient_compensation(target_grade)

new_bp = bp.copy().update(root=new_bids_root)

write_raw_bids(

        raw,

        bids_path=new_bp,

        overwrite=True,

        verbose=False

    )

new_raw = mne.io.read_raw_ctf(new_bp.fpath, preload=False)

print(f" → written {new_bp.fpath} with compensation grade {new_raw.compensation_grade}")

```

(NOTE: I created a new bids\_path to go around the issue signalled [here](https://mne.discourse.group/t/using-mne-bids-to-convert-ctf-data-to-bids-format/5336/17) )

But strangely the compensation grade of the new raw is still 3:

```python
Initial compensation grade: 3
Compensator constructed to change 3 → 0
...
Current compensation grade : 3
→ written /home/.../BIDS_for_MNE-BIDS-Pipeline/sub-063/ses-01/meg/sub-063_ses-01_task-rest_run-01_meg.ds with compensation grade 3

```

In the sidecar json:

```json
"SoftwareFilters": {

        "SpatialCompensation": {

            "GradientOrder": 0

        }

    }

```

Why this happens? I saw I could impose in write\_raw\_bids to have format = ‘FIF’ and that would solve the issue, but I would prefer to keep .ds

---

_[View the full topic](https://mne.discourse.group/t/error-compensation-grade-of-ica-3-and-raw-0-do-not-match/11731)._
