Estimate cross-spectral density with a given function. This function will apply the given CSD function in parallel across epochs. Parameters ---------- X : array-like, shape (n_epochs, n_channels, n_times) The time series data consisting of n_epochs separate observations
(
X,
times,
frequencies,
csd_function,
params,
n_fft,
ch_names=None,
projs=None,
n_jobs=None,
*,
verbose=None,
)
| 1300 | |
| 1301 | @verbose |
| 1302 | def _execute_csd_function( |
| 1303 | X, |
| 1304 | times, |
| 1305 | frequencies, |
| 1306 | csd_function, |
| 1307 | params, |
| 1308 | n_fft, |
| 1309 | ch_names=None, |
| 1310 | projs=None, |
| 1311 | n_jobs=None, |
| 1312 | *, |
| 1313 | verbose=None, |
| 1314 | ): |
| 1315 | """Estimate cross-spectral density with a given function. |
| 1316 | |
| 1317 | This function will apply the given CSD function in parallel across epochs. |
| 1318 | |
| 1319 | Parameters |
| 1320 | ---------- |
| 1321 | X : array-like, shape (n_epochs, n_channels, n_times) |
| 1322 | The time series data consisting of n_epochs separate observations |
| 1323 | of signals with n_channels time-series of length n_times. |
| 1324 | times : float |
| 1325 | Timestamps for each sample. |
| 1326 | frequencies : list of float |
| 1327 | The frequencies of interest for which the CSD is going to be computed. |
| 1328 | csd_function : function |
| 1329 | Function that performs the actual CSD computation |
| 1330 | params : list |
| 1331 | List of parameters to pass the CSD function. |
| 1332 | n_fft : int |
| 1333 | Number of FFT points. This is stored in the CSD object. |
| 1334 | ch_names : list of str | None |
| 1335 | A name for each time series. If ``None`` (the default), the series will |
| 1336 | be named 'SERIES###'. |
| 1337 | projs : list of Projection | None |
| 1338 | List of projectors to store in the CSD object. Defaults to ``None``, |
| 1339 | which means the projectors defined in the Epochs object will be copied. |
| 1340 | %(n_jobs)s |
| 1341 | %(verbose)s |
| 1342 | |
| 1343 | Returns |
| 1344 | ------- |
| 1345 | csd : instance of CrossSpectralDensity |
| 1346 | The computed cross-spectral density. |
| 1347 | """ |
| 1348 | n_epochs, n_channels, _ = X.shape |
| 1349 | |
| 1350 | logger.info("Computing cross-spectral density from epochs...") |
| 1351 | |
| 1352 | n_freqs = len(frequencies) |
| 1353 | csds_mean = np.zeros( |
| 1354 | (n_channels * (n_channels + 1) // 2, n_freqs), dtype=np.complex128 |
| 1355 | ) |
| 1356 | |
| 1357 | # Prepare the function that does the actual CSD computation for parallel |
| 1358 | # execution. |
| 1359 | parallel, my_csd, n_jobs = parallel_func(csd_function, n_jobs, verbose=verbose) |
no test coverage detected