예제 #1
0
def run(da, di, mf):
    print(('Processing : %4d nAm (dip %d) : SSS=%s' % (da, di, mf)).ljust(42),
          end='')
    epochs, evoked, cov, sphere = get_data(base_path, di, da, mf, bads=bads)
    # Hack to only use gradiometers
    epochs.pick_types(meg='grad')
    evoked.pick_types(meg='grad')
    # Do LCMV
    data_cov = mne.compute_covariance(epochs, tmin=0.)
    stc = mne.beamformer.lcmv(evoked,
                              fwd,
                              cov,
                              data_cov,
                              reg=0.01,
                              pick_ori='max-power',
                              reduce_rank=True,
                              max_ori_out='signed')
    stc = abs(stc)
    idx_max = np.argmax(np.mean(stc.data, axis=1))
    vertno_max = stc.vertices[idx_max]
    pos = src[0]['rr'][vertno_max]
    ori = None
    amp = None
    gof = None

    actual_params = dict(actual_pos=actual_pos[di - 1],
                         actual_ori=actual_ori[di - 1],
                         actual_amp=da / 2.)
    error = compute_error(di, pos, ori, amp, **actual_params)
    error['gof'] = gof
    error['maxfilter'] = mf
    return pd.DataFrame(error, index=[0])
def run(da, di, mf):
    print(('Processing : %4d nAm (dip %d) : SSS=%s' % (da, di, mf)).ljust(43),
          end='')
    epochs, evoked, cov, sphere = get_data(base_path, di, da, mf, bads=bads)

    # # Hack to only use gradiometers
    # epochs.pick_types(meg='grad')
    # evoked.pick_types(meg='grad')

    dip = mne.beamformer.rap_music(evoked,
                                   fwd,
                                   cov,
                                   n_dipoles=1,
                                   return_residual=False)[0]
    t_idx = np.argmax(dip.gof)
    pos = dip.pos[t_idx]
    ori = dip.ori[t_idx]
    gof = dip.gof[t_idx]
    amp = dip.amplitude[t_idx]
    actual_params = dict(actual_pos=actual_pos[di - 1],
                         actual_ori=actual_ori[di - 1],
                         actual_amp=da / 2.)
    error = compute_error(di, pos, ori, 1e9 * amp, **actual_params)
    error['gof'] = gof
    error['maxfilter'] = mf
    return pd.DataFrame(error, index=[0])
def run(da, di, mf):
    print(('Processing : %4d nAm (dip %d) : SSS=%s' % (da, di, mf)).ljust(43),
          end='')
    epochs, evoked, cov, sphere = get_data(base_path, di, da, mf, bads=bads)

    # Do LCMV
    reduce_rank = True  # as we use a sphere model
    pick_ori = 'max-power'
    rank = None

    # # Expose MNE bug...
    # reduce_rank = False
    # pick_ori = None
    # rank = None

    data_cov = mne.compute_covariance(epochs, tmin=0.05)
    filters = mne.beamformer.make_lcmv(epochs.info,
                                       fwd,
                                       data_cov,
                                       reg=0.05,
                                       noise_cov=cov,
                                       pick_ori=pick_ori,
                                       rank=rank,
                                       weight_norm='nai',
                                       reduce_rank=reduce_rank)

    stc = mne.beamformer.apply_lcmv(evoked, filters, max_ori_out='signed')
    stc = abs(stc)
    idx_max = np.argmax(np.mean(stc.data, axis=1))
    vertno_max = stc.vertices[idx_max]
    pos = src[0]['rr'][vertno_max]
    ori = None
    amp = None
    gof = None

    actual_params = dict(actual_pos=actual_pos[di - 1],
                         actual_ori=actual_ori[di - 1],
                         actual_amp=da / 2.)
    error = compute_error(di, pos, ori, amp, **actual_params)
    error['gof'] = gof
    error['maxfilter'] = mf
    return pd.DataFrame(error, index=[0])
def run(da, di, mf):
    print(('Processing : %4d nAm (dip %d) : SSS=%s' % (da, di, mf)).ljust(42),
          end="")
    epochs, evoked, cov, sphere = get_data(base_path, di, da, mf, bads=bads)
    # Hack to only use gradiometers
    epochs.pick_types(meg='grad')
    evoked.pick_types(meg='grad')
    # Do the dipole fit
    t_peak = 66e-3  # only fit the largest peak
    evoked.crop(t_peak, t_peak)
    dip = mne.fit_dipole(evoked, cov, sphere)[0]
    pos = dip.pos[0]
    ori = dip.ori[0]
    gof = dip.gof[0]
    actual_params = dict(actual_pos=actual_pos[di - 1],
                         actual_ori=actual_ori[di - 1],
                         actual_amp=da / 2.)
    error = compute_error(di, pos, ori, 1e9 * dip.amplitude, **actual_params)
    error['gof'] = gof
    error['maxfilter'] = mf
    return pd.DataFrame(error)