[Mne_analysis] Maxwell Filter and Projections

Sam Zorowitz szorowi1 at gmail.com
Fri Mar 25 15:39:59 EDT 2016
Search archives:

This was all very helpful. Thank you all for your responses.

On Fri, Mar 25, 2016 at 3:13 PM, Ghuman, Avniel <ghumana at upmc.edu> wrote:

> And this is why it is pragmatically easier to do it the other way around
> (SSP after SSS). Even though the rank of the data is not full after SSS,
> SSP does a PCA/SVD so there will be a bunch of eigenvectors with near 0
> eigenvalues, which does not cause problems.
>
> In fact, you can use the SVD to estimate the true rank of your data after
> SSS, which can be helpful. For example if you want to do multivariate
> classification of the MEG data in sensor space, you might be better off
> doing it in the eigenspace on only the eigenvectors that do not have near
> 0 eigenvalues associated with them rather than the full sensor matrix and
> the eigenvectors will be orthogonal, so you can use a relatively simpler
> classifier that assumes independence, like a Naïve Bayes classifier.
>
> On 3/25/16 3:05 PM, "Matti Hamalainen" <msh at nmr.mgh.harvard.edu> wrote:
>
> >
> >In other words, in order for the SSS to work if SSP has been already
> >applied, the same SSP projector should be applied to the SSS multipolar
> >basis vectors as well.
> >
> >- Matti
> >
> >> On Mar 25, 2016, at 3:02 PM, sheraz at nmr.mgh.harvard.edu wrote:
> >>
> >> My couple of cents
> >>
> >> SSP and SSS (maxfilter) are both spatial filter.
> >>
> >> SSS is a single point multipolar expansion using spherical harmonics
> >>basis
> >> functions,  assumes data to be represented in a particular spatial
> >> orientation.
> >>
> >> SSP rotates the spatial orientation hence basic assumption of the SSS
> >> basis function no longer remain valid.
> >>
> >> You can always do SSP after SSS
> >>
> >> Sheraz
> >>
> >>
> >>> Note, I am not a physicist, but I think this is roughly helpful:
> >>> (if a real physicist reads this, please correct me)
> >>>
> >>> short version it doesn't make sense, both ssp and sss use the signal
> >>> space to remove artifacts
> >>> but sss pushes converts the data into spherical harmonics to do this,
> >>> but if you reduce the rank
> >>> with an ssp vector i don't think going into spherical harmonics would
> >>> work.
> >>> I think this is also why you have to have a whole head type system to
> >>> work in maxfilter in general.
> >>>
> >>> hth
> >>> d
> >>>
> >>> On Fri, Mar 25, 2016 at 2:28 PM, Sam Zorowitz <szorowi1 at gmail.com>
> >>>wrote:
> >>>> @ Dan: Ahh, we were wondering how the -skip function worked. (We
> >>>>looked
> >>>> through the manual but did not specify.)
> >>>>
> >>>> @ Eric: Absolutely will do.
> >>>>
> >>>> All of which brings me back to the original question: Does anyone
> >>>>know a
> >>>> reason why one shouldn't apply projections before Maxwell filtering?
> >>>>
> >>>> On Fri, Mar 25, 2016 at 2:22 PM, Eric Larson <larson.eric.d at gmail.com
> >
> >>>> wrote:
> >>>>>
> >>>>> That error is different from the SVD one, but I suspect it has the
> >>>>>same
> >>>>> underlying cause (Anaconda using outdated build tools). To avoid
> >>>>> derailing
> >>>>> the original topic too much, can you open an mne-python issue for
> >>>>>this
> >>>>> specific error scipy.linalg error? We can tackle debugging steps
> >>>>>there.
> >>>>> If
> >>>>> you can anonymize the file, upload it somewhere, give the minimal
> >>>>>steps
> >>>>> to
> >>>>> reproduce it, and paste the output of `mne.sys_info()` (assuming
> >>>>>you're
> >>>>> on
> >>>>> `master`) that would help.
> >>>>>
> >>>>> Eric
> >>>>>
> >>>>>
> >>>>> On Fri, Mar 25, 2016 at 2:18 PM, Sam Zorowitz <szorowi1 at gmail.com>
> >>>>> wrote:
> >>>>>>
> >>>>>> @ Dan: We were trying to move away from the command line version
> >>>>>>for a
> >>>>>> number of reasons. As far as I know, there is no -skip option in the
> >>>>>> python
> >>>>>> implementation.
> >>>>>>
> >>>>>> @ Eric: We are using the Anaconda distribution, and I was not able
> >>>>>>to
> >>>>>> reproduce the error from the thread you linked. When we are getting
> >>>>>>an
> >>>>>> error, it looks like this:
> >>>>>>
> >>>>>>> RuntimeWarning: invalid value encountered in greater
> >>>>>>>  num = np.sum(s > tol, dtype=int)
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> Traceback (most recent call last):
> >>>>>>>  File "motion_correction.py", line 32, in <module>
> >>>>>>>    raw = maxwell_filter(raw, st_duration=st_duration,
> >>>>>>> destination=trans.mean(axis=0), bad_condition='warning')
> >>>>>>>
> >>>>>>> File "<string>", line 2, in maxwell_filter
> >>>>>>>
> >>>>>>> File
> >>>>>>> "/homes/5/szoro/.local/lib/python2.7/site-packages/mne/utils.py",
> >>>>>>> line 551, in verbose
> >>>>>>>    return function(*args, **kwargs)
> >>>>>>>
> >>>>>>> File
> >>>>>>>
> >>>>>>>"/homes/5/szoro/.local/lib/python2.7/site-packages/mne/preprocessing
> >>>>>>>/maxwell.py",
> >>>>>>> line 404, in maxwell_filter
> >>>>>>>    t_proj = _overlap_projector(orig_in_data, resid, st_correlation)
> >>>>>>>
> >>>>>>> File
> >>>>>>>
> >>>>>>>"/homes/5/szoro/.local/lib/python2.7/site-packages/mne/preprocessing
> >>>>>>>/maxwell.py",
> >>>>>>> line 1237, in _overlap_projector
> >>>>>>>    overwrite_a=True, mode='economic', **check_disable)[0].T
> >>>>>>>
> >>>>>>> File
> >>>>>>>
> >>>>>>>"/homes/5/szoro/.local/lib/python2.7/site-packages/scipy/linalg/deco
> >>>>>>>mp_qr.py",
> >>>>>>> line 142, in qr
> >>>>>>>    overwrite_a=overwrite_a)
> >>>>>>>
> >>>>>>> File
> >>>>>>>
> >>>>>>>"/homes/5/szoro/.local/lib/python2.7/site-packages/scipy/linalg/deco
> >>>>>>>mp_qr.py",
> >>>>>>> line 20, in safecall
> >>>>>>>    ret = f(*args, **kwargs)
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> ValueError: failed to create intent(cache|hide)|optional array--
> >>>>>>>must
> >>>>>>> have defined dimensions but got (0,)
> >>>>>>
> >>>>>>
> >>>>>> Unfortunately I can't quite parse what's going on here in the error
> >>>>>> message.
> >>>>>>
> >>>>>> On Fri, Mar 25, 2016 at 1:47 PM, Eric Larson
> >>>>>><larson.eric.d at gmail.com>
> >>>>>> wrote:
> >>>>>>>>
> >>>>>>>> The short of it is that we were running into some issues with the
> >>>>>>>> Maxwell filter function, such that the SVD will not converge for
> >>>>>>>> certain
> >>>>>>>> buffers if there is an abundance of noise.
> >>>>>>>
> >>>>>>>
> >>>>>>> I have observed seen this "failure to converge" problem with SVD
> >>>>>>> before.
> >>>>>>> Are you running Anaconda? If so, could you look here, see if you
> >>>>>>>can
> >>>>>>> reproduce the error with the .npy file from the post, and also do
> >>>>>>>the
> >>>>>>> `cat
> >>>>>>> /proc/cpuinfo` step? It will help isolate the problem, and keep
> >>>>>>> attention on
> >>>>>>> it:
> >>>>>>>
> >>>>>>> https://github.com/ContinuumIO/anaconda-issues/issues/695
> >>>>>>>
> >>>>>>> If you're not on Anaconda, I'm curious what Python setup you're
> >>>>>>> using.
> >>>>>>>
> >>>>>>> Such "high noise" segments really shouldn't be a problem for SVD.
> >>>>>>>If
> >>>>>>> the
> >>>>>>> Anaconda folks don't fix the issue, we're going to try to put a
> >>>>>>> workaround
> >>>>>>> solution in upstream scipy:
> >>>>>>>
> >>>>>>> https://github.com/scipy/scipy/pull/5994#issuecomment-200341678
> >>>>>>>
> >>>>>>> Eric
> >>>>>>>
> >>>>>>>
> >>>>>>> _______________________________________________
> >>>>>>> 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
> >>>>>>
> >>>>>>
> >>>>>> 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
> >>>>>
> >>>>>
> >>>>> 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
> >>>>
> >>>>
> >>>> 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
> >>
> >>
> >
> >
> >_______________________________________________
> >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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20160325/4d115c03/attachment-0001.html 


More information about the Mne_analysis mailing list