ENH: Allow removal of (up to two) bad marker coils in read_raw_kit()#12394
ENH: Allow removal of (up to two) bad marker coils in read_raw_kit()#12394larsoner merged 17 commits intomne-tools:mainfrom
Conversation
|
@JD-Zhu if you look at the style run by clicking "Details" you'll see this: From CircleCI details you'll see: I'll comment more inline but in general when a CI fails if you scroll toward the bottom of the failed/red step it should have helpful info about what went wrong! |
There was a problem hiding this comment.
Looks like a good start! I think a simple little test would be to look through our existing MNE-Python KIT test datasets to see if one of them has enough coils where you could remove one or two of the markers using bad_coils and ensure the dev_head_t that gets computed is similar (but not identical!). Let me know if anything is unclear or you want help with any of this!
Perhaps this is a naive question, but does this mean that users need to call |
|
@larsoner Thanks so much for the detailed comments and suggested changes! Is there a way to accept all the suggestions ("Add suggestion to batch" is grayed out) or should I just click "Commit suggestion" for each one? Thanks. |
Thanks for the comment. In this solution, users only need to call read_raw_kit() once. The bad coils are usually known beforehand (most likely written down during data acquisition), so they can be passed into read_raw_kit() straight away. That said, I think having an option to remove bad coils and re-compute the dev_head_t (as well as updating 'dig' and 'hpi_results'?) for raw data that have already been read in (as per your suggestion) is also not a bad idea. This can also be quite useful on epochs/evoked data, e.g. if sensor-space analysis has been carried out previously (without worrying about bad coils as it probably didn't matter for sensor space), it would be nice to be able to load the previous results (e.g. -epo.fif) and then apply bad marker coil removal to obtain the correct transformations for source analysis. Edit: when I said "post-hoc" in the original post, I meant after data acquisition (rather than after reading the data in). Sorry for the confusion! |
On the "Files changed" tab of this page (which links here) yes you can "add to batch" then commit multiple changes at once. But at least a couple of my suggestions were more ideas that you'd have to push changes for anyway (or one suggestion that applies in multiple places in principle) so probably easier just to push a commit! |
for more information, see https://pre-commit.ci
…ne-python into handle_bad_marker_coils
Sounds like a good idea! Will try to test this once I can figure out the virtual environments (which always seem to get me in trouble). |
for more information, see https://pre-commit.ci
In theory if you are in the You can see where |
|
Pushed a few commits to make CIs happy then merged, thanks @JD-Zhu ! |
* upstream/main: fix prefilter management for EDF/BDF (mne-tools#12441) [pre-commit.ci] pre-commit autoupdate (mne-tools#12541) ENH: Allow removal of (up to two) bad marker coils in read_raw_kit() (mne-tools#12394) Implement `picks` argument to `Raw.plot()` (mne-tools#12467) Add Meggie under Related Software documentation (mne-tools#12540)
@larsoner
Related to #8981 #8989
The previous fix deals with missing marker coils when reading in KIT data. However, when all five marker coils are present in the data, sometimes there are bad coils that need to be removed post-hoc. This step needs to happen before the device-head transformation is computed during the call to read_raw_kit().
Removal of bad coils cannot be achieved by simply editing the relevant digitisation file (.elp), as this causes another error downstream in fit_matched_points() due to a mismatch in the number of marker coils between the .elp and .mrk files. The .mrk file cannot be edited as it's not in plain text format.
The proposed solution here allows a list of bad coils to be passed in when calling read_raw_kit(), so that they can be removed once the marker coil info has been read in from the .elp and .mrk files. Up to two bad coils are allowed, so we can ensure there are at least three marker coils remaining to be used for the tranformation.