Repository navigation
Description
This issue is to keep track of the remaining Digitization PRs. It reflects a conversation with @larsoner.
TODO (each item will be a separate PR):
-
Add move all
montageuse to Raw and Epochs readers that havemontageargument to call only the following at the end of their__init__, not used anywhere else (Add montage parameter to BaseRaw #6462):if montage is not None: self.set_montage(montage) -
Deprecate
montageargument in all readers that supportmontagearguments ([MRG] Deprecate montage param from all EEG raw readers #6534)- Make we have a test like sure Digitization progress #6461 (comment)
def test_montage(): raw_montage = read_raw_*(fname, montage=my_montage) raw_none = read_raw_*(fname, montage=None) raw_none.set_montage(montage) assert object_diff(raw_none.info['chs'], raw_montage.info['chs']) assert object_diff(raw_none.info['dig'], raw_montage.info['dig'])
- Make we have a test like sure Digitization progress #6461 (comment)
-
Replicate montage and digmontage usecases withThis no longer applies. We keptDigitizationDigMontage, removeMontageand makedigitizationprivate.- Refactor
DigMontageto useDigitization+ch_namesas representation (+ deprecate things that we no longer want to support) (MNT: Change DigMontage representation to use Digitization #6639) - Make
digitizationmodule private_digitization(Make mne/digitization private mne/_digitization #6700) - Fix
DigMontage.save(savesdigbut notch_names) - Fix
DigMontage()without parmeters. - Refactor
DigMontagetests. All that we did not change in MNT: Change DigMontage representation to use Digitization #6639 because we only wanted to touch code logic not test logic. -
set_montagetakes onlyDigMontagenotMontage - Some refactor of
mne/_digitization. We have all_make_dig_{kit, artemist, bti}that overlap withDigMontage. - deprecate
read_dig_montagein favor ofread_dig_montage_FOOormake_dig_montage(np.arrays..). No transforms allowed. - deprecate
DigMontage.dev_head_tin favor of:- Storing the 2 versionsof the HPI points in the
DigMontage.dig: one inFIFFV_COORD_HEADand the other inFIFFV_COORD_MEG.
When you wantdev_head_t, callDigMontage.get_dev_head_t()and it will compute it from these directly. - a free function returning a proper transformation:
def compute_dev_head_t(dig: Digitization) -> Transform:
- Storing the 2 versionsof the HPI points in the
- rename
elp,hpiin favor of the new names (hpi,hpi_dev) in the internal calls. (I'm not sure this will be needed. We'll see) -
DigMontage.transform_to_head()(not fully clear but it will get more clear when addressing the others). Things that could require:- a free function like:
def get_fiducials(dig: Digitization) -> Fiducials:(Fiducialsis aBunchwithnasion,lpa,rpaor similar, named tuple whatever.) - do all points need to be in 'head' or only some of them?
- does it need to be a method? (probably yes)
- a free function like:
- Refactor
-
remove fit_match_points outside of coreg.
-
move
read_dig_XXXXtomne/io/ -
AddFix theplot()toDigitizationclass WIP: Add plot method to digitization #6412. 3D plot with each dig point, maybe symbol based on coordinate frame (sphere=head, cube=meg, ... ?) and color based on type (eeg, extra, hpi, we have colors for these indefaults.pyorplot_alignmentsomewhere)DigMontage-Montagemess we had in the existing plot withpoint_namesand custom transforms. ([RFC] Are we aiming to be able to write plot_montage like this? #6649, maybe different PR) -
Make a none smoke test for applied transforms Reveal missing test massich/mne-python#31 (I've close it by error, it still applies)
Log of past PRs:
- Add example showing all the eeg helmets (Add example showing all the eeg helmets #6158)
- MRG: Prepare BTI to refactor for Digitization (MRG: Prepare BTI to refactor for Digitization #6228)
- MAINT: Refactor digitation for KIT, artemis123, bti (MAINT: Refactor digitation for KIT, artemis123, bti #6368)
- ENH: Add digitization class (ENH: Add digitization class #6369)
- MNT: Change DigMontage representation to use Digitization (MNT: Change DigMontage representation to use Digitization #6639)
- Make mne/digitization private mne/_digitization (Make mne/digitization private mne/_digitization #6700)
Cross-reference issues:
- API: Refactor montage classes #3893 (comment)
- [RFC] changing python type by a term definition in docstring #6698
Here is a summary of the readers with respect to how they are tested. Main focus: does the reader go through _test_raw_reader? has the reader been tested with digitization or None? Does the reader have digitization or a montage?
| _test_raw_reader | None | Digitization | other |
-----------------------+------------------+------+--------------+---------+
RawArray | x | x | | |
read_raw_artemis123 | x | | x | |
read_raw_bdf | | | | montage |
read_raw_brainvision | x | x | x | |
read_raw_bti | x | x | x | |
read_raw_cnt | x | x | | montage |
read_raw_ctf | x | | x | |
read_raw_edf | x | x | x | |
read_raw_eeglab | x | | x | |
read_raw_egi | x | x | | montage |
read_raw_eximia | x | x | | ------- |
read_raw_fieldtrip | | | | ------- |
read_raw_fif | x | | x | |
read_raw_gdf | x | x | | montage |
read_raw_kit | x | x | x | |
read_raw_nicolet | x | x | | montage |other notes:
- duplicated montages
import os.path as op
import mne
fname = op.join(op.dirname(mne.io.edf.__file__), 'tests', 'data', 'biosemi.hpts')
default_biosemi64 = mne.channels.read_montage('biosemi64')
edf_testing_biosemi64 = mne.channels.read_montage(fname)
Activity
GuillaumeFavelier commentedon Jun 17, 2019
Thanks for the overview @massich! I think there is also #6412 (add a
plot()function to theDigitizationclass). I still have to integrate @agramfort reviews.massich commentedon Jun 17, 2019
@GuillaumeFavelier right!
larsoner commentedon Jun 18, 2019
@massich updated top description with my suggested order / description based on extrapolating what I discussed with @agramfort
massich commentedon Jun 19, 2019
just to make sure that we are all on the same page. This should pass without warning error nothing:
agramfort commentedon Jun 19, 2019
larsoner commentedon Jun 19, 2019
Yes in this PR. Eventually in this release cycle we will deprecade the
read_raw_*(fname, montage=my_montage), but not in this PR. (It should be almost trivial after this PR.)larsoner commentedon Jun 19, 2019
Sorry, I meant to say that yes, that should be the behavior in #6462.
In the PR after that,
read_raw_*(fname, montage=my_montage)should be deprecated and the user told to doraw.set_montage(my_montage).massich commentedon Jun 26, 2019
update_ch_nameshas been exposed in 0.19. Once Digitization is here, we should be able to remove it from the signature.mne-python/mne/channels/channels.py
Line 446 in 2f9873e
In other words,
Digitizationshould go in before releasing so that we don't need to deprecate this parameter.massich commentedon Jul 10, 2019
now that montage is deprecated, the idea is that
raw.set_montageonly takes Digitization and that as a middle step montages and digmontages had to be transformed to Digitizations, am I right? @agramfort, @larsonerlarsoner commentedon Jul 10, 2019
Yeah I think so.
agramfort commentedon Jul 10, 2019
massich commentedon Jul 11, 2019
set_montagesounds fine to memassich commentedon Jul 11, 2019
There are at least two ways of getting the digitization information from a fif file:
mne-python/mne/io/meas_info.py
Line 891 in 897c3b2
mne-python/mne/channels/montage.py
Line 637 in 897c3b2
it is true that one populates
meas_infowhile the other returns aDigMontage, but they are essentially the same.(The later calls the former)
agramfort commentedon Jul 11, 2019
massich commentedon Aug 26, 2019
Regarding the
kindwe have thisFIF.FIFV_MNE_COORD_DIGITIZERandFIFFV_COORD_ISOTRAKthat is used nowhere.agramfort commentedon Aug 26, 2019
teonbrooks commentedon Aug 28, 2019
explaining some context behind the KIT digitization process at NYU based on a discussion with @massich.
so for the KIT system, the use of the labels elp and hpi had come from the naming used in the old mne-c manual.
HPI
Head Position Indicator (HPI) points come from the head localization procedure in the MEG with the attached coils. There are five coils for the KIT system, these points have a specific order, and that this allows for the coregistration of the head into MEG device space for the
dev_head_tcomputation. This is stored in either a.mrkfile or a.sqdfile, which just contains this head localization procedure.ELP
The electrode points file has been constructed to emulate the
.elpfile structure that was produced from the old ISOTRAK pen IIRC. In this file, there is a section for the fiducials which exists at the top, and there is a section for the corresponding HPI points but collected in the digitizer native space.The NYU lab with the KIT system has been accustomed to include all 8 points in an exported txt file from the FASKTRAK digitizer. This has been done as a matter of lab protocol convention.
I think that ideally there should be three files as opposed to two files: one for the HPI points (5 points), one for those points in digitizer space (5 points), and one file for the fiducials (3 points). I don't think including the fiducials in the points file is a good idea anymore because this requires an arbitrary assignment of points to references. From my discussion with @massich, it is true that someone could place the points in any manner they sought fit but there is no way for the software to intelligently know this.
File Format
FASKTRAK allows for exports to txt files but there isn't anything inherently special about it, it just arbitrary number of point x 3. These points are referenced to a reference box therefore all the digitizer data must be re-reference to neuromag head space based on fiducials. The polhemus file reader is just one that ignores the header and just reads the data in as an array.
Naming
As for the names of HPI and ELP, there has been a proposal to rename the points:
HPI -->
hpi_devELP -->
hpiAfter thinking about this, I think that HPI should remain being
hpiand ELP should be the one renamed to something likehpi_isotrakorhpi_isotrak_spaceHPI -->
hpiELP -->
hpi_isotrakhope this provides some context and recommendations.
larsoner commentedon Sep 21, 2019
@massich do we need any of the rest of these for 0.19? Or just #6764?
massich commentedon Sep 23, 2019
I think #6764 is enough. I'm closing this one