def _generate_noise(info, cov, iir_filter, random_state, n_samples, zi=None):
 from scipy.signal import lfilter
 noise_cov = pick_channels_cov(cov, include=info['ch_names'], exclude=[])
 if (set(info['ch_names']) != set(noise_cov.ch_names)):
  raise ValueError(('Evoked and covariance channel names are not identical. Cannot generate the noise matrix. Channels missing in covariance %s.' % np.setdiff1d(info['ch_names'], noise_cov.ch_names)))
 rng = check_random_state(random_state)
 c = (np.diag(noise_cov.data) if noise_cov['diag'] else noise_cov.data)
 mu_channels = np.zeros(len(c))
 with warnings.catch_warnings(record=True):
  noise = rng.multivariate_normal(mu_channels, c, n_samples).T
 if (iir_filter is not None):
  if (zi is None):
   zi = np.zeros((len(c), (len(iir_filter) - 1)))
  (noise, zf) = lfilter([1], iir_filter, noise, axis=(-1), zi=zi)
 else:
  zf = None
 return (noise, zf)

def _generate_noise ( info , cov , iir_filter , random_state , n_samples , zi = None ) : from scipy . signal import lfilter noise_cov = pick_channels_cov ( cov , include = info [ 'ch_names' ] , exclude = [ ] ) if ( set ( info [ 'ch_names' ] ) != set ( noise_cov . ch_names ) ) : raise ValueError ( ( 'Evoked and covariance channel names are not identical. Cannot generate the noise matrix. Channels missing in covariance %s.' % np . setdiff1d ( info [ 'ch_names' ] , noise_cov . ch_names ) ) ) rng = check_random_state ( random_state ) c = ( np . diag ( noise_cov . data ) if noise_cov [ 'diag' ] else noise_cov . data ) mu_channels = np . zeros ( len ( c ) ) with warnings . catch_warnings ( record = True ) : noise = rng . multivariate_normal ( mu_channels , c , n_samples ) . T if ( iir_filter is not None ) : if ( zi is None ) : zi = np . zeros ( ( len ( c ) , ( len ( iir_filter ) - 1 ) ) ) ( noise , zf ) = lfilter ( [ 1 ] , iir_filter , noise , axis = ( - 1 ) , zi = zi ) else : zf = None return ( noise , zf )
create spatially colored and temporally iir-filtered noise .