Repository navigation
[ENH] Add support for importing UCL/FIL OPM data - #11366
Conversation
|
Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴🏽♂️ |
I'm not too worried about FIL vs FIF in terms of confusion or completion. If FIL is a better name in principle then let's use it |
|
Thanks, will change to FIL. |
|
Pushed a tiny commit to fix a doc issue, and since I have write access to the repo we'll no longer need to approve CI workflow runs (first-time committers need CI approvals as a GH security measure) |
|
Argh, GH is degraded at the moment:
We'll have to wait maybe until tomorrow to see if there are legitimate failures. |
|
Sorry, the class is RawFIL, not RawUCL! I'll make the changes in the documentation. |
|
I wouldn't worry about If you really want to fix it now, another option is to not |
|
I hadn't come across pymatreader before. It looks like it is a simple drop-in. |
|
Apologies for the chaos. This is my first time using a CI'd repo, but It finally works. It appears to pass all checks on my local fork now. Unsure why the default test on here is failing. |
Awesome! No need to apologize, CIs are almost always red for a while, even for experienced contributors.
That's CircleCI -- as a security measure they won't run your commit because you've never committed to MNE-Python before. I just pushed an empty commit that should get all CIs running |
|
@georgeoneill okay if I push a commit to add a dataset downloader for #11257 (comment) in this PR? Then you can add a hopefully short tutorial/example that shows how to get some auditory responses using your reader? I think it's the last major thing we'd want to add to this PR. |
|
Of course! |
|
Okay I:
With this I think we are very close to being able to merge! What's left:
FYI we are releasing 1.3 this Friday, so we should hold off on merging this (and adding a |
|
FYI if you click the "Check the rendered docs here!" you can see: and other stuff like the rendered API pages. |
|
Hi @larsoner, that quite a lot of infrastructure you've put in. Thanks! @neurofractal and I should be able to put something together for a basic, non-HFC, documentation until such a time that its been inplimented. Filters can do the heavy lifting for the time being. thumb's up emoji. Also happy to wait for to merge after 1.3 release. Unless we get a tutorial together before then, of course. |
|
Lovely - happy to help write the tutorial and have a play around with the new code! |
* upstream/main: [ENH, MRG] Add info save method (#11401) MAINT: Sanitize name lists (#11399) [ENH] Read annotation duration from SNIRF files. (#11397) 1.4dev0 deprecations and TODOs (#11391) MRG: Use MNE-misc-data dataset version 0.24 (#11389) update installer links (#11387) bump version to dev release 1.3 (#11384) [BUG][MRG] Fix surface finding for mne.viz.Brain (#11361) [circle deploy] Replaced package mention ESINet by invertmeeg (#11381) Handle None-type for 'sex' in raw subject info before writing EDF (#11375) FIX: Safer numba import (#11377) [DRAFT][DOC] Adapt LCMV tutorial (#11378) [DOC] Adding make clean to contributing guide (#11379) Fix lingering topomap api (#11371) MAINT: Bump to 20.04 (#11374) Improve ICA component selection with the argument picks (#11369) [MRG] Fix missing PR number in changelog (#11365)
|
I've just updated the tutorial to do some synthetic gradiometry. It appears to work. Feel free to edit how the data is visualised as I suspect my plotting method isn't very memory efficient? One thing which concerns me is when checking the shielding factor (measured as |
|
I'll take a look and push a commit with a few plotting tweaks |
There was a problem hiding this comment.
FYI the > 5 Hz PSD stuff seemed to mostly have to do with the IIR .filter -- the roll-off of the default IIR filter isn't super sharp so there was enough content there for the regression to capture it. Switching to our default FIR implementation seems to help.
I also .crop the data now to ~2 minutes. We need to keep examples < 1.5 GB of data usage to keep CircleCI happy building the docs -- and also it's not a bad idea from an example/tutorial efficiency standpoint. Hopefully this will still allow some ERFs to be obtained eventually. If this is too difficult for you to work with, feel free to revert the .crop for now and I can figure out how to save memory once everything works fully
| picks = pick_types(raw.info, eeg=True) | ||
| assert_array_equal(picks, np.arange(4, 12)) | ||
| norms = np.linalg.norm(raw.get_data(picks), axis=1) | ||
| raw_reg, _ = regress_artifact(raw, picks=picks, picks_artifact='eog') |
There was a problem hiding this comment.
@wmvanvliet this is where in the OPM example it used to fail during the .apply stage, saying some of the picks (e.g., 94) were too large for info, which only contained 86 channels following the pick_info call
| all_picks = np.unique(np.hstack((picks, picks_artifact))) | ||
| self.info_ = pick_info(inst.info, all_picks) | ||
| self.info_ = inst.info.copy() |
There was a problem hiding this comment.
@wmvanvliet this was buggy -- if picks and/or picks_regression were numerical and did not begin at 0 and stay contiguous, this could lead to incorrect channels being picked at the apply stage. Imagine you had 5 MEG channels, then 4 EEG, then 1 EOG, and your picks are np.arange(5, 9) (i.e., EEG but numerical), the pick_info of the picks+picks_artifact would reduce info_ to only have 5 channels, but the numerical .picks attribute would be np.arange(5, 9), which is clearly out of range.
We could probably get away with some searchsorted stuff, but it would be a bit complex and annoying to get right. It seems easy/okay enough just to have some extra info['chs'] entries that won't ever be used...
There was a problem hiding this comment.
Huh. In my mind, picks would always be a list of str. Didn't I enforce that somewhere?
There was a problem hiding this comment.
Eventually some sanity check converts them to str but by that time the bug has already occurred. But in the object itself they were still stored as a single string (which generally worked) or as an ndarray of int (which didn't), depending on what was passed originally to the constructor
I agree storing the ordered channel names and using pick_channels(...,ordered=True) would be a good way to avoid the bug and avoid needing to keep am complete info
|
So far so good @georgeoneill 👍 |
|
A basic tutorial is complete, for now. The final evoked plot is passable for now (you can see the M100 at least), but the real denoising magic happens when HFC is applied. |
Interesting, we use an IIR (6th order Butterworth) in our SPM code, it seems to behave nicely for us. Filters are strange.
Thanks, this is fine for now. If we struggle later, we have the power to do provide a downsampled (and anti-aliased) version of the OPM data (in raw binary format). 6 kHz is unweildy at the best of times, especially when QuSpin rate their sensors' sensitivity rolls off at > 130 Hz! |
|
Just pushed a tiny commit to set the Tutorial gallery thumbnail and get CIs to run, marking for merge when green. Thanks for this awesome addition @georgeoneill , hopefully the first of many 😄 |
... and I meant to add that we should probably do this in some next iteration that adds HFC and/or head movement correction. If you can get me the files at some point, I can add them. But at this point there's no rush I think |
|
🎉 Congrats on merging your first pull request! 🥳 Looking forward to seeing more from you in the future! 💪 |


Reference issue
Closes #11257.
What does this implement/fix?
RawUCLRawFIL object.Open question
This PR has used UCL instead of FIL, to avoid confusion with FIF. However the corresponding mne-test-data uses FIL. Should we use FIL for consistency here?