Exemplo n.º 1
0
def map_meg_loocv_channels(inst,
                           pick_from,
                           pick_to,
                           self_dots=None,
                           cross_dots=None,
                           mode='fast'):

    from mne.io.pick import pick_info
    from mne.forward._lead_dots import _do_self_dots, _do_cross_dots
    from mne.forward._make_forward import _create_meg_coils, _read_coil_defs
    from mne.forward._field_interpolation import _setup_dots
    from mne.forward._field_interpolation import _compute_mapping_matrix
    from mne.bem import _check_origin

    info_from = pick_info(inst.info, pick_from, copy=True)
    info_to = pick_info(inst.info, pick_to, copy=True)

    # no need to apply trans because both from and to coils are in device
    # coordinates
    templates = _read_coil_defs(verbose=False)
    coils_from = _create_meg_coils(info_from['chs'], 'normal',
                                   info_from['dev_head_t'], templates)
    coils_to = _create_meg_coils(info_to['chs'], 'normal',
                                 info_to['dev_head_t'], templates)
    miss = 1e-4  # Smoothing criterion for MEG

    int_rad, noise, lut_fun, n_fact = _setup_dots(mode, coils_from, 'meg')
    my_origin = _check_origin((0., 0., 0.04), info_from)

    if self_dots is None:
        self_dots = _do_self_dots(int_rad,
                                  False,
                                  coils_from,
                                  my_origin,
                                  'meg',
                                  lut_fun,
                                  n_fact,
                                  n_jobs=1)
    if cross_dots is None:
        cross_dots = _do_cross_dots(int_rad, False, coils_from, coils_to,
                                    my_origin, 'meg', lut_fun, n_fact).T

    ch_names = [c['ch_name'] for c in info_from['chs']]
    fmd = dict(kind='meg',
               ch_names=ch_names,
               origin=my_origin,
               noise=noise,
               self_dots=self_dots,
               surface_dots=cross_dots,
               int_rad=int_rad,
               miss=miss)
    fmd['data'] = _compute_mapping_matrix(fmd, info_from)

    return fmd['data'], self_dots, cross_dots
Exemplo n.º 2
0
 def _compute_dots(info, mode='fast'):
     """Compute all-to-all dots."""
     templates = _read_coil_defs()
     coils = _create_meg_coils(info['chs'], 'normal', info['dev_head_t'],
                               templates)
     my_origin = _check_origin((0., 0., 0.04), info_from)
     int_rad, noise, lut_fun, n_fact = _setup_dots(mode, coils, 'meg')
     self_dots = _do_self_dots(int_rad, False, coils, my_origin, 'meg',
                               lut_fun, n_fact, n_jobs=1)
     cross_dots = _do_cross_dots(int_rad, False, coils, coils,
                                 my_origin, 'meg', lut_fun, n_fact).T
     return self_dots, cross_dots
Exemplo n.º 3
0
 def _compute_dots(info, mode='fast'):
     """Compute all-to-all dots.
     """
     templates = _read_coil_defs()
     coils = _create_meg_coils(info['chs'], 'normal', info['dev_head_t'],
                               templates)
     my_origin = _check_origin((0., 0., 0.04), info_from)
     int_rad, noise, lut_fun, n_fact = _setup_dots(mode, coils, 'meg')
     self_dots = _do_self_dots(int_rad, False, coils, my_origin, 'meg',
                               lut_fun, n_fact, n_jobs=1)
     cross_dots = _do_cross_dots(int_rad, False, coils, coils,
                                 my_origin, 'meg', lut_fun, n_fact).T
     return self_dots, cross_dots
Exemplo n.º 4
0
def _compute_dots(info, mode='fast'):
    """Compute all-to-all dots."""
    from mne.forward._field_interpolation import _setup_dots
    from mne.forward._lead_dots import _do_self_dots, _do_cross_dots
    from mne.forward._make_forward import _create_meg_coils, _read_coil_defs
    from mne.bem import _check_origin

    templates = _read_coil_defs()
    coils = _create_meg_coils(info['chs'], 'normal', info['dev_head_t'],
                              templates)
    my_origin = _check_origin((0., 0., 0.04), info)
    int_rad, noise, lut_fun, n_fact = _setup_dots(mode, coils, 'meg')
    self_dots = _do_self_dots(int_rad, False, coils, my_origin, 'meg',
                              lut_fun, n_fact, n_jobs=1)
    cross_dots = _do_cross_dots(int_rad, False, coils, coils,
                                my_origin, 'meg', lut_fun, n_fact).T
    return self_dots, cross_dots
Exemplo n.º 5
0
def _compute_dots(info, mode='fast'):
    """Compute all-to-all dots."""
    from mne.forward._field_interpolation import _setup_dots
    from mne.forward._lead_dots import _do_self_dots, _do_cross_dots
    from mne.forward._make_forward import _create_meg_coils, _read_coil_defs
    from mne.bem import _check_origin

    templates = _read_coil_defs()
    coils = _create_meg_coils(info['chs'], 'normal', info['dev_head_t'],
                              templates)
    my_origin = _check_origin((0., 0., 0.04), info)
    int_rad, noise, lut_fun, n_fact = _setup_dots(mode, coils, 'meg')
    self_dots = _do_self_dots(int_rad, False, coils, my_origin, 'meg',
                              lut_fun, n_fact, n_jobs=1)
    cross_dots = _do_cross_dots(int_rad, False, coils, coils,
                                my_origin, 'meg', lut_fun, n_fact).T
    return self_dots, cross_dots
Exemplo n.º 6
0
def map_meg_loocv_channels(inst, pick_from, pick_to, self_dots=None,
                           cross_dots=None, mode='fast'):

    from mne.io.pick import pick_info
    from mne.forward._lead_dots import _do_self_dots, _do_cross_dots
    from mne.forward._make_forward import _create_meg_coils, _read_coil_defs
    from mne.forward._field_interpolation import _setup_dots
    from mne.forward._field_interpolation import _compute_mapping_matrix
    from mne.bem import _check_origin

    info_from = pick_info(inst.info, pick_from, copy=True)
    info_to = pick_info(inst.info, pick_to, copy=True)

    # no need to apply trans because both from and to coils are in device
    # coordinates
    templates = _read_coil_defs(verbose=False)
    coils_from = _create_meg_coils(info_from['chs'], 'normal',
                                   info_from['dev_head_t'], templates)
    coils_to = _create_meg_coils(info_to['chs'], 'normal',
                                 info_to['dev_head_t'], templates)
    miss = 1e-4  # Smoothing criterion for MEG

    int_rad, noise, lut_fun, n_fact = _setup_dots(mode, coils_from, 'meg')
    my_origin = _check_origin((0., 0., 0.04), info_from)

    if self_dots is None:
        self_dots = _do_self_dots(int_rad, False, coils_from, my_origin, 'meg',
                                  lut_fun, n_fact, n_jobs=1)
    if cross_dots is None:
        cross_dots = _do_cross_dots(int_rad, False, coils_from, coils_to,
                                    my_origin, 'meg', lut_fun, n_fact).T

    ch_names = [c['ch_name'] for c in info_from['chs']]
    fmd = dict(kind='meg', ch_names=ch_names,
               origin=my_origin, noise=noise, self_dots=self_dots,
               surface_dots=cross_dots, int_rad=int_rad, miss=miss)
    fmd['data'] = _compute_mapping_matrix(fmd, info_from)

    return fmd['data'], self_dots, cross_dots