You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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.
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.
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.
@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.
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.
..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?
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.
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.
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.
Activity
dengemann commentedon Jan 17, 2013
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.
mluessi commentedon Jan 17, 2013
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.
larsoner commentedon Jan 17, 2013
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.
mluessi commentedon Jan 17, 2013
@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.
agramfort commentedon Jan 17, 2013
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.
mluessi commentedon Jan 17, 2013
..but the function
mne.fiff.raw.make_compensatordoes not exist and the code is fundamentally broken. Also, to repeat myself, why would this be a part of Epochs and not Raw?agramfort commentedon Jan 18, 2013
Because I never worked with CTF with mne ;) do not hesitate to fix...
mluessi commentedon Jan 18, 2013
If I can find out what
mne.fiff.raw.make_compensatoris supposed to do I can try.. any objections if these parameters are moved to Raw (API change)?agramfort commentedon Jan 18, 2013
fine with me.
dengemann commentedon Jan 18, 2013
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:
mluessi commentedon Jan 18, 2013
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=Falseand adest_compvalue 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 functionmne.fiff.raw.make_compensatordoes 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.dengemann commentedon Jan 18, 2013
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]:
agramfort commentedon Mar 7, 2013
@mluessi are we good here?
larsoner commentedon Jun 6, 2013
This has been addressed by @agramfort's recent PR, closing.