def _filtfilt(x, iir_params, picks, n_jobs, copy):
 from scipy.signal import filtfilt
 padlen = min(iir_params['padlen'], len(x))
 n_jobs = check_n_jobs(n_jobs)
 (x, orig_shape, picks) = _prep_for_filtering(x, copy, picks)
 if ('sos' in iir_params):
  sosfiltfilt = get_sosfiltfilt()
  fun = partial(sosfiltfilt, sos=iir_params['sos'], padlen=padlen)
  _check_coefficients(iir_params['sos'])
 else:
  fun = partial(filtfilt, b=iir_params['b'], a=iir_params['a'], padlen=padlen)
  _check_coefficients((iir_params['b'], iir_params['a']))
 if (n_jobs == 1):
  for p in picks:
   x[p] = fun(x=x[p])
 else:
  (parallel, p_fun, _) = parallel_func(fun, n_jobs)
  data_new = parallel((p_fun(x=x[p]) for p in picks))
  for (pp, p) in enumerate(picks):
   x[p] = data_new[pp]
 x.shape = orig_shape
 return x

def _filtfilt ( x , iir_params , picks , n_jobs , copy ) : from scipy . signal import filtfilt padlen = min ( iir_params [ 'padlen' ] , len ( x ) ) n_jobs = check_n_jobs ( n_jobs ) ( x , orig_shape , picks ) = _prep_for_filtering ( x , copy , picks ) if ( 'sos' in iir_params ) : sosfiltfilt = get_sosfiltfilt ( ) fun = partial ( sosfiltfilt , sos = iir_params [ 'sos' ] , padlen = padlen ) _check_coefficients ( iir_params [ 'sos' ] ) else : fun = partial ( filtfilt , b = iir_params [ 'b' ] , a = iir_params [ 'a' ] , padlen = padlen ) _check_coefficients ( ( iir_params [ 'b' ] , iir_params [ 'a' ] ) ) if ( n_jobs == 1 ) : for p in picks : x [ p ] = fun ( x = x [ p ] ) else : ( parallel , p_fun , _ ) = parallel_func ( fun , n_jobs ) data_new = parallel ( ( p_fun ( x = x [ p ] ) for p in picks ) ) for ( pp , p ) in enumerate ( picks ) : x [ p ] = data_new [ pp ] x . shape = orig_shape return x
helper to more easily call filtfilt .