inverse solution for resting state

Hi everyone.

I want to apply source reconstruction to MEG resting state. I calculated the noise covariance matrix from emptyroom.

Is the pipeline able to do this?

From inverse_target seems this case is not considered… or do I have misunderstood this?

Thanks as always :grin:

Hi Leonardo,

you specify the recording for covariance estimation as shown in this example.

noise_cov: (
tuple[float | None, float | None]
| Literal[β€œemptyroom”, β€œrest”, β€œad-hoc”]
| Callable[[BIDSPath], Covariance]
) = (None, 0)

Hope this was helpful.

Cheers,

Carina

Thanks Carina.

Actually I already defined

noise_cov = β€œemptyroom”

My question regards inverse_target and whether the pipeline is able to apply the inverse operator to resting state, given that in the documentation it says:

β€œCurrently, the only supported target is 'evoked'"

Hi Leonardo,

Sorry, I misunderstood your question, and you are absolutely right that the docs state it only accepts an evoked data object. Disclaimer: I never worked with the MNE-BIDS pipeline. A relatively easy but hacky way could be to epoch your resting state data (e.g. create one big epoch), average, and you have an evoked data object that you can apply the inverse operator on. There are configurations in the epoching step that address the epoching of resting state data, so this might be the intended way.

Another option is to apply your inverse solution to the raw data (preprocessed but not epoched) using MNE’s apply_inverse_raw. This is, however, outside of the MNE BIDS pipeline.

Hope this was more helpful,

I also pinged the MNE BIDS developer; I might have overlooked something in the BIDS pipeline.

@richard @sophie

Cheers,

Carina

Hello Carina,

thanks again. As you said, that could actually be the intended way!

Effectively the pipeline forces me to epoch the data even in the absence of events (somewhere I remember reading it was a design decision for ICA if I’m not wrong).

So maybe the inverse_target = [β€˜evoked’] takes into account also this case (β€˜evoked’ to me referred more strictly to an event-related paradigm, that’s why my doubt).

I fix some other issues than try this way. Anyway plan B will definitely be doing it outside the pipeline as you suggested.

Thanks a lot, let’s wait their feedback

Hi.

I tried as suggested, but this is the error:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”¬ source/_05_make_inverse ─────────────────────────────────────────────────────────────────────────────────────────────────
β”‚09:53:09β”‚ ❌ sub-063 ses-01 A critical error occurred. The error message was: missing in_files["evoked"] = /home/leozm/CRNL_projects/MNEBIDS_mimosa_criticality/data/sample_for_Leonardo/BIDS/derivatives/mne-bids-pipeline/sub-063/ses-01/meg/sub-063_ses-01_task-rest_ave.fif

Aborting pipeline run. The traceback is:

  File "/home/leozm/CRNL_projects/envs/MNEBIDS_mimosa_env/lib/python3.10/site-packages/mne_bids_pipeline/_run.py", line 55, in __mne_bids_pipeline_failsafe_wrapper__
    out = memory.cache(func)(*args, **kwargs)
  File "/home/leozm/CRNL_projects/envs/MNEBIDS_mimosa_env/lib/python3.10/site-packages/mne_bids_pipeline/_run.py", line 179, in wrapper
    hashes.append(hash_(k, v))
  File "/home/leozm/CRNL_projects/envs/MNEBIDS_mimosa_env/lib/python3.10/site-packages/mne_bids_pipeline/_run.py", line 456, in _path_to_str_hash
    assert v.exists(), f'missing {kind}_files["{k}"] = {v}'

Previously also in the source/_04_make_forward step the pipeline tried to retrieve the *task-rest_ave.fif file (which is never created). I could correct for it by setting

source_info_path_update = {

    'task' : 'noise',

    'processing' : 'clean',

    'suffix' :  'raw'

}

which is the input file of the noise covariance estimation.

I feel the only way is to set inverse_targets = [] and then use the inverse operator outside the pipeline.

Anyway, setting inverse_targets = [], the *task-rest_inv.fif file is created, but another error is then thrown

β”‚10:40:03β”‚ ❌ sub-063 ses-01 A critical error occurred. The error message was: 'NoneType' object has no attribute 'copy'

Aborting pipeline run. The traceback is:

  File "/home/leozm/CRNL_projects/envs/MNEBIDS_mimosa_env/lib/python3.10/site-packages/mne_bids_pipeline/steps/source/_05_make_inverse.py", line 110, in run_inverse
    conditions = _all_conditions(cfg=cfg)
  File "/home/leozm/CRNL_projects/envs/MNEBIDS_mimosa_env/lib/python3.10/site-packages/mne_bids_pipeline/_report.py", line 545, in _all_conditions
    conditions = cfg.conditions.copy()

within the MNE-BIDS-Pipeline, currently the only way to apply inverse is to apply it to evokeds, so you would need to either (1) create one big epoch and average it, or (2) create equally spaced events, epoch, and average the epochs.

You might also need to designate the ER file as a task="rest" condition rather than emptyroom, not sure.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.