def _compare_inverses_approx(inv_1, inv_2, evoked, rtol, atol, check_depth=True):
 if check_depth:
  if (inv_1['depth_prior'] is not None):
   assert_array_almost_equal(inv_1['depth_prior']['data'], inv_2['depth_prior']['data'], 5)
  else:
   assert_true((inv_2['depth_prior'] is None))
 if (inv_1['orient_prior'] is not None):
  assert_array_almost_equal(inv_1['orient_prior']['data'], inv_2['orient_prior']['data'])
 else:
  assert_true((inv_2['orient_prior'] is None))
 assert_array_almost_equal(inv_1['source_cov']['data'], inv_2['source_cov']['data'])
 assert_array_almost_equal(np.abs(inv_1['eigen_fields']['data']), np.abs(inv_2['eigen_fields']['data']), 0)
 assert_array_almost_equal(np.abs(inv_1['eigen_leads']['data']), np.abs(inv_2['eigen_leads']['data']), 0)
 stc_1 = apply_inverse(evoked, inv_1, lambda2, 'dSPM')
 stc_2 = apply_inverse(evoked, inv_2, lambda2, 'dSPM')
 assert_true((stc_1.subject == stc_2.subject))
 assert_equal(stc_1.times, stc_2.times)
 assert_allclose(stc_1.data, stc_2.data, rtol=rtol, atol=atol)
 assert_true((inv_1['units'] == inv_2['units']))

def _compare_inverses_approx ( inv_1 , inv_2 , evoked , rtol , atol , check_depth = True ) : if check_depth : if ( inv_1 [ 'depth_prior' ] is not None ) : assert_array_almost_equal ( inv_1 [ 'depth_prior' ] [ 'data' ] , inv_2 [ 'depth_prior' ] [ 'data' ] , 5 ) else : assert_true ( ( inv_2 [ 'depth_prior' ] is None ) ) if ( inv_1 [ 'orient_prior' ] is not None ) : assert_array_almost_equal ( inv_1 [ 'orient_prior' ] [ 'data' ] , inv_2 [ 'orient_prior' ] [ 'data' ] ) else : assert_true ( ( inv_2 [ 'orient_prior' ] is None ) ) assert_array_almost_equal ( inv_1 [ 'source_cov' ] [ 'data' ] , inv_2 [ 'source_cov' ] [ 'data' ] ) assert_array_almost_equal ( np . abs ( inv_1 [ 'eigen_fields' ] [ 'data' ] ) , np . abs ( inv_2 [ 'eigen_fields' ] [ 'data' ] ) , 0 ) assert_array_almost_equal ( np . abs ( inv_1 [ 'eigen_leads' ] [ 'data' ] ) , np . abs ( inv_2 [ 'eigen_leads' ] [ 'data' ] ) , 0 ) stc_1 = apply_inverse ( evoked , inv_1 , lambda2 , 'dSPM' ) stc_2 = apply_inverse ( evoked , inv_2 , lambda2 , 'dSPM' ) assert_true ( ( stc_1 . subject == stc_2 . subject ) ) assert_equal ( stc_1 . times , stc_2 . times ) assert_allclose ( stc_1 . data , stc_2 . data , rtol = rtol , atol = atol ) assert_true ( ( inv_1 [ 'units' ] == inv_2 [ 'units' ] ) )
compare inverses .