/
docs.py
2519 lines (2282 loc) · 97 KB
/
docs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
"""The documentation functions."""
# Authors: Eric Larson <larson.eric.d@gmail.com>
#
# License: BSD (3-clause)
from copy import deepcopy
import inspect
import os
import os.path as op
import sys
import warnings
import webbrowser
from .config import get_config
from ..defaults import HEAD_SIZE_DEFAULT
from ..externals.doccer import filldoc, unindent_dict
from .check import _check_option
##############################################################################
# Define our standard documentation entries
docdict = dict()
# Verbose
docdict['verbose'] = """
verbose : bool, str, int, or None
If not None, override default verbose level (see :func:`mne.verbose`
and :ref:`Logging documentation <tut_logging>` for more).
If used, it should be passed as a keyword-argument only."""
docdict['verbose_meth'] = (docdict['verbose'] + ' Defaults to self.verbose.')
# Preload
docdict['preload'] = """
preload : bool or str (default False)
Preload data into memory for data manipulation and faster indexing.
If True, the data will be preloaded into memory (fast, requires
large amount of memory). If preload is a string, preload is the
file name of a memory-mapped file which is used to store the data
on the hard drive (slower, requires less memory)."""
docdict['preload_concatenate'] = """
preload : bool, str, or None (default None)
Preload data into memory for data manipulation and faster indexing.
If True, the data will be preloaded into memory (fast, requires
large amount of memory). If preload is a string, preload is the
file name of a memory-mapped file which is used to store the data
on the hard drive (slower, requires less memory). If preload is
None, preload=True or False is inferred using the preload status
of the instances passed in.
"""
# Raw
_on_missing_base = """\
Can be ``'raise'`` (default) to raise an error, ``'warn'`` to emit a
warning, or ``'ignore'`` to ignore when"""
docdict['on_split_missing'] = """
on_split_missing : str
Can be ``'raise'`` to raise an error, ``'warn'`` (default) to emit a
warning, or ``'ignore'`` to ignore when a split file is missing.
The default will change from ``'warn'`` to ``'raise'`` in 0.23, set the
value explicitly to avoid deprecation warnings.
.. versionadded:: 0.22
""" # after deprecation period, this can use _on_missing_base
# Cropping
docdict['include_tmax'] = """
include_tmax : bool
If True (default), include tmax. If False, exclude tmax (similar to how
Python indexing typically works).
.. versionadded:: 0.19
"""
docdict['notes_tmax_included_by_default'] = """
Unlike Python slices, MNE time intervals by default include **both**
their end points; ``crop(tmin, tmax)`` returns the interval
``tmin <= t <= tmax``. Pass ``include_tmax=False`` to specify the half-open
interval ``tmin <= t < tmax`` instead.
"""
docdict['raw_tmin'] = """
tmin : float
Start time of the raw data to use in seconds (must be >= 0).
"""
docdict['raw_tmax'] = """
tmax : float
End time of the raw data to use in seconds (cannot exceed data duration).
"""
# Raw
docdict['standardize_names'] = """
standardize_names : bool
If True, standardize MEG and EEG channel names to be
``"MEG ###"`` and ``"EEG ###"``. If False (default), native
channel names in the file will be used when possible.
"""
docdict['event_color'] = """
event_color : color object | dict | None
Color(s) to use for events. To show all events in the same color, pass any
matplotlib-compatible color. To color events differently, pass a `dict`
that maps event names or integer event numbers to colors (must include
entries for *all* events, or include a "fallback" entry with key ``-1``).
If ``None``, colors are chosen from the current Matplotlib color cycle.
"""
docdict['browse_group_by'] = """
group_by : str
How to group channels. ``'type'`` groups by channel type,
``'original'`` plots in the order of ch_names, ``'selection'`` uses
Elekta's channel groupings (only works for Neuromag data),
``'position'`` groups the channels by the positions of the sensors.
``'selection'`` and ``'position'`` modes allow custom selections by
using a lasso selector on the topomap. In butterfly mode, ``'type'``
and ``'original'`` group the channels by type, whereas ``'selection'``
and ``'position'`` use regional grouping. ``'type'`` and ``'original'``
modes are ignored when ``order`` is not ``None``. Defaults to ``'type'``.
"""
# Epochs
docdict['proj_epochs'] = """
proj : bool | 'delayed'
Apply SSP projection vectors. If proj is 'delayed' and reject is not
None the single epochs will be projected before the rejection
decision, but used in unprojected state if they are kept.
This way deciding which projection vectors are good can be postponed
to the evoked stage without resulting in lower epoch counts and
without producing results different from early SSP application
given comparable parameters. Note that in this case baselining,
detrending and temporal decimation will be postponed.
If proj is False no projections will be applied which is the
recommended value if SSPs are not used for cleaning the data.
"""
# Reject by annotation
docdict['reject_by_annotation_all'] = """
reject_by_annotation : bool
Whether to omit bad segments from the data before fitting. If ``True``
(default), annotated segments whose description begins with ``'bad'`` are
omitted. If ``False``, no rejection based on annotations is performed.
"""
docdict['reject_by_annotation_epochs'] = """
reject_by_annotation : bool
Whether to reject based on annotations. If ``True`` (default), epochs
overlapping with segments whose description begins with ``'bad'`` are
rejected. If ``False``, no rejection based on annotations is performed.
"""
docdict['reject_by_annotation_raw'] = docdict['reject_by_annotation_all'] + """
Has no effect if ``inst`` is not a :class:`mne.io.Raw` object.
"""
# General plotting
docdict["show"] = """
show : bool
Show figure if True.
"""
docdict["title_None"] = """
title : str | None
Title. If None (default), no title is displayed.
"""
docdict["plot_proj"] = """
proj : bool | 'interactive' | 'reconstruct'
If true SSP projections are applied before display. If 'interactive',
a check box for reversible selection of SSP projection vectors will
be shown. If 'reconstruct', projection vectors will be applied and then
M/EEG data will be reconstructed via field mapping to reduce the signal
bias caused by projection.
.. versionchanged:: 0.21
Support for 'reconstruct' was added.
"""
docdict["topomap_ch_type"] = """
ch_type : 'mag' | 'grad' | 'planar1' | 'planar2' | 'eeg' | None
The channel type to plot. For 'grad', the gradiometers are collected in
pairs and the RMS for each pair is plotted.
If None, then channels are chosen in the order given above.
"""
docdict["topomap_vmin_vmax"] = """
vmin, vmax : float | callable | None
Lower and upper bounds of the colormap, in the same units as the data.
If ``vmin`` and ``vmax`` are both ``None``, they are set at ± the
maximum absolute value of the data (yielding a colormap with midpoint
at 0). If only one of ``vmin``, ``vmax`` is ``None``, will use
``min(data)`` or ``max(data)``, respectively. If callable, should
accept a :class:`NumPy array <numpy.ndarray>` of data and return a
float.
"""
docdict["topomap_cmap"] = """
cmap : matplotlib colormap | (colormap, bool) | 'interactive' | None
Colormap to use. If tuple, the first value indicates the colormap to
use and the second value is a boolean defining interactivity. In
interactive mode the colors are adjustable by clicking and dragging the
colorbar with left and right mouse button. Left mouse button moves the
scale up and down and right mouse button adjusts the range (zoom).
The mouse scroll can also be used to adjust the range. Hitting space
bar resets the range. Up and down arrows can be used to change the
colormap. If None (default), 'Reds' is used for all positive data,
otherwise defaults to 'RdBu_r'. If 'interactive', translates to
(None, True).
.. warning:: Interactive mode works smoothly only for a small amount
of topomaps. Interactive mode is disabled by default for more than
2 topomaps.
"""
docdict["topomap_sensors"] = """
sensors : bool | str
Add markers for sensor locations to the plot. Accepts matplotlib plot
format string (e.g., 'r+' for red plusses). If True (default),
circles will be used.
"""
docdict["topomap_colorbar"] = """
colorbar : bool
Plot a colorbar in the rightmost column of the figure.
"""
docdict["topomap_scalings"] = """
scalings : dict | float | None
The scalings of the channel types to be applied for plotting.
If None, defaults to ``dict(eeg=1e6, grad=1e13, mag=1e15)``.
"""
docdict["topomap_units"] = """
units : dict | str | None
The unit of the channel type used for colorbar label. If
scale is None the unit is automatically determined.
"""
docdict["topomap_res"] = """
res : int
The resolution of the topomap image (n pixels along each side).
"""
docdict["topomap_size"] = """
size : float
Side length per topomap in inches.
"""
docdict["topomap_cbar_fmt"] = """
cbar_fmt : str
String format for colorbar values.
"""
docdict["topomap_mask"] = """
mask : ndarray of bool, shape (n_channels, n_times) | None
The channels to be marked as significant at a given time point.
Indices set to ``True`` will be considered. Defaults to ``None``.
"""
docdict["topomap_mask_params"] = """
mask_params : dict | None
Additional plotting parameters for plotting significant sensors.
Default (None) equals::
dict(marker='o', markerfacecolor='w', markeredgecolor='k',
linewidth=0, markersize=4)
"""
docdict['topomap_outlines'] = """
outlines : 'head' | 'skirt' | dict | None
The outlines to be drawn. If 'head', the default head scheme will be
drawn. If 'skirt' the head scheme will be drawn, but sensors are
allowed to be plotted outside of the head circle. If dict, each key
refers to a tuple of x and y positions, the values in 'mask_pos' will
serve as image mask.
Alternatively, a matplotlib patch object can be passed for advanced
masking options, either directly or as a function that returns patches
(required for multi-axis plots). If None, nothing will be drawn.
Defaults to 'head'.
"""
docdict['topomap_contours'] = """
contours : int | array of float
The number of contour lines to draw. If 0, no contours will be drawn.
When an integer, matplotlib ticker locator is used to find suitable
values for the contour thresholds (may sometimes be inaccurate, use
array for accuracy). If an array, the values represent the levels for
the contours. The values are in µV for EEG, fT for magnetometers and
fT/m for gradiometers. If colorbar=True, the ticks in colorbar
correspond to the contour levels. Defaults to 6.
"""
docdict['topomap_image_interp'] = """
image_interp : str
The image interpolation to be used. All matplotlib options are
accepted.
"""
docdict['topomap_average'] = """
average : float | None
The time window around a given time to be used for averaging (seconds).
For example, 0.01 would translate into window that starts 5 ms before
and ends 5 ms after a given time point. Defaults to None, which means
no averaging.
"""
docdict['topomap_axes'] = """
axes : instance of Axes | list | None
The axes to plot to. If list, the list must be a list of Axes of the
same length as ``times`` (unless ``times`` is None). If instance of
Axes, ``times`` must be a float or a list of one float.
Defaults to None.
"""
docdict['topomap_extrapolate'] = """
extrapolate : str
Options:
- ``'box'``
Extrapolate to four points placed to form a square encompassing all
data points, where each side of the square is three times the range
of the data in the respective dimension.
- ``'local'`` (default)
Extrapolate only to nearby points (approximately to points closer than
median inter-electrode distance). This will also set the
mask to be polygonal based on the convex hull of the sensors.
- ``'head'``
Extrapolate out to the edges of the clipping circle. This will be on
the head circle when the sensors are contained within the head circle,
but it can extend beyond the head when sensors are plotted outside
the head circle.
.. versionchanged:: 0.21
- The default was changed to ``'local'``
- ``'local'`` was changed to use a convex hull mask
- ``'head'`` was changed to extrapolate out to the clipping circle.
"""
docdict['topomap_border'] = """
border : float | 'mean'
Value to extrapolate to on the topomap borders. If ``'mean'`` (default),
then each extrapolated point has the average value of its neighbours.
.. versionadded:: 0.20
"""
docdict['topomap_sphere'] = """
sphere : float | array-like | instance of ConductorModel
The sphere parameters to use for the cartoon head.
Can be array-like of shape (4,) to give the X/Y/Z origin and radius in
meters, or a single float to give the radius (origin assumed 0, 0, 0).
Can also be a spherical ConductorModel, which will use the origin and
radius. Can also be None (default) which is an alias for %s.
Currently the head radius does not affect plotting.
.. versionadded:: 0.20
""" % (HEAD_SIZE_DEFAULT,)
docdict['topomap_sphere_auto'] = """
sphere : float | array-like | str | None
The sphere parameters to use for the cartoon head.
Can be array-like of shape (4,) to give the X/Y/Z origin and radius in
meters, or a single float to give the radius (origin assumed 0, 0, 0).
Can also be a spherical ConductorModel, which will use the origin and
radius. Can be "auto" to use a digitization-based fit.
Can also be None (default) to use 'auto' when enough extra digitization
points are available, and %s otherwise.
Currently the head radius does not affect plotting.
.. versionadded:: 0.20
""" % (HEAD_SIZE_DEFAULT,)
docdict['topomap_ch_type'] = """
ch_type : str
The channel type being plotted. Determines the ``'auto'``
extrapolation mode.
.. versionadded:: 0.21
"""
docdict['topomap_show_names'] = """
show_names : bool | callable
If True, show channel names on top of the map. If a callable is
passed, channel names will be formatted using the callable; e.g., to
delete the prefix 'MEG ' from all channel names, pass the function
``lambda x: x.replace('MEG ', '')``. If ``mask`` is not None, only
significant sensors will be shown.
"""
# PSD topomaps
docdict["psd_topo_vlim_joint"] = """
vlim : tuple of length 2 | 'joint'
Colormap limits to use. If a :class:`tuple` of floats, specifies the
lower and upper bounds of the colormap (in that order); providing
``None`` for either entry will set the corresponding boundary at the
min/max of the data (separately for each topomap). Elements of the
:class:`tuple` may also be callable functions which take in a
:class:`NumPy array <numpy.ndarray>` and return a scalar.
If ``vlim='joint'``, will compute the colormap limits jointly across
all topomaps of the same channel type, using the min/max of the data.
Defaults to ``(None, None)``.
.. versionadded:: 0.21
"""
docdict['psd_topo_agg_fun'] = """
agg_fun : callable
The function used to aggregate over frequencies. Defaults to
:func:`numpy.sum` if ``normalize=True``, else :func:`numpy.mean`.
"""
docdict['psd_topo_dB'] = """
dB : bool
If ``True``, transform data to decibels (with ``10 * np.log10(data)``)
following the application of ``agg_fun``. Ignored if ``normalize=True``.
"""
docdict['psd_topo_cmap'] = """
cmap : matplotlib colormap | (colormap, bool) | 'interactive' | None
Colormap to use. If :class:`tuple`, the first value indicates the colormap
to use and the second value is a boolean defining interactivity. In
interactive mode the colors are adjustable by clicking and dragging the
colorbar with left and right mouse button. Left mouse button moves the
scale up and down and right mouse button adjusts the range. Hitting
space bar resets the range. Up and down arrows can be used to change
the colormap. If ``None``, ``'Reds'`` is used for data that is either
all-positive or all-negative, and ``'RdBu_r'`` is used otherwise.
``'interactive'`` is equivalent to ``(None, True)``. Defaults to ``None``.
"""
docdict['psd_topo_cbar_fmt'] = """
cbar_fmt : str
Format string for the colorbar tick labels. If ``'auto'``, is equivalent
to '%0.3f' if ``dB=False`` and '%0.1f' if ``dB=True``. Defaults to
``'auto'``.
"""
docdict['psd_topo_normalize'] = """
normalize : bool
If True, each band will be divided by the total power. Defaults to
False.
"""
docdict['psd_topo_bands'] = """
bands : list of tuple | None
The frequencies or frequency ranges to plot. Length-2 tuples specify
a single frequency and a subplot title (e.g.,
``(6.5, 'presentation rate')``); length-3 tuples specify lower and
upper band edges and a subplot title. If ``None`` (the default),
expands to::
bands = [(0, 4, 'Delta'), (4, 8, 'Theta'), (8, 12, 'Alpha'),
(12, 30, 'Beta'), (30, 45, 'Gamma')]
In bands where a single frequency is provided, the topomap will reflect
the single frequency bin that is closest to the provided value.
"""
docdict['psd_topo_axes'] = """
axes : list of Axes | None
List of axes to plot consecutive topographies to. If ``None`` the axes
will be created automatically. Defaults to ``None``.
"""
# Picks
picks_header = 'picks : str | list | slice | None'
picks_intro = ('Channels to include. Slices and lists of integers will be '
'interpreted as channel indices.')
_reminder = ("Note that channels in ``info['bads']`` *will be included* if "
"their {}indices are explicitly provided.\n")
reminder = _reminder.format('names or ')
reminder_nostr = _reminder.format('')
noref = f'(excluding reference MEG channels). {reminder}'
picks_base = f"""{picks_header}
{picks_intro} In lists, channel *type* strings
(e.g., ``['meg', 'eeg']``) will pick channels of those
types, channel *name* strings (e.g., ``['MEG0111', 'MEG2623']``
will pick the given channels. Can also be the string values
"all" to pick all channels, or "data" to pick :term:`data channels`.
None (default) will pick"""
docdict['picks_header'] = picks_header # these get reused as stubs in a
docdict['picks_base'] = picks_base # couple places (e.g., BaseEpochs)
docdict['picks_all'] = f'{picks_base} all channels. {reminder}'
docdict['picks_all_data'] = f'{picks_base} all data channels. {reminder}'
docdict['picks_good_data'] = f'{picks_base} good data channels. {reminder}'
docdict['picks_all_data_noref'] = f'{picks_base} all data channels {noref}'
docdict['picks_good_data_noref'] = f'{picks_base} good data channels {noref}'
docdict['picks_nostr'] = f"""picks : list | slice | None
{picks_intro} None (default) will pick all channels. {reminder_nostr}"""
# Filtering
docdict['l_freq'] = """
l_freq : float | None
For FIR filters, the lower pass-band edge; for IIR filters, the lower
cutoff frequency. If None the data are only low-passed.
"""
docdict['h_freq'] = """
h_freq : float | None
For FIR filters, the upper pass-band edge; for IIR filters, the upper
cutoff frequency. If None the data are only high-passed.
"""
docdict['filter_length'] = """
filter_length : str | int
Length of the FIR filter to use (if applicable):
* **'auto' (default)**: The filter length is chosen based
on the size of the transition regions (6.6 times the reciprocal
of the shortest transition band for fir_window='hamming'
and fir_design="firwin2", and half that for "firwin").
* **str**: A human-readable time in
units of "s" or "ms" (e.g., "10s" or "5500ms") will be
converted to that number of samples if ``phase="zero"``, or
the shortest power-of-two length at least that duration for
``phase="zero-double"``.
* **int**: Specified length in samples. For fir_design="firwin",
this should not be used.
"""
docdict['filter_length_notch'] = docdict['filter_length'] + """
When ``method=='spectrum_fit'``, this sets the effective window duration
over which fits are computed. See :func:`mne.filter.create_filter`
for options. Longer window lengths will give more stable frequency
estimates, but require (potentially much) more processing and are not able
to adapt as well to non-stationarities.
The default in 0.21 is None, but this will change to ``'10s'`` in 0.22.
"""
docdict['l_trans_bandwidth'] = """
l_trans_bandwidth : float | str
Width of the transition band at the low cut-off frequency in Hz
(high pass or cutoff 1 in bandpass). Can be "auto"
(default) to use a multiple of ``l_freq``::
min(max(l_freq * 0.25, 2), l_freq)
Only used for ``method='fir'``.
"""
docdict['h_trans_bandwidth'] = """
h_trans_bandwidth : float | str
Width of the transition band at the high cut-off frequency in Hz
(low pass or cutoff 2 in bandpass). Can be "auto"
(default in 0.14) to use a multiple of ``h_freq``::
min(max(h_freq * 0.25, 2.), info['sfreq'] / 2. - h_freq)
Only used for ``method='fir'``.
"""
docdict['phase'] = """
phase : str
Phase of the filter, only used if ``method='fir'``.
Symmetric linear-phase FIR filters are constructed, and if ``phase='zero'``
(default), the delay of this filter is compensated for, making it
non-causal. If ``phase=='zero-double'``,
then this filter is applied twice, once forward, and once backward
(also making it non-causal). If 'minimum', then a minimum-phase filter will
be constricted and applied, which is causal but has weaker stop-band
suppression.
.. versionadded:: 0.13
"""
docdict['fir_design'] = """
fir_design : str
Can be "firwin" (default) to use :func:`scipy.signal.firwin`,
or "firwin2" to use :func:`scipy.signal.firwin2`. "firwin" uses
a time-domain design technique that generally gives improved
attenuation using fewer samples than "firwin2".
.. versionadded:: 0.15
"""
docdict['fir_window'] = """
fir_window : str
The window to use in FIR design, can be "hamming" (default),
"hann" (default in 0.13), or "blackman".
.. versionadded:: 0.15
"""
docdict['pad-fir'] = """
pad : str
The type of padding to use. Supports all :func:`numpy.pad` ``mode``
options. Can also be "reflect_limited", which pads with a
reflected version of each vector mirrored on the first and last
values of the vector, followed by zeros. Only used for ``method='fir'``.
"""
docdict['method-fir'] = """
method : str
'fir' will use overlap-add FIR filtering, 'iir' will use IIR
forward-backward filtering (via filtfilt).
"""
docdict['n_jobs-fir'] = """
n_jobs : int | str
Number of jobs to run in parallel. Can be 'cuda' if ``cupy``
is installed properly and method='fir'.
"""
docdict['n_jobs-cuda'] = """
n_jobs : int | str
Number of jobs to run in parallel. Can be 'cuda' if ``cupy``
is installed properly.
"""
docdict['iir_params'] = """
iir_params : dict | None
Dictionary of parameters to use for IIR filtering.
If iir_params is None and method="iir", 4th order Butterworth will be used.
For more information, see :func:`mne.filter.construct_iir_filter`.
"""
docdict['npad'] = """
npad : int | str
Amount to pad the start and end of the data.
Can also be "auto" to use a padding that will result in
a power-of-two size (can be much faster).
"""
docdict['window-resample'] = """
window : str | tuple
Frequency-domain window to use in resampling.
See :func:`scipy.signal.resample`.
"""
docdict['average-psd'] = """
average : str | None
How to average the segments. If ``mean`` (default), calculate the
arithmetic mean. If ``median``, calculate the median, corrected for
its bias relative to the mean. If ``None``, returns the unaggregated
segments.
"""
docdict['window-psd'] = """
window : str | float | tuple
Windowing function to use. See :func:`scipy.signal.get_window`.
"""
docdict['decim'] = """
decim : int
Factor by which to subsample the data.
.. warning:: Low-pass filtering is not performed, this simply selects
every Nth sample (where N is the value passed to
``decim``), i.e., it compresses the signal (see Notes).
If the data are not properly filtered, aliasing artifacts
may occur.
"""
docdict['decim_offset'] = """
offset : int
Apply an offset to where the decimation starts relative to the
sample corresponding to t=0. The offset is in samples at the
current sampling rate.
.. versionadded:: 0.12
"""
docdict['decim_notes'] = """
For historical reasons, ``decim`` / "decimation" refers to simply subselecting
samples from a given signal. This contrasts with the broader signal processing
literature, where decimation is defined as (quoting
:footcite:`OppenheimEtAl1999`, p. 172; which cites
:footcite:`CrochiereRabiner1983`):
"... a general system for downsampling by a factor of M is the one shown
in Figure 4.23. Such a system is called a decimator, and downsampling
by lowpass filtering followed by compression [i.e, subselecting samples]
has been termed decimation (Crochiere and Rabiner, 1983)."
Hence "decimation" in MNE is what is considered "compression" in the signal
processing community.
Decimation can be done multiple times. For example,
``inst.decimate(2).decimate(2)`` will be the same as
``inst.decimate(4)``.
"""
# cHPI
docdict['chpi_t_window'] = """
t_window : float
Time window to use to estimate the amplitudes, default is
0.2 (200 ms).
"""
docdict['chpi_ext_order'] = """
ext_order : int
The external order for SSS-like interfence suppression.
The SSS bases are used as projection vectors during fitting.
.. versionchanged:: 0.20
Added ``ext_order=1`` by default, which should improve
detection of true HPI signals.
"""
docdict['chpi_adjust_dig'] = """
adjust_dig : bool
If True, adjust the digitization locations used for fitting based on
the positions localized at the start of the file.
"""
docdict['chpi_amplitudes'] = """
chpi_amplitudes : dict
The time-varying cHPI coil amplitudes, with entries
"times", "proj", and "slopes".
"""
docdict['chpi_locs'] = """
chpi_locs : dict
The time-varying cHPI coils locations, with entries
"times", "rrs", "moments", and "gofs".
"""
# EEG reference: set_eeg_reference
docdict['set_eeg_reference_ref_channels'] = """
ref_channels : list of str | str
Can be:
- The name(s) of the channel(s) used to construct the reference.
- ``'average'`` to apply an average reference (default)
- ``'REST'`` to use the Reference Electrode Standardization Technique
infinity reference :footcite:`Yao2001`.
- An empty list, in which case MNE will not attempt any re-referencing of
the data
"""
docdict['set_eeg_reference_projection'] = """
projection : bool
If ``ref_channels='average'`` this argument specifies if the
average reference should be computed as a projection (True) or not
(False; default). If ``projection=True``, the average reference is
added as a projection and is not applied to the data (it can be
applied afterwards with the ``apply_proj`` method). If
``projection=False``, the average reference is directly applied to
the data. If ``ref_channels`` is not ``'average'``, ``projection``
must be set to ``False`` (the default in this case).
"""
docdict['set_eeg_reference_ch_type'] = """
ch_type : 'auto' | 'eeg' | 'ecog' | 'seeg'
The name of the channel type to apply the reference to. If 'auto',
the first channel type of eeg, ecog or seeg that is found (in that
order) will be selected.
.. versionadded:: 0.19
"""
docdict['set_eeg_reference_forward'] = """
forward : instance of Forward | None
Forward solution to use. Only used with ``ref_channels='REST'``.
.. versionadded:: 0.21
"""
docdict['set_eeg_reference_see_also_notes'] = """
See Also
--------
mne.set_bipolar_reference : Convenience function for creating bipolar
references.
Notes
-----
Some common referencing schemes and the corresponding value for the
``ref_channels`` parameter:
- Average reference:
A new virtual reference electrode is created by averaging the current
EEG signal by setting ``ref_channels='average'``. Bad EEG channels are
automatically excluded if they are properly set in ``info['bads']``.
- A single electrode:
Set ``ref_channels`` to a list containing the name of the channel that
will act as the new reference, for example ``ref_channels=['Cz']``.
- The mean of multiple electrodes:
A new virtual reference electrode is created by computing the average
of the current EEG signal recorded from two or more selected channels.
Set ``ref_channels`` to a list of channel names, indicating which
channels to use. For example, to apply an average mastoid reference,
when using the 10-20 naming scheme, set ``ref_channels=['M1', 'M2']``.
- REST
The given EEG electrodes are referenced to a point at infinity using the
lead fields in ``forward``, which helps standardize the signals.
1. If a reference is requested that is not the average reference, this
function removes any pre-existing average reference projections.
2. During source localization, the EEG signal should have an average
reference.
3. In order to apply a reference, the data must be preloaded. This is not
necessary if ``ref_channels='average'`` and ``projection=True``.
4. For an average or REST reference, bad EEG channels are automatically
excluded if they are properly set in ``info['bads']``.
.. versionadded:: 0.9.0
References
----------
.. footbibliography::
"""
# ICA
docdict['n_pca_components_apply'] = """
n_pca_components : int | float | None
The number of PCA components to be kept, either absolute (int)
or fraction of the explained variance (float). If None (default),
the ``ica.n_pca_components`` from initialization will be used in 0.22;
in 0.23 all components will be used.
"""
# Maxwell filtering
docdict['maxwell_origin'] = """
origin : array-like, shape (3,) | str
Origin of internal and external multipolar moment space in meters.
The default is ``'auto'``, which means ``(0., 0., 0.)`` when
``coord_frame='meg'``, and a head-digitization-based
origin fit using :func:`~mne.bem.fit_sphere_to_headshape`
when ``coord_frame='head'``. If automatic fitting fails (e.g., due
to having too few digitization points),
consider separately calling the fitting function with different
options or specifying the origin manually.
"""
docdict['maxwell_int'] = """
int_order : int
Order of internal component of spherical expansion.
"""
docdict['maxwell_ext'] = """
ext_order : int
Order of external component of spherical expansion.
"""
docdict['maxwell_cal'] = """
calibration : str | None
Path to the ``'.dat'`` file with fine calibration coefficients.
File can have 1D or 3D gradiometer imbalance correction.
This file is machine/site-specific.
"""
docdict['maxwell_cross'] = """
cross_talk : str | None
Path to the FIF file with cross-talk correction information.
"""
docdict['maxwell_coord'] = """
coord_frame : str
The coordinate frame that the ``origin`` is specified in, either
``'meg'`` or ``'head'``. For empty-room recordings that do not have
a head<->meg transform ``info['dev_head_t']``, the MEG coordinate
frame should be used.
"""
docdict['maxwell_reg'] = """
regularize : str | None
Basis regularization type, must be "in" or None.
"in" is the same algorithm as the "-regularize in" option in
MaxFilter™.
"""
docdict['maxwell_ref'] = """
ignore_ref : bool
If True, do not include reference channels in compensation. This
option should be True for KIT files, since Maxwell filtering
with reference channels is not currently supported.
"""
docdict['maxwell_cond'] = """
bad_condition : str
How to deal with ill-conditioned SSS matrices. Can be "error"
(default), "warning", "info", or "ignore".
"""
docdict['maxwell_pos'] = """
head_pos : array | None
If array, movement compensation will be performed.
The array should be of shape (N, 10), holding the position
parameters as returned by e.g. ``read_head_pos``.
"""
docdict['maxwell_dest'] = """
destination : str | array-like, shape (3,) | None
The destination location for the head. Can be ``None``, which
will not change the head position, or a string path to a FIF file
containing a MEG device<->head transformation, or a 3-element array
giving the coordinates to translate to (with no rotations).
For example, ``destination=(0, 0, 0.04)`` would translate the bases
as ``--trans default`` would in MaxFilter™ (i.e., to the default
head location).
"""
docdict['maxwell_st_fixed_only'] = """
st_fixed : bool
If True (default), do tSSS using the median head position during the
``st_duration`` window. This is the default behavior of MaxFilter
and has been most extensively tested.
.. versionadded:: 0.12
st_only : bool
If True, only tSSS (temporal) projection of MEG data will be
performed on the output data. The non-tSSS parameters (e.g.,
``int_order``, ``calibration``, ``head_pos``, etc.) will still be
used to form the SSS bases used to calculate temporal projectors,
but the output MEG data will *only* have temporal projections
performed. Noise reduction from SSS basis multiplication,
cross-talk cancellation, movement compensation, and so forth
will not be applied to the data. This is useful, for example, when
evoked movement compensation will be performed with
:func:`~mne.epochs.average_movements`.
.. versionadded:: 0.12
"""
docdict['maxwell_mag'] = """
mag_scale : float | str
The magenetometer scale-factor used to bring the magnetometers
to approximately the same order of magnitude as the gradiometers
(default 100.), as they have different units (T vs T/m).
Can be ``'auto'`` to use the reciprocal of the physical distance
between the gradiometer pickup loops (e.g., 0.0168 m yields
59.5 for VectorView).
"""
docdict['maxwell_skip'] = """
skip_by_annotation : str | list of str
If a string (or list of str), any annotation segment that begins
with the given string will not be included in filtering, and
segments on either side of the given excluded annotated segment
will be filtered separately (i.e., as independent signals).
The default ``('edge', 'bad_acq_skip')`` will separately filter
any segments that were concatenated by :func:`mne.concatenate_raws`
or :meth:`mne.io.Raw.append`, or separated during acquisition.
To disable, provide an empty list.
"""
docdict['maxwell_extended'] = """
extended_proj : list
The empty-room projection vectors used to extend the external
SSS basis (i.e., use eSSS).
.. versionadded:: 0.21
"""
# Rank
docdict['rank'] = """
rank : None | 'info' | 'full' | dict
This controls the rank computation that can be read from the
measurement info or estimated from the data.
:data:`python:None`
The rank will be estimated from the data after proper scaling of
different channel types.
``'info'``
The rank is inferred from ``info``. If data have been processed
with Maxwell filtering, the Maxwell filtering header is used.
Otherwise, the channel counts themselves are used.
In both cases, the number of projectors is subtracted from
the (effective) number of channels in the data.
For example, if Maxwell filtering reduces the rank to 68, with
two projectors the returned value will be 66.
``'full'``
The rank is assumed to be full, i.e. equal to the
number of good channels. If a `~mne.Covariance` is passed, this can
make sense if it has been (possibly improperly) regularized without
taking into account the true data rank.
:class:`dict`
Calculate the rank only for a subset of channel types, and explicitly
specify the rank for the remaining channel types. This can be
extremely useful if you already **know** the rank of (part of) your
data, for instance in case you have calculated it earlier.
This parameter must be a dictionary whose **keys** correspond to
channel types in the data (e.g. ``'meg'``, ``'mag'``, ``'grad'``,
``'eeg'``), and whose **values** are integers representing the
respective ranks. For example, ``{'mag': 90, 'eeg': 45}`` will assume
a rank of ``90`` and ``45`` for magnetometer data and EEG data,
respectively.
The ranks for all channel types present in the data, but
**not** specified in the dictionary will be estimated empirically.
That is, if you passed a dataset containing magnetometer, gradiometer,
and EEG data together with the dictionary from the previous example,
only the gradiometer rank would be determined, while the specified
magnetometer and EEG ranks would be taken for granted.
"""
docdict['rank_None'] = docdict['rank'] + "\n The default is ``None``."
docdict['rank_info'] = docdict['rank'] + "\n The default is ``'info'``."
docdict['rank_tol'] = """
tol : float | 'auto'
Tolerance for singular values to consider non-zero in
calculating the rank. The singular values are calculated
in this method such that independent data are expected to
have singular value around one. Can be 'auto' to use the
same thresholding as :func:`scipy.linalg.orth`.
"""
docdict['rank_tol_kind'] = """
tol_kind : str
Can be: "absolute" (default) or "relative". Only used if ``tol`` is a
float, because when ``tol`` is a string the mode is implicitly relative.
After applying the chosen scale factors / normalization to the data,
the singular values are computed, and the rank is then taken as:
- ``'absolute'``
The number of singular values ``s`` greater than ``tol``.
This mode can fail if your data do not adhere to typical
data scalings.
- ``'relative'``
The number of singular values ``s`` greater than ``tol * s.max()``.
This mode can fail if you have one or more large components in the
data (e.g., artifacts).
.. versionadded:: 0.21.0
"""
# Inverses
docdict['depth'] = """
depth : None | float | dict
How to weight (or normalize) the forward using a depth prior.
If float (default 0.8), it acts as the depth weighting exponent (``exp``)
to use, which must be between 0 and 1. None is equivalent to 0, meaning
no depth weighting is performed. It can also be a :class:`dict`
containing keyword arguments to pass to
:func:`mne.forward.compute_depth_prior` (see docstring for details and
defaults). This is effectively ignored when ``method='eLORETA'``.
.. versionchanged:: 0.20
Depth bias ignored for ``method='eLORETA'``.
"""
docdict['loose'] = """
loose : float | 'auto' | dict
Value that weights the source variances of the dipole components
that are parallel (tangential) to the cortical surface. Can be:
- float between 0 and 1 (inclusive)
If 0, then the solution is computed with fixed orientation.
If 1, it corresponds to free orientations.
- ``'auto'`` (default)
Uses 0.2 for surface source spaces (unless ``fixed`` is True) and
1.0 for other source spaces (volume or mixed).
- dict
Mapping from the key for a given source space type (surface, volume,
discrete) to the loose value. Useful mostly for mixed source spaces.
"""
_pick_ori_novec = """
Options:
- ``None``
Pooling is performed by taking the norm of loose/free
orientations. In case of a fixed source space no norm is computed
leading to signed source activity.
- ``"normal"``
Only the normal to the cortical surface is kept. This is only
implemented when working with loose orientations.
"""
docdict['pick_ori-novec'] = """
pick_ori : None | "normal"
""" + _pick_ori_novec
docdict['pick_ori'] = """
pick_ori : None | "normal" | "vector"
""" + _pick_ori_novec + """
- ``"vector"``
No pooling of the orientations is done, and the vector result
will be returned in the form of a :class:`mne.VectorSourceEstimate`
object.
"""
docdict['reduce_rank'] = """
reduce_rank : bool
If True, the rank of the denominator of the beamformer formula (i.e.,