MCPcopy
hub / github.com/mne-tools/mne-python / rescale

Function rescale

mne/baseline.py:27–141  ·  view source on GitHub ↗

Rescale (baseline correct) data. Parameters ---------- data : array It can be of any shape. The only constraint is that the last dimension should be time. times : 1D array Time instants is seconds. %(baseline_rescale)s mode : 'mean' | 'ratio' | 'logra

(data, times, baseline, mode="mean", copy=True, picks=None, verbose=None)

Source from the content-addressed store, hash-verified

25
26@verbose
27def rescale(data, times, baseline, mode="mean", copy=True, picks=None, verbose=None):
28 """Rescale (baseline correct) data.
29
30 Parameters
31 ----------
32 data : array
33 It can be of any shape. The only constraint is that the last
34 dimension should be time.
35 times : 1D array
36 Time instants is seconds.
37 %(baseline_rescale)s
38 mode : 'mean' | 'ratio' | 'logratio' | 'percent' | 'zscore' | 'zlogratio'
39 Perform baseline correction by
40
41 - subtracting the mean of baseline values ('mean')
42 - dividing by the mean of baseline values ('ratio')
43 - dividing by the mean of baseline values and taking the log
44 ('logratio')
45 - subtracting the mean of baseline values followed by dividing by
46 the mean of baseline values ('percent')
47 - subtracting the mean of baseline values and dividing by the
48 standard deviation of baseline values ('zscore')
49 - dividing by the mean of baseline values, taking the log, and
50 dividing by the standard deviation of log baseline values
51 ('zlogratio')
52
53 copy : bool
54 Whether to return a new instance or modify in place.
55 picks : list of int | None
56 Data to process along the axis=-2 (None, default, processes all).
57 %(verbose)s
58
59 Returns
60 -------
61 data_scaled: array
62 Array of same shape as data after rescaling.
63 """
64 if copy:
65 data = data.copy()
66 if verbose is not False:
67 msg = _log_rescale(baseline, mode)
68 logger.info(msg)
69 if baseline is None or data.shape[-1] == 0:
70 return data
71
72 bmin, bmax = baseline
73 if bmin is None:
74 imin = 0
75 else:
76 imin = np.where(times >= bmin)[0]
77 if len(imin) == 0:
78 raise ValueError(
79 f"bmin is too large ({bmin}), it exceeds the largest time value"
80 )
81 imin = int(imin[0])
82 if bmax is None:
83 imax = len(times)
84 else:

Callers 11

test_epochs_bad_baselineFunction · 0.90
apply_baselineMethod · 0.85
_detrend_offset_decimMethod · 0.85
apply_baselineMethod · 0.85
apply_baselineMethod · 0.85
source_induced_powerFunction · 0.85
plot_tfr_topomapFunction · 0.85
apply_baselineMethod · 0.85
_prep_data_for_plotFunction · 0.85

Calls 5

_log_rescaleFunction · 0.85
infoMethod · 0.80
funFunction · 0.70
copyMethod · 0.45
meanMethod · 0.45

Tested by 1

test_epochs_bad_baselineFunction · 0.72