Skip to content

Accessing data after applying gradient compensation & picking doesn't work #8315

Closed

Description

@hoechenberger

Steps to reproduce

import os.path as op
from mne.io import read_raw_fif

base_dir = op.join('/Users/hoechenberger/Development/mne-python/mne', 'io',
                   'tests', 'data')
raw_ctf_fname = op.join(base_dir, 'test_ctf_raw.fif')

raw = read_raw_fif(raw_ctf_fname, preload=False)
raw.apply_gradient_compensation(3)
raw.copy().pick_types(meg=True).get_data()

Expected results

Opening raw data file /Users/hoechenberger/Development/mne-python/mne/io/tests/data/test_ctf_raw.fif...
    Read 5 compensation matrices
    Range : 24000 ... 31200 =     10.000 ...    13.000 secs
Ready.
Current compensation grade : 0
Reading 0 ... 7200  =      0.000 ...     3.000 secs...
Compensator constructed to change 0 -> 3
Applying compensator to loaded data

Actual results

Opening raw data file /Users/hoechenberger/Development/mne-python/mne/io/tests/data/test_ctf_raw.fif...
    Read 5 compensation matrices
    Range : 24000 ... 31200 =     10.000 ...    13.000 secs
Ready.
Current compensation grade : 0
Compensator constructed to change 0 -> 3
Traceback (most recent call last):
  File "/private/tmp/mwe.py", line 10, in <module>
    raw.copy().pick_types(meg=True).get_data()
  File "<decorator-gen-166>", line 21, in get_data
  File "/Users/hoechenberger/Development/mne-python/mne/io/base.py", line 823, in get_data
    data, times = self[picks, start:stop]
  File "/Users/hoechenberger/Development/mne-python/mne/io/base.py", line 772, in __getitem__
    data = self._read_segment(start=start, stop=stop, sel=sel,
  File "<decorator-gen-163>", line 21, in _read_segment
  File "/Users/hoechenberger/Development/mne-python/mne/io/base.py", line 375, in _read_segment
    mult = self._comp[idx] * cals
ValueError: operands could not be broadcast together with shapes (304,309) (1,304) 

Additional information

If the data is preloaded:

raw = read_raw_fif(raw_ctf_fname, preload=True)

the problem does not occur.

Also if I skip the pick_types() it does work.

NumPy is 1.19.1.

Activity

  1. larsoner commented on Sep 29, 2020

    @larsoner
    Member

    I can look into this in the coming days

  2. added this to the 0.22 milestone on Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions