def test_magnetic_dipole():
 trans = Transform('mri', 'head')
 info = read_info(fname_raw)
 picks = pick_types(info, meg=True, eeg=False, exclude=[])
 info = pick_info(info, picks[:12])
 coils = _create_meg_coils(info['chs'], 'normal', trans)
 r0 = np.array([0.0, 13.0, (-6.0)])
 for (ch, coil) in zip(info['chs'], coils):
  rr = ((ch['loc'][:3] + r0) / 2.0)
  far_fwd = _magnetic_dipole_field_vec(r0[np.newaxis, :], [coil])
  near_fwd = _magnetic_dipole_field_vec(rr[np.newaxis, :], [coil])
  ratio = (8.0 if (ch['ch_name'][(-1)] == '1') else 16.0)
  assert_allclose(np.median((near_fwd / far_fwd)), ratio, atol=0.1)

def test_magnetic_dipole ( ) : trans = Transform ( 'mri' , 'head' ) info = read_info ( fname_raw ) picks = pick_types ( info , meg = True , eeg = False , exclude = [ ] ) info = pick_info ( info , picks [ : 12 ] ) coils = _create_meg_coils ( info [ 'chs' ] , 'normal' , trans ) r0 = np . array ( [ 0.0 , 13.0 , ( - 6.0 ) ] ) for ( ch , coil ) in zip ( info [ 'chs' ] , coils ) : rr = ( ( ch [ 'loc' ] [ : 3 ] + r0 ) / 2.0 ) far_fwd = _magnetic_dipole_field_vec ( r0 [ np . newaxis , : ] , [ coil ] ) near_fwd = _magnetic_dipole_field_vec ( rr [ np . newaxis , : ] , [ coil ] ) ratio = ( 8.0 if ( ch [ 'ch_name' ] [ ( - 1 ) ] == '1' ) else 16.0 ) assert_allclose ( np . median ( ( near_fwd / far_fwd ) ) , ratio , atol = 0.1 )
test basic magnetic dipole forward calculation .