Apply linear transform. 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.partial`). The first parameter of
(self, func, idx=None, tmin=None, tmax=None, copy=False)
| 1297 | return data_t |
| 1298 | |
| 1299 | def transform(self, func, idx=None, tmin=None, tmax=None, copy=False): |
| 1300 | """Apply linear transform. |
| 1301 | |
| 1302 | The transform is applied to each source time course independently. |
| 1303 | |
| 1304 | Parameters |
| 1305 | ---------- |
| 1306 | func : callable |
| 1307 | The transform to be applied, including parameters (see, e.g., |
| 1308 | :func:`functools.partial`). The first parameter of the function is |
| 1309 | the input data. The first two dimensions of the transformed data |
| 1310 | should be (i) vertices and (ii) time. See Notes for details. |
| 1311 | idx : array | None |
| 1312 | Indices of source time courses for which to compute transform. |
| 1313 | If None, all time courses are used. |
| 1314 | tmin : float | int | None |
| 1315 | First time point to include (ms). If None, self.tmin is used. |
| 1316 | tmax : float | int | None |
| 1317 | Last time point to include (ms). If None, self.tmax is used. |
| 1318 | copy : bool |
| 1319 | If True, return a new instance of SourceEstimate instead of |
| 1320 | modifying the input inplace. |
| 1321 | |
| 1322 | Returns |
| 1323 | ------- |
| 1324 | stcs : SourceEstimate | VectorSourceEstimate | list |
| 1325 | The transformed stc or, in the case of transforms which yield |
| 1326 | N-dimensional output (where N > 2), a list of stcs. For a list, |
| 1327 | copy must be True. |
| 1328 | |
| 1329 | Notes |
| 1330 | ----- |
| 1331 | Transforms which yield 3D |
| 1332 | output (e.g. time-frequency transforms) are valid, so long as the |
| 1333 | first two dimensions are vertices and time. In this case, the |
| 1334 | copy parameter must be True and a list of |
| 1335 | SourceEstimates, rather than a single instance of SourceEstimate, |
| 1336 | will be returned, one for each index of the 3rd dimension of the |
| 1337 | transformed data. In the case of transforms yielding 2D output |
| 1338 | (e.g. filtering), the user has the option of modifying the input |
| 1339 | inplace (copy = False) or returning a new instance of |
| 1340 | SourceEstimate (copy = True) with the transformed data. |
| 1341 | |
| 1342 | Applying transforms can be significantly faster if the |
| 1343 | SourceEstimate object was created using "(kernel, sens_data)", for |
| 1344 | the "data" parameter as the transform is applied in sensor space. |
| 1345 | Inverse methods, e.g., "apply_inverse_epochs", or "apply_lcmv_epochs" |
| 1346 | do this automatically (if possible). |
| 1347 | """ |
| 1348 | # min and max data indices to include |
| 1349 | times = 1000.0 * self.times |
| 1350 | t_idx = np.where(_time_mask(times, tmin, tmax, sfreq=self.sfreq))[0] |
| 1351 | if tmin is None: |
| 1352 | tmin_idx = None |
| 1353 | else: |
| 1354 | tmin_idx = t_idx[0] |
| 1355 | |
| 1356 | if tmax is None: |
nothing calls this directly
no test coverage detected