[Mne_analysis] Difference between mne_make_movie & python apply_inverse?

acgt2 at cam.ac.uk acgt2 at cam.ac.uk
Fri Jan 25 12:01:46 EST 2013
Search archives:

Hi NME-ers

We've found the reason for the difference between my c_mne and python_mne
results. Alex is correct - there is no difference between the two versions
of code - but the flag for '--signed' is 'off' in the C version by default,
and 'on' in the python version by default. As a result, when averaged
between participants, the source time courses end up different.

Best,

Andy

-----Original Message-----
From: Alexandre Gramfort [mailto:gramfort at nmr.mgh.harvard.edu] 
Sent: 25 January 2013 14:00
To: acgt2 at cam.ac.uk
Cc: mne_analysis at nmr.mgh.harvard.edu
Subject: Re: [Mne_analysis] Difference between mne_make_movie & python
apply_inverse?

hi Andy,

there should not be any difference in theory and we have now a big test
suite to check the results of mne-python with the results given by the
current C code.
However we never test a 100% of the cases... could you share a minimal set
of data and scripts to reproduce the difference between
2 estimated stc files (one with python and one with the C)?

Best,
Alex

On Fri, Jan 25, 2013 at 12:35 PM,  <acgt2 at cam.ac.uk> wrote:
> Hi Alex,
>
> Thanks for your reply -
>
> I have re-run the python results, and adding in the baseline doesn't 
> really affect them (I'm doing single trial analysis so this is 
> probably to be expected), so there remains a difference between the 
> outputs of the two sets of code.
>
> Do I understand from your (first) reply that, to the best of your 
> knowledge, the two bits of code I have below should do absolutely 
> identical things (assuming I've added the baseline to the python 
> code)? I'm very pleased with the python results, but a lot of people 
> in my group are using code similar/identical to my original and were 
> under the impression there was no difference between the commandline 
> functions and their 'equivalent' python versions, so I would like to 
> be sure. If the reason the two outputs are different is due to the 
> fact that the underlying python functions are an improvement on the 
> equivalent commandline functions (even in some seemingly trivial way, 
> like using hanning windows instead of rectangular windows or 
> something), then this might explain the difference (and is a good 
> reason for us to move to mne_python!). I should be clear that, if 
> there are differences, I'm not asking for a breakdown of what they 
> are! Just confirmation (or otherwise) that the two pieces of code are not
expected to give out exactly the same results.
>
> You asked about the data: it is EEG+MEG combined.
>
> Thanks for all your help with this, much appreciated.
>
> Andy
>
> -----Original Message-----
> From: Alexandre Gramfort [mailto:gramfort at nmr.mgh.harvard.edu]
> Sent: 24 January 2013 20:57
> To: acgt2 at cam.ac.uk
> Cc: mne_analysis at nmr.mgh.harvard.edu
> Subject: Re: [Mne_analysis] Difference between mne_make_movie & python 
> apply_inverse?
>
> hi Andy,
>
> my bad you're right "baseline=(-0.2, 0)" should do it. If you 
> high-passed the data is very possible that baseline correction is not 
> mandatory, even better without.
>
> Best,
> Alex
>
>> I will try adding in the baseline now and report back - although if 
>> this
> is
>> the difference it would mean that the result is worse when one adds 
>> it in (which is possible, but would be a bit strange).
>>
>> You say I should use 'baseline=(-0.2, None)' to match my make_movie
> command,
>> but I thought that 'baseline=(-0.2, 0)' would be closer,  wouldn't 'None'
> in
>> the second parameter make the baseline from -0.2 to the end of my 
>> evoked file? (the code says 'end of the interval' but I'm not sure 
>> what that
> refers
>> to).
>>
>> Andy
>>
>>
>>
>> -----Original Message-----
>> From: Alexandre Gramfort [mailto:gramfort at nmr.mgh.harvard.edu]
>> Sent: 24 January 2013 12:44
>> To: acgt2 at cam.ac.uk
>> Cc: mne_analysis at nmr.mgh.harvard.edu
>> Subject: Re: [Mne_analysis] Difference between mne_make_movie & 
>> python apply_inverse?
>>
>> hi Andy,
>>
>> the only obvious difference is the bmin/bmax.
>>
>> To match the mne_make_movie code you should do:
>>
>> evoked = Evoked('Participant_1_EvokedAuditory.fif', baseline=(-0.2, 
>> None))
>>
>> do you have MEG only? or EEG + MEG?
>>
>> HTH
>> Alex
>>
>> On Thu, Jan 24, 2013 at 12:34 PM,  <acgt2 at cam.ac.uk> wrote:
>>>
>>>
>>> Hi MNE-ers
>>>
>>>
>>>
>>> I have just switched from using the mne_make_movie command (version
>>> 2.7.3) to compute-the-inverse-solution-and-morph-to-average, to 
>>> using the python 'apply inverse' operator and the
'morph_data_precomputed'
>>> to do the same thing. I am pleased to find that the results are now 
>>> similar (as one would hope), but noticeably better (my experiments 
>>> involve auditory data, and results that were about a centimeter away 
>>> from Heschls Gyrus, had now moved to exactly on top of Heschls Gyrus).
>>> Obviously I'm delighted, but I just wanted to check that the python 
>>> version should be expected to give better results - as I had assumed 
>>> the two results would be the same. Should  they be?
>>>
>>>
>>>
>>> As far as I can work out, both my two pieces of codes applied the 
>>> same parameters. (although smoothing and bmin/max don't make an 
>>> appearance in the python code, the python log says '5 smoothing 
>>> iterations done', so I assume this is the default)
>>>
>>>
>>>
>>> The command line version (split onto several lines for easier reading):
>>>
>>>
>>>
>>> mne_make_movie
>>>
>>> --inv /inverse-operators/3L-loose0.2-nodepth-reg-inv.fif
>>>
>>> --meas Participant_1_EvokedAuditory.fif
>>>
>>> --morph average
>>>
>>> --morphgrade
>>>
>>> --subject Participant_1
>>>
>>> --stc Participant_1_EvokedAuditory.stc
>>>
>>> --smooth 5
>>>
>>> --snr 1
>>>
>>> --bmin -200
>>>
>>> --bmax 0
>>>
>>> --picknormalcomp
>>>
>>>
>>>
>>>
>>>
>>> Python:
>>>
>>>
>>>
>>> snr = 1.0
>>>
>>> lambda2 = 1.0 / snr ** 2
>>>
>>>
>>>
>>> # Make inverse solution
>>>
>>>
>>>
>>> inverse_operator =
>>> read_inverse_operator('/inverse-operators/3L-loose0.2-nodepth-reg-inv.
>>> fif')
>>>
>>> evoked = Evoked('Participant_1_EvokedAuditory.fif')
>>>
>>> stc_from = apply_inverse(evoked, inverse_operator, lambda2, "MNE",
>>> pick_normal=True)
>>>
>>>
>>>
>>> # First compute morph matices for participant
>>>
>>> subject_to = 'average'
>>>
>>> subject_from = 'Participant_1'
>>>
>>> vertices_to = mne.grade_to_vertices(subject_to, grade=4,
>>> subjects_dir=subjects_dir)
>>>
>>> morph_mat = mne.compute_morph_matrix(subject_from, subject_to, 
>>> stc_from.vertno, vertices_to, subjects_dir=subjects_dir)
>>>
>>>
>>>
>>> # Morph to average
>>>
>>> stc_morphed = mne.morph_data_precomputed(subject_from, subject_to, 
>>> stc_from, vertices_to, morph_mat)
>>>
>>> stc_morphed.save('Participant_1_EvokedAuditory.stc')
>>>
>>>
>>>
>>>
>>>
>>> Thanks for any help,
>>>
>>>
>>>
>>> Andy
>>>
>>>
>>> _______________________________________________
>>> Mne_analysis mailing list
>>> Mne_analysis at nmr.mgh.harvard.edu
>>> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>>>
>>>
>>> The information in this e-mail is intended only for the person to 
>>> whom it is addressed. If you believe this e-mail was sent to you in 
>>> error and the e-mail contains patient information, please contact 
>>> the Partners Compliance HelpLine at 
>>> http://www.partners.org/complianceline
>>> . If the e-mail was sent to you in error but does not contain 
>>> patient information, please contact the sender and properly dispose 
>>> of the e-mail.
>>>
>>
>> _______________________________________________
>> Mne_analysis mailing list
>> Mne_analysis at nmr.mgh.harvard.edu
>> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis




More information about the Mne_analysis mailing list