MCPcopy Index your code
hub / github.com/mne-tools/mne-python / transform_data

Method transform_data

mne/source_estimate.py:1221–1297  ·  view source on GitHub ↗

Get data after a linear (time) transform has been applied. The transform is applied to each source time course independently. Parameters ---------- func : callable The transform to be applied, including parameters (see, e.g., :func:`functools

(self, func, idx=None, tmin_idx=None, tmax_idx=None)

Source from the content-addressed store, hash-verified

1219 return stc
1220
1221 def transform_data(self, func, idx=None, tmin_idx=None, tmax_idx=None):
1222 """Get data after a linear (time) transform has been applied.
1223
1224 The transform is applied to each source time course independently.
1225
1226 Parameters
1227 ----------
1228 func : callable
1229 The transform to be applied, including parameters (see, e.g.,
1230 :func:`functools.partial`). The first parameter of the function is
1231 the input data. The first return value is the transformed data,
1232 remaining outputs are ignored. The first dimension of the
1233 transformed data has to be the same as the first dimension of the
1234 input data.
1235 idx : array | None
1236 Indicices of source time courses for which to compute transform.
1237 If None, all time courses are used.
1238 tmin_idx : int | None
1239 Index of first time point to include. If None, the index of the
1240 first time point is used.
1241 tmax_idx : int | None
1242 Index of the first time point not to include. If None, time points
1243 up to (and including) the last time point are included.
1244
1245 Returns
1246 -------
1247 data_t : ndarray
1248 The transformed data.
1249
1250 Notes
1251 -----
1252 Applying transforms can be significantly faster if the
1253 SourceEstimate object was created using "(kernel, sens_data)", for
1254 the "data" parameter as the transform is applied in sensor space.
1255 Inverse methods, e.g., "apply_inverse_epochs", or "apply_lcmv_epochs"
1256 do this automatically (if possible).
1257 """
1258 if idx is None:
1259 # use all time courses by default
1260 idx = slice(None, None)
1261
1262 if self._kernel is None and self._sens_data is None:
1263 if self._kernel_removed:
1264 warn(
1265 "Performance can be improved by not accessing the data "
1266 "attribute before calling this method."
1267 )
1268
1269 # transform source space data directly
1270 data_t = func(self.data[idx, ..., tmin_idx:tmax_idx])
1271
1272 if isinstance(data_t, tuple):
1273 # use only first return value
1274 data_t = data_t[0]
1275 else:
1276 # apply transform in sensor space
1277 sens_data_t = func(self._sens_data[:, tmin_idx:tmax_idx])
1278

Callers 3

transformMethod · 0.95
test_transform_dataFunction · 0.80
test_transformFunction · 0.80

Calls 2

warnFunction · 0.85
funcFunction · 0.50

Tested by 2

test_transform_dataFunction · 0.64
test_transformFunction · 0.64