Skip to content

keep_comp and dest_comp parameters of Epochs #395

Closed

Description

@mluessi

While working on #382 I came across the keep_comp and dest_comp parameters of Epochs. It is not really clear to me what this is good for and it is broken and ugly:

  • When keep_comp is False, the current_comp != dest_comp, the non-existing function fiff.raw.make_compensator is called (obviously not covered by a test).
  • The Raw instance is potentially modified in the Epochs constructor (setting the comp), which very ugly.
  • The dest_comp parameter of Epochs doesn't have a docstring, so it is not clear to me what it does.

@agramfort you seem to have implemented this, can you explain why it is there? Also, if this is needed (probably not, as no one seems to be using it), wouldn't the right place for it be Raw, not Epochs?

Activity

  1. dengemann commented on Jan 17, 2013

    @dengemann
    Member

    Wait, this might become a hot feature. If I'm not mistaken this is about the ctf (and bti) software gradient compensation matrixes included in some fiff files from ctf and bti. We might want to refactor it at some point. Actually I might want to use it in the future. But let @agramfort tell us more.

  2. mluessi commented on Jan 17, 2013

    @mluessi
    ContributorAuthor

    I agree that it may be important, and the gradient compensation is currently applied when the data is read in Raw. The problem is that Epochs is currently broken and it is not clear to me why those parameters are passed to Epochs and not Raw.

  3. larsoner commented on Jan 17, 2013

    @larsoner
    Member

    IIRC, the calibration application / de-application caused a problem with read/write epochs not giving back the exact same values, too. +1 on removing it if possible. However, it looks like the Evoked datasets have calibration applied -- presumably whatever is done in Evoked is also meant to be done in Epochs, so I'm not terribly optimistic about our ability to remove the calibration. Or, we can just have the calibrations applied / unapplied on read / write for Evoked for historical reasons, but don't apply / unapply them for Epochs because we don't need to.

  4. mluessi commented on Jan 17, 2013

    @mluessi
    ContributorAuthor

    @Eric89GXL I'm not talking about the calibration but the CTF gradient compensation. It makes sense that the data is decalibrated before saving, otherwise you would lose precision when storing the data as float32.

  5. agramfort commented on Jan 17, 2013

    @agramfort
    SponsorMember

    my code on CTF calibration is copied from the mne-matlab code. Ideally we
    should decalibrate anytime we save on disk (raw, epochs, evoked) so it's
    like something is broken... Maybe the tiny CTF fif file in the
    fiff/tests/data can already be used to check / test all this.

  6. mluessi commented on Jan 17, 2013

    @mluessi
    ContributorAuthor

    ..but the function mne.fiff.raw.make_compensator does not exist and the code is fundamentally broken. Also, to repeat myself, why would this be a part of Epochs and not Raw?

  7. agramfort commented on Jan 18, 2013

    @agramfort
    SponsorMember

    Because I never worked with CTF with mne ;) do not hesitate to fix...

  8. mluessi commented on Jan 18, 2013

    @mluessi
    ContributorAuthor

    If I can find out what mne.fiff.raw.make_compensator is supposed to do I can try.. any objections if these parameters are moved to Raw (API change)?

  9. agramfort commented on Jan 18, 2013

    @agramfort
    SponsorMember

    fine with me.

  10. dengemann commented on Jan 18, 2013

    @dengemann
    Member

    I think the reason for this being part of Epochs might be that the mne c
    code allows for both, compensating raw and evoked data. the compensation is
    then applied on computing averages. If we want it at some point, we can
    re-introduce it properly with valid function calls...

    On Fri, Jan 18, 2013 at 2:34 PM, Alexandre Gramfort <
    [email protected]> wrote:

    fine with me.

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/395#issuecomment-12421826.

  11. mluessi commented on Jan 18, 2013

    @mluessi
    ContributorAuthor

    As it is right now in mne-python, the compensation is applied by Raw when the data is read. When Epochs is created with keep_comp=False and a dest_comp value that is different than what is already in the Raw instance, the Raw instance is modified (supposedly, right now it will just fail as the function mne.fiff.raw.make_compensator does not exist) by Epochs.init, which is a bad design (a function/method should never just change an object that is supplied as a parameter, unless it is clearly documented in the docstring). This is why those parameters should be a part of Raw. The compensation will still be applied the way it is now, with the added benefit that it is possible to change the compensation when Raw is used without Epochs.

  12. dengemann commented on Jan 18, 2013

    @dengemann
    Member

    sounds good to me, thanks for elaborating! I agree with what you propose.

    On Fri, Jan 18, 2013 at 3:40 PM, Martin Luessi [email protected]:

    As it is right now in mne-python, the compensation is applied by Raw when
    the data is read. When Epochs is created with keep_comp=False and a
    dest_comp value that is different than what is already in the Raw
    instance, the Raw instance is modified (supposedly, right now it will just
    fail as the function mne.fiff.raw.make_compensator does not exist) by
    Epochs.init, which is a bad design (a function/method should never just
    change an object that is supplied as a parameter, unless it is clearly
    documented in the docstring). This is why those parameters should be a part
    of Raw. The compensation will still be applied the way it is now, with the
    added benefit that it is possible to change the compensation when Raw is
    used without Epochs.

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/395#issuecomment-12424371.

  13. agramfort commented on Mar 7, 2013

    @agramfort
    SponsorMember

    @mluessi are we good here?

  14. larsoner commented on Jun 6, 2013

    @larsoner
    Member

    This has been addressed by @agramfort's recent PR, closing.

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions