Problem running mne-bids-pipeline when no EEG or additional points on the head were digitized

Dear MNE developers,

My problem is related to the Maxfilter step of mne_bids_pipeline.

  • MNE version: 1.5.1
  • operating system: macOS 12.2.1

When running mne_bids_pipeline for some MEG data where I just recorded the position of the fiducials and HPI, using the following lines related to maxfilter step in config.py file:

find_flat_channels_meg = True
find_noisy_channels_meg = True
use_maxwell_filter = True

I get the following error message

preprocessing/_01_data_quality sub-02 run-01 A critical error occurred. The error message was: No digitization points found for dig_kinds=[4 (FIFFV_POINT_EXTRA), 3 (FIFFV_POINT_EEG)]

Aborting pipeline run. The traceback is:

  File "/opt/anaconda3/envs/mne/lib/python3.11/site-packages/mne_bids_pipeline/_run.py", line 55, in __mne_bids_pipeline_failsafe_wrapper__
    out = memory.cache(func)(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/mne/lib/python3.11/site-packages/mne_bids_pipeline/_run.py", line 268, in wrapper
    out_files = memorized_func(*args, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/mne/lib/python3.11/site-packages/joblib/memory.py", line 655, in __call__
    return self._cached_call(args, kwargs)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/mne/lib/python3.11/site-packages/joblib/memory.py", line 598, in _cached_call
    out, metadata = self.call(*args, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/mne/lib/python3.11/site-packages/joblib/memory.py", line 856, in call
    output = self.func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/mne/lib/python3.11/site-packages/mne_bids_pipeline/steps/preprocessing/_01_data_quality.py", line 89, in assess_data_quality
    auto_scores = _find_bads_maxwell(
                  ^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/mne/lib/python3.11/site-packages/mne_bids_pipeline/steps/preprocessing/_01_data_quality.py", line 194, in _find_bads_maxwell
    ) = mne.preprocessing.find_bad_channels_maxwell(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<decorator-gen-472>", line 12, in find_bad_channels_maxwell
  File "/opt/anaconda3/envs/mne/lib/python3.11/site-packages/mne/preprocessing/maxwell.py", line 2629, in find_bad_channels_maxwell
    params = _prep_maxwell_filter(
             ^^^^^^^^^^^^^^^^^^^^^
  File "<decorator-gen-468>", line 12, in _prep_maxwell_filter
  File "/opt/anaconda3/envs/mne/lib/python3.11/site-packages/mne/preprocessing/maxwell.py", line 522, in _prep_maxwell_filter
    origin = _check_origin(origin, info, coord_frame, disp=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/mne/lib/python3.11/site-packages/mne/bem.py", line 1162, in _check_origin
    R, origin = fit_sphere_to_headshape(
                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "<decorator-gen-75>", line 10, in fit_sphere_to_headshape
  File "/opt/anaconda3/envs/mne/lib/python3.11/site-packages/mne/bem.py", line 998, in fit_sphere_to_headshape
    radius, origin_head, origin_device = _fit_sphere_to_headshape(info, dig_kinds)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<decorator-gen-77>", line 12, in _fit_sphere_to_headshape
  File "/opt/anaconda3/envs/mne/lib/python3.11/site-packages/mne/bem.py", line 1091, in _fit_sphere_to_headshape
    hsp = get_fitting_dig(info, dig_kinds)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<decorator-gen-76>", line 12, in get_fitting_dig
  File "/opt/anaconda3/envs/mne/lib/python3.11/site-packages/mne/bem.py", line 1044, in get_fitting_dig
    return get_fitting_dig(info, ("extra", "eeg"))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<decorator-gen-76>", line 12, in get_fitting_dig
  File "/opt/anaconda3/envs/mne/lib/python3.11/site-packages/mne/bem.py", line 1060, in get_fitting_dig
    raise ValueError(f"No digitization points found for dig_kinds={dig_kinds}")

I don’t get it if I put the following line in the config.py file:

mf_head_origin = [0,0,0]

but then the maxfiltering step seems to fail and the data is extremely noisy.

Thank you in advance for your help.

Fosca

Hi Fosca,

I just ran into the same problem and found the following solution, namely to compute the head sphere manually and supply the origin to maxfilter:

radius, origin_head, origin_device = mne.bem.fit_sphere_to_headshape(raw.info, dig_kinds=('cardinal', 'hpi'))

That said, I think it is better to digitize those extra points to estimate the head origin more accurately.

Sophie

2 Likes

Thanks a lot Sophie for your help !