Skip to content

Reading CTF Evokeds fails: missing compensation channel(s) #4241

Closed

Description

@jona-sassenhagen

On master, the attached file was created with evoked.save(fname), but can't be read with mne.read_evokeds(fname):

/Users/jona/tools/mne-python/mne/io/meas_info.py in read_meas_info(fid, tree, clean_bads, verbose)
    775
    776     #   Load the CTF compensation data
--> 777     comps = read_ctf_comp(fid, meas_info, chs)
    778
    779     #   Load the bad channel list

/Users/jona/tools/mne-python/mne/io/ctf_comp.py in read_ctf_comp(fid, node, chs, verbose)

/Users/jona/tools/mne-python/mne/utils.py in verbose(function, *args, **kwargs)
    705         with use_log_level(verbose_level):
    706             return function(*args, **kwargs)
--> 707     return function(*args, **kwargs)
    708
    709

/Users/jona/tools/mne-python/mne/io/ctf_comp.py in read_ctf_comp(fid, node, chs, verbose)
    109         if not calibrated:
    110             #   Calibrate...
--> 111             _calibrate_comp(one, chs, mat['row_names'], mat['col_names'])
    112         else:
    113             one['rowcals'] = np.ones(mat['data'].shape[0], dtype=np.float)

/Users/jona/tools/mne-python/mne/io/ctf_comp.py in _calibrate_comp(comp, chs, row_names, col_names, mult_keys, flip)
     42             if p != 1:
     43                 raise RuntimeError('Channel %s does not appear exactly once '
---> 44                                    'in data' % names[ii])
     45             idx = ch_names.index(names[ii])
     46             val = chs[idx][mult_keys[0]] * chs[idx][mult_keys[1]]

RuntimeError: Channel BG1-3609 does not appear exactly once in data

The instance was created by linear_regression_raw out of a Raw instance.

HA0710_demo-ave.fif.zip

@jaeilepp ..?

Edit: the problem stems from picking the channels and removing the ref_meg.

It also makes mne.make_forward_solution fail with a similar error.

Activity

  1. larsoner commented on May 4, 2017

    @larsoner
    Member

    Can you see if you can reproduce using one of the CTF datasets in testing?

    If not, can you at least see if this happens without using linear_regression_raw (i.e., using plain Epochs and epochs.average()? My guess is that there is some interaction with picks where linear_regression_raw chooses non-reference channels, and the resulting Evoked instance doesn't have the channels necessary for comps, and this is only noticed on read.

  2. jona-sassenhagen commented on May 4, 2017

    @jona-sassenhagen
    ContributorAuthor

    It only depends on picking ref_meg = False. E.g., if I write the raw file's info to the disk after picking, I can't read it due to this error. If I don't pick, it works.

  3. jaeilepp commented on May 4, 2017

    @jaeilepp
    Contributor

    I'm not sure what's the right fix for this. I see 3 options:

    1. Don't save the comps info from dropped channels.
    2. Save the comps info, but ignore them while reading, throwing a warning.
    3. Not allow saving when required channels are missing.
  4. jaeilepp commented on May 4, 2017

    @jaeilepp
    Contributor

    And BTW the issue heading is incorrect. The problem is that the compensation channel is not there.

  5. changed the title [-]Reading CTF Evokeds fails: duplicate compensation channel[/-] [+]Reading CTF Evokeds fails: missing compensation channel(s)[/+] on May 4, 2017
  6. jona-sassenhagen commented on May 4, 2017

    @jona-sassenhagen
    ContributorAuthor
  7. larsoner commented on May 4, 2017

    @larsoner
    Member

    Comps are also necessary for fwd/inv.

    My proposed fix is that when picking is done (e.g., in raw.pick_types, or in linear_regresison_raw, etc.):

    1. If compensation has been applied but not all used comp channels are picked, raise an error.

    2. If no compensation has been applied, discard the projectors (alongside a logger.info that this is being done).

  8. jona-sassenhagen commented on May 4, 2017

    @jona-sassenhagen
    ContributorAuthor
  9. dokato commented on Dec 13, 2017

    @dokato
    Contributor

    Hi, is there a quick workaround before it gets fixed? I got the same error when I try to read my epoched data, so I assume it's related.

  10. jona-sassenhagen commented on Dec 13, 2017

    @jona-sassenhagen
    ContributorAuthor

    If you can, it would probably be easiest to recreate the epochs in a what that can be read.

  11. dokato commented on Dec 13, 2017

    @dokato
    Contributor

    Yes, you're right. Thanks.

    So in my case skipping picks=picks_meg argument, while creating epochs, helped.

  12. agramfort commented on Dec 13, 2017

    @agramfort
    SponsorMember
  13. added this to the 0.16 milestone on Feb 21, 2018
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