Conforming to Montage Deprecations

External Email - Use Caution

Happy Holidays MNE Team,

I am trying to conform to the new deprecation that has occurred in developer version 0.19 concerning the montage. My input file is a Neuroscan (.cnt) file extension type and thus my script previously read `mne.io.read_raw_cnt(fname, montage=?standard_1020?, etc ?)`. However, I have migrated this to a separate command `mne.channels.make_standard_montage(kind=?standard_1020)`. When doing this it skews my X,Y,Z locations. For example, when I pass `print(raw.info[?chs?])` my FP1 EEG electrode location is skewed from

`?loc?: array([-0.0294367, 0.0839171, -0.00699, 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ])`

to

`?loc?: array([-0.20257819, 0.21764863, 0.95477283, nan, nan,
               nan, nan, nan, nan, nan,
               nan, nan]).

Furthermore, when I input `print(raw.info)` the previous code output under `dig : list | 26 items (3 cardinal, 23 EEG)` while the latter code displays NoneType in the `dig`. While this seems like it would be a straight-forward change, it is definitely not as easy in practice. Is there any reason that it is not reading my montage as a standard_1020 anymore?

Thank you for any assistance provided,
Bianca Islas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20191226/1be65c34/attachment.html

External Email - Use Caution

hi Bianca,

are you doing:

raw = mne.io.read_raw_cnt(fname)
montage = mne.channels.make_standard_montage(kind=?standard_1020)
raw.set_montage(montage)

?

this should set the chs and the dig.

the reason we have changed this is that we want to make sure that the channel
locations are can considered to be in head coordinate system so you can relate
them to fsaverage for example. Is the shrinking problematic for you?

Alex

External Email - Use Caution

When I implement the changes this way, I get a ValueError that reads:
?DigMontage is a only a subset of info. There are 7 channel positions not present it the DigMontage. The required channels are: {'FP1', 'OZ', 'FZ', 'FP2', 'PZ', 'CZ', 'FPZ'}. You can use `raise_if_subset=False` in `set_montage` to avoid this ValueError and get a DeprecationWarning instead.?

If I do as suggested above I do not get an error I get an output of what which channels will be ignored and a warning that reads:
?Reading 0 ... 2552079 = 0.000 ... 1276.040 secs...

<ipython-input-12-e47b0d549095>:8: RuntimeWarning: Could not parse meas date from the header. Setting to None.
  data_format='int32', date_format='mm/dd/yy', preload=True, verbose='debug')

DigMontage is a superset of info. 78 in DigMontage will be ignored. The ignored channels are: {'T5', 'Oz', 'C5', 'PO9', 'AF1', 'PO3', 'AF4', 'F1', 'FC4', 'CP3', 'AF6', 'FC6', 'Fz', 'Cz', 'CP5', 'TP7', 'FC3', 'AF8', 'T10', 'P10', 'FT7', 'P6', 'T3', 'TP10', 'PO1', 'AF5', 'P5', 'Iz', 'FC5', 'TP9', 'POz', 'FC2', 'PO8', 'AF3', 'AF10', 'CP2', 'T9', 'PO4', 'PO2', 'FT10', 'P2', 'T6', 'AF7', 'AF9', 'C6', 'A2', 'PO5', 'PO6', 'F6', 'A1', 'P1', 'F10', 'Fp2', 'C2', 'FT8', 'F5', 'AF2', 'P9', 'FCz', 'O9', 'CP4', 'Fp1', 'PO7', 'PO10', 'C1', 'F9', 'CP1', 'O10', 'FT9', 'CP6', 'TP8', 'F2', 'T4', 'CPz', 'Pz', 'AFz', 'Fpz', 'FC1'}

<ipython-input-12-e47b0d549095>:13: RuntimeWarning: DigMontage is a only a subset of info. Did not set 7 channel positions:
FP1, OZ, FZ, FP2, PZ, CZ, FPZ
  raw.set_montage(montage, raise_if_subset=False)

Out[12]:
<RawCNT | st003_PAMR_s1079_20080319.cnt, n_channels x n_times : 38 x 2552080 (1276.0 sec), ~740.0 MB, data loaded>?

This is very problematic as I am only supposed to have 23 EEG, 5 EMG, 2 EOG, 1ECG, 2 MISC (skin conductance), and 1 Stim channel.

- Bianca

External Email - Use Caution

It looks like our standard_1020 names follow a different capitalization
pattern:

https://github.com/mne-tools/mne-python/blob/master/mne/channels/data/montages/standard_1020.elc#L107

So if you do something like:

raw.rename_channels(lambda x: x.lower().capitalize())

Or go the direct dictionary route:

raw.rename_channels(dict(FP1='Fp1', OZ='Oz', FZ='Fz', FP2='Fp2', PZ='Pz',
CZ='Cz', FPZ='Fpz'))

Some variant like this should allow not having the warning without needing
to pass `raise_if_subset=False`. And if you have channels that are actually
not EEG, make sure to do raw.set_channel_types
<https://mne.tools/dev/generated/mne.io.Raw.html#mne.io.Raw.set_channel_types>
to set them to the correct channel types.

As for the channel count mismatch, what extra channels are in raw.ch_names
that you don't expect to be there? Does raw.plot() look reasonable?

Eric

External Email - Use Caution

When I input `print(raw.ch_names)` before I would get the right channels regardless of capitalization, oddly enough. Although further on in the script it now makes sense that when I would try to do averaging it was telling me that it did not recognize ?FP1? as a channel. So, thank you very much Eric, for pointing this difference out. After migrating the code to the suggested commands the montage went from this:

To this:

The channel count is accurate now, and the raw.plot output looks exactly as it did before. As for the specifics, when I print(raw.info[?chs?]) to troubleshoot location it is still off but only by thousandths for the y-axis and hundredths in the y and z axes. Is this a by-product of the aforementioned ?shrinking? mentioned before?

External Email - Use Caution

The channel positions might differ a bit because of a slightly different
`head_size` parameter of make_standard_montage, or because we now properly
transform the channel positions to head coordinates (defined by LPA,
Nasion, and RPA).

Eric

        External Email - Use Caution

When I input `print(raw.ch_names)` before I would get the right channels
regardless of capitalization, oddly enough. Although further on in the
script it now makes sense that when I would try to do averaging it was
telling me that it did not recognize ?FP1? as a channel. So, thank you
very much Eric, for pointing this difference out. After migrating the code
to the suggested commands the montage went from this:

To this:

The channel count is accurate now, and the raw.plot output looks exactly
as it did before. As for the specifics, when I print(raw.info[?chs?]) to
troubleshoot location it is still off but only by thousandths for the
y-axis and hundredths in the y and z axes. Is this a by-product of the
aforementioned ?shrinking? mentioned before?

*From: *Eric Larson <larson.eric.d at gmail.com>
*Sent: *Friday, December 27, 2019 7:38 PM
*Subject: *Re: [Mne_analysis] Conforming to Montage Deprecations

* External Email - Use Caution *

It looks like our standard_1020 names follow a different capitalization
pattern:

https://github.com/mne-tools/mne-python/blob/master/mne/channels/data/montages/standard_1020.elc#L107

So if you do something like:

raw.rename_channels(lambda x: x.lower().capitalize())

Or go the direct dictionary route:

raw.rename_channels(dict(FP1='Fp1', OZ='Oz', FZ='Fz', FP2='Fp2', PZ='Pz',
CZ='Cz', FPZ='Fpz'))

Some variant like this should allow not having the warning without needing
to pass `raise_if_subset=False`. And if you have channels that are actually
not EEG, make sure to do raw.set_channel_types
<mne.io.Raw — MNE 1.7.0.dev17+g20174f448 documentation;
to set them to the correct channel types.

As for the channel count mismatch, what extra channels are in raw.ch_names
that you don't expect to be there? Does raw.plot() look reasonable?

Eric

* External Email - Use Caution *

When I implement the changes this way, I get a ValueError that reads:

?DigMontage is a only a subset of info. There are 7 channel positions not
present it the DigMontage. The required channels are: {'FP1', 'OZ', 'FZ',
'FP2', 'PZ', 'CZ', 'FPZ'}. You can use `raise_if_subset=False` in
`set_montage` to avoid this ValueError and get a DeprecationWarning
instead.?

If I do as suggested above I do not get an error I get an output of what
which channels will be ignored and a warning that reads:

?Reading 0 ... 2552079 = 0.000 ... 1276.040 secs...

<ipython-input-12-e47b0d549095>:8: RuntimeWarning: Could not parse meas
date from the header. Setting to None.

  data_format='int32', date_format='mm/dd/yy', preload=True,
verbose='debug')

DigMontage is a superset of info. 78 in DigMontage will be ignored. The
ignored channels are: {'T5', 'Oz', 'C5', 'PO9', 'AF1', 'PO3', 'AF4', 'F1',
'FC4', 'CP3', 'AF6', 'FC6', 'Fz', 'Cz', 'CP5', 'TP7', 'FC3', 'AF8', 'T10',
'P10', 'FT7', 'P6', 'T3', 'TP10', 'PO1', 'AF5', 'P5', 'Iz', 'FC5', 'TP9',
'POz', 'FC2', 'PO8', 'AF3', 'AF10', 'CP2', 'T9', 'PO4', 'PO2', 'FT10',
'P2', 'T6', 'AF7', 'AF9', 'C6', 'A2', 'PO5', 'PO6', 'F6', 'A1', 'P1',
'F10', 'Fp2', 'C2', 'FT8', 'F5', 'AF2', 'P9', 'FCz', 'O9', 'CP4', 'Fp1',
'PO7', 'PO10', 'C1', 'F9', 'CP1', 'O10', 'FT9', 'CP6', 'TP8', 'F2', 'T4',
'CPz', 'Pz', 'AFz', 'Fpz', 'FC1'}

<ipython-input-12-e47b0d549095>:13: RuntimeWarning: DigMontage is a only a
subset of info. Did not set 7 channel positions:

FP1, OZ, FZ, FP2, PZ, CZ, FPZ

  raw.set_montage(montage, raise_if_subset=False)

Out[12]:

<RawCNT | st003_PAMR_s1079_20080319.cnt, n_channels x n_times : 38 x
2552080 (1276.0 sec), ~740.0 MB, data loaded>?

This is very problematic as I am only supposed to have 23 EEG, 5 EMG, 2
EOG, 1ECG, 2 MISC (skin conductance), and 1 Stim channel.

   - Bianca

*From: *Alexandre Gramfort <alexandre.gramfort at inria.fr>
*Sent: *Thursday, December 26, 2019 11:35 PM
*To: *Discussion and support forum for the users of MNE Software
<mne_analysis at nmr.mgh.harvard.edu>
*Subject: *Re: [Mne_analysis] Conforming to Montage Deprecations

        External Email - Use Caution

hi Bianca,

are you doing:

raw = mne.io.read_raw_cnt(fname)

montage = mne.channels.make_standard_montage(kind=?standard_1020)

raw.set_montage(montage)

?

this should set the chs and the dig.

the reason we have changed this is that we want to make sure that the
channel

locations are can considered to be in head coordinate system so you can
relate

them to fsaverage for example. Is the shrinking problematic for you?

Alex

>

> External Email - Use Caution

>

> Happy Holidays MNE Team,

>

>

>

> I am trying to conform to the new deprecation that has occurred in
developer version 0.19 concerning the montage. My input file is a
Neuroscan (.cnt) file extension type and thus my script previously read
`mne.io.read_raw_cnt(fname, montage=?standard_1020?, etc ?)`. However, I
have migrated this to a separate command
`mne.channels.make_standard_montage(kind=?standard_1020)`. When doing this
it skews my X,Y,Z locations. For example, when I pass `print(raw.info[?chs?])`
my FP1 EEG electrode location is skewed from

>

>

>

> `?loc?: array([-0.0294367, 0.0839171, -0.00699, 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. ])`

>

>

>

> to

>

>

>

> `?loc?: array([-0.20257819, 0.21764863, 0.95477283, nan,
        nan,

>

> nan, nan, nan, nan, nan,

>

> nan, nan]).

>

>

>

> Furthermore, when I input `print(raw.info)` the previous code output
under `dig : list | 26 items (3 cardinal, 23 EEG)` while the latter code
displays NoneType in the `dig`. While this seems like it would be a
straight-forward change, it is definitely not as easy in practice. Is
there any reason that it is not reading my montage as a standard_1020
anymore?

>

>

>

> Thank you for any assistance provided,

>

> Bianca Islas

>

> _______________________________________________

> Mne_analysis mailing list

> Mne_analysis at nmr.mgh.harvard.edu

> Mne_analysis Info Page

_______________________________________________

Mne_analysis mailing list

Mne_analysis at nmr.mgh.harvard.edu

Mne_analysis Info Page

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20191228/6acde8ee/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: E8EF3AA34FD34BECAA14BA0209485DF1.png
Type: image/png
Size: 16647 bytes
Desc: not available
Url : http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20191228/6acde8ee/attachment-0002.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 131233DD1F6F4D62AE4389D7FD5076F4.png
Type: image/png
Size: 20761 bytes
Desc: not available
Url : http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20191228/6acde8ee/attachment-0003.png