-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Denoising options for preprocessing #2112
Comments
can you hack something with MNE using the python code? just to see how well
it works?
btw Alain de Cheveigné is in Paris so you could see him IRL :)
PS : don't spend one week on it :)
|
I'll follow up on my question regarding denoising external sources here, because it's likely to generate a long discussion perhaps even a PR..
So thanks @teonlamont for the refs and links. I've tried the git package, but without success: neither for raw nor epoched data. The code is pretty messy, and I keep encountering data shape issues (see my gist here). @teonlamont have you successfully preprocess your data with these scripts? Before re-coding the entire script, I thought of checking up how the TSPCA actually cleans my data, using some in-lab wrapper ( The benefit of this procedure is far from being obvious to me. The evoked responses (high versus low tones) are basically the same, the decoding performance is nearly identical (but it's multivariate, so it could makes sense...). Similar results were obtained when the components were not fitted with an empty room but with the subjects data.
I've tried to use the SSS implementation of mne-python but got stuck pretty quickly. I am using a KIT, which is composed of i) axial gradiometers, that are actually considered as magnetometers by mne-python (which makes sense) ii) and 3 magnetometers (x,y,z) further away from the head to be used as a reference). However, the
=> picking error I'd be happy to share empty room, single tone and dual tone data from a KIT if that helps. |
the repo https://github.com/pealco/python-meg-denoise does not contain data
that can be used for testing easily. Maybe CTF spm data can used as it has
ref_meg channels.
I had not realized that dss required a ref channel...
regarding SSS, it has not been tested on non neuromag systems and so far it
is not clear how to handle reference channels.
|
I meant disregarding the ref and trying to apply the sss on the axial gradiometers. Would this make sense ? |
maybe @staulu can comment |
It makes sense to apply SSS on the axial gradiometers after leaving out the reference sensors. However, if the reference sensor signals are available in the data without the coupling to the axial gradiometers, it would be even better to use all channels in SSS (axial gradiometers + refs). By coupling I mean extrapolation and subtraction of the reference-based interference, which is the way the reference channels are traditionally used. Just to double check: How many axial gradiometers are there in the KIT system? |
Thanks. In our KIT, there are 157 whole-head axial gradiometers and 3 (xyz) On 29 November 2015 at 00:23, Samu Taulu [email protected] wrote:
|
Thanks for the info. Since I am not sure how accurately the KIT sensors are calibrated and given the relatively small number of sensors (<200), I would use tSSS, which is less sensitive to calibration errors than the plain SSS, and I would also test the performance with internal expansion order (L_in) values of 6, 7, and 8. Do we know if the raw signals are already compensated for based on the 3 reference magnetometers? |
My understanding is that no, the raw data is not compensated based on @Eric89GXL is there a tSSS implemented in MNE ? On Tuesday, 1 December 2015, Samu Taulu [email protected] wrote:
|
@kingjr yes, tSSS is now implemented in mne-python. @staulu I don't know much about these systems, but I do know that the FIF file contains information about different forms of compensation matrices that can be applied to the data. So I suspect we can detect whether or not compensation has been done. But it would be good to get input from people who really know (@kingjr if you are one of those people or can ping someone who is it would be very helpful here!). |
Thanks to our meg engineer Jeffrey Walker, here are some clarifications from the KIT team.
Hi Jeff, Actually, there is a way for the online compensation using the signals It is possible to implement DOLPHIN to MEG systems but the electronics must The SQUID electronics of the MEG system in Abu Dhabi is relatively new |
cute acronym, they are really trying to keep up the ocean metaphors ;) so from my reading, and from my experience, there is currently no online compensation done to the MEG data in New York. @kingjr, I wasn't able to get it to work (but I also didn't invest too much time in it). i wonder if it would be easier to go from the MATLAB code to a Python implementation than the currently defunct meg-denoise repo. The nice thing about about tsPCA is that when it's reduced down to no shifts, it is equivalent to the CALM procedure, so it encompasses multiple denoising techniques. unfortunately, I can only be a cheerleader on this issue 🤘👏 |
@kingjr is there a way to tell if DOLPHIN has been performed on the data
during acquisition? If it hasn't been, is it then safe to assume data has
not been compensated? Thanks for looking into this stuff.
|
Perhaps, but from what I've seen, the python repo is pretty much a direct translation of chevigne's toolbox. The main issue with the latter is that there are a lot of peripheral functions to normalize columns, demean etc, that are not systematic (these functions typically check the input size and apply a different function accordingly). So I think the best is probably to start from the equations directly. From my end, I would first need to know whether there's an actual benefit in applying these denoising techniques, as compared to the tSSS. If there is, I'll implement it.
You mean, in the header? I haven't any DOLPHIN data, so it's hard to check but I'll ask. In my specific case, I know our squids are not compatible with this online denoising procedure. |
It would be great if we could get SSS (and trivially thereafter tSSS) working. We want to release
Yeah, it would be best if we could tell from the header information that some form of online compensation has been applied. That way we know whether or not we can use SSS. It sounds like only one site is using it currently so it might not be a big deal currently, but it would be good to get support for it as early as possible. |
Nothing in the headers apparently. Here are their reply:
I'm stuck at the SSS transform, the data format is not easily compatible with the current script. I'll try to hack it this weekend, and ll report you what I get. Here |
Can you reproduce with any of the files in the |
That's what we'll probably want to use to make tests eventually. It is hopefully something minor with the picking functions. |
@kingjr any way you could have a look by Monday or Tuesday and hopefully reproduce with test data, or otherwise share a failing file? That way I can have a look. It would be nice to work out whatever bug before releasing 0.11, which we hope to do at the end of next week. |
OK today will be a bit difficult for me but I'll try to give it a try On Saturday, 12 December 2015, Eric Larson [email protected] wrote:
|
@Eric89GXL I had to make several changes to prevent
minor: I think the
I'm not entirely sure whether i) my parameters are set in the optimal place and ii) whether they actually are valid.
However, here is what we obtain after SSS: It looks a bit crazy to me. no?
|
Things are never easy, are they? :) I agree those dipolar patterns are not so good in the Maxwell filtering case. @staulu you were thinking we should include reference sensors in SSS decomposition, right? You shouldn't need to pass the acquisition system -- we can improve the SSS code to try using Elekta defs, and fall back to mne defs if they're not available. That should be easy enough to implement. I can give it a shot. I'll make some some basic test from these files: https://github.com/mne-tools/mne-python/tree/master/mne/io/kit/tests/data We can't really validate the quality of the output using those files, but we can at least make some tests that ensure the algorithm runs on those data. I think we'll need to get your dataset working better to start validating the algorithm. Have you tried tSSS at all? |
Also, how many components were kept due to regularization (you can see it with |
@kingjr the |
@kingjr looks like when I run the test file I get only 30 components kept due to regularization (!). Try using |
No, but I have only one run in this case, so I guess it won't change much, or will it? Can you point me the script that runs tSSS?
Ah ok. Well, that changes everything, except that it's still crappy :)
This is what I get with no regularization with the correct hsp and elp files. Still doesn't look correct Not sure what to do from here, but thanks a lot for your help. |
Hmm... I wonder if there is still some problem with the transforms. Have you successfully computed a forward/inverse for this dataset? The forward code and Maxwell filtering code use the same set of transforms, so if the forward works, it suggests the transforms are not the problem. |
No I only have a pilot data for now. I have an old MRI of myself, so I could try segment it and all, but this will take a while. Is there a quicker way of checking this up? |
Not that I can think of offhand :( I am about to open a PR that contains some minor fixes that might make it work better for you, though. |
Just a couple of thoughts: 1) Would it be possible to check the condition number of the normalized SSS basis before transforming the data from sensors to multipole moments? Also, 2) it just occurred to me that since this system only has gradiometers (when references are omitted), the first three external basis vectors will be zero, or some random vectors due to numerical inaccuracies. This is because those vectors correspond to homogeneous fields, which ideal gradiometers are insensitive to. So, the three homogeneous vectors should be excluded from the model, otherwise the SSS matrix may be quite ill-conditioned. It would be beneficial to include the reference sensors in the SSS model, but I don't think it would fix the reported problem. Maybe the above points help us find the cause of the problem. |
It would be straightforward to add this. Are you thinking we should throw a warning if it's too large (e.g., > 1000)? We could also throw an error I suppose, to be really safe. Actually
Do you think the safest approach is to numerically check for zero-ness (e.g., check if norm is greater than some reasonable default), or to infer it based on a |
Any chance one of you could guide me in the maxwell_filter script to test @EricGXL89 your PR works fine with my kit data (ie it doesn't crash but On Tuesday, 15 December 2015, Samu Taulu [email protected] wrote:
|
Rats.
I'll do better and just implement the changes. Give me a few minutes (hope I can get to it). |
@staulu added a check (let me know if 1000. is a reasonable value or if something else would be better):
So yes, it looks like the condition is bad. Now to fix it as recommended... |
Yes, I think 1000 is a reasonable limit in case it's based on the basis after dropping of the poorly detectable columns. As for the zero vectors, it's best to check if the system consists of ideal gradiometers only. Note that if we have information about gradiometer imbalance, modeled as point-like magnetometer contribution, then the homogeneous components should be included even for a system with gradiometers only. |
@staulu okay, I'll go ahead and implement it that way. I implemented it the norm-comparison way first because it was simpler code-wise, and tests work for it. Swapping in and checking the grad-check version should be doable given the tests that exist now. BTW, the condition is often more than 1000 if no regularization is performed. |
Using the coil type worked for BTi and CTF, but not KIT, but I think it's a bug in our channel picking functions. |
Ah no, it just with the regularization that is does this. Else, it's like before. |
I have compared several denoising options
All subjects performed a passive two-tones protocol: ~ 3 minutes of pitch presentation, no task. We expect two lateral dipoles generated from the auditory cortices. The full report is here: https://www.dropbox.com/s/2z2i6emtbb25htb/report.html?dl=0 [EDIT: wrong link].
In brief,
Consequently, I am wondering whether we could have a regularlized version to automatically discard bad chans? But this may breaks the linearity right?
I'm now onto checking the fwd and inv models to see whether we get what we expect; that would provides an additional check that the maxwell_filter correct. |
sorry to go off on a tangent, but I like that code snippet thing in mne-report. Any chance you could share that code? |
@jasmainak You'll find it very hackish, I made a class to simplify the MNE-report which detects whether you're running the caller is ipython or an actual script and extract its code. The class is also used to not initialize the save dir, and allows updating to dropbox; feel free to incorporate some of the concepts to mne reports. |
Off-topic: looks like there are some potentially interesting pieces for On Thu, Jan 21, 2016 at 6:26 PM, Jean-Rémi KING [email protected]
|
@kingjr am I missing something or are you only showing SSP vs LS? |
|
@dengemann > Sorry, I had updated the wrong report; see https://www.dropbox.com/s/2z2i6emtbb25htb/report.html?dl=0. SSS didn't change anything, but perhaps I should tweak some params? I'm happy to put the data online.
Feel free to copy, but I think you'll find too hackish. @jona-sassenhagen yep, and it actually helps a lot :] |
This is surprising to me. By eye it looks like SSS did nothing to the data. Is it easy to compute and report what Have you tried tSSS (e.g., st_duration=10. or st_duration=60.)? |
@teonlamont I'm going to move this to mne-sandbox |
It would be nice if we had some denoising options available for preprocessing data. A few options that I was thinking of tsPCA (Cheveigné, 2007), and CALM (Adachi, 2001), which can be a special case of tsPCA.
there's a package on git (https://github.com/pealco/python-meg-denoise) that contains an implementation, as well as source code (http://www.isr.umd.edu/Labs/CSSL/simonlab/Denoising.html).
use case for those whose lab implement these tools in Matlab, or private software, those don't have license for maxfilter but would like cleaner data.
The text was updated successfully, but these errors were encountered: