def test_channels_grid():
    grid_chan = chan(lambda x: x.label.startswith('grid'))
    assert grid_chan.n_chan == 16

    grid_chan.export(exported_chan_path)

    imported = Channels(exported_chan_path)
    assert imported.n_chan == grid_chan.n_chan
Beispiel #2
0
def plot_electrodes(elec, freesurfer, labels=None, values=None):
    if labels is None:
        labels = [x['name'] for x in elec.electrodes.tsv]
    xyz = array(elec.get_xyz(labels))

    # convert from RAS to tkRAS
    xyz -= freesurfer.surface_ras_shift

    chan = Channels(labels, xyz)
    if median(chan.return_xyz()[:, 0]) > 0:
        surf = freesurfer.read_brain().rh
    else:
        surf = freesurfer.read_brain().lh
    v = Viz3()
    v.add_chan(chan, values=values)
    v.add_surf(surf, alpha=0.5)

    return v
def test_plot3d_surf_chan_color_one_alpha():

    surf = Surf(surf_path)
    channels = Channels(chan_path)

    v = Viz3()
    v.add_chan(channels, color=(1, 0, 0), alpha=0.5)
    v.add_surf(surf, alpha=.5)

    v.save(VIZ_PATH / 'viz3_07_surf_chan_color_one_alpha.png')
    v.close()
def test_plot3d_surf_chan():

    surf = Surf(surf_path)
    channels = Channels(chan_path)

    v = Viz3()
    v.add_chan(channels)
    v.add_surf(surf, alpha=.8)

    v.save(VIZ_PATH / 'viz3_05_surf_chan.png')
    v.close()
def test_plot3d_surf_chan_color_everyother():

    from numpy import tile

    surf = Surf(surf_path)
    channels = Channels(chan_path)

    color_everyother = tile([[1, 0, 0], [0, 0, 1]], (14, 1))

    v = Viz3()
    v.add_chan(channels, color=color_everyother)
    v.add_surf(surf, alpha=.5)

    v.save(VIZ_PATH / 'viz3_08_surf_chan_color_everyother.png')
    v.close()
def test_plot3d_surf_chan_values():

    from numpy import arange

    surf = Surf(surf_path)
    channels = Channels(chan_path)

    v = Viz3()
    v.add_chan(channels, values=arange(channels.n_chan), colorbar=True)
    v.add_surf(surf, alpha=.5)

    v.save(VIZ_PATH / 'viz3_09_surf_chan_values.png')
    v.close()

    # reuse the limits_c
    v.add_chan(channels, values=arange(channels.n_chan))
from nibabel import load as nload
from wonambi.attr import Channels, Freesurfer
from wonambi.attr.chan import (
    find_channel_groups,
    create_sphere_around_elec,
)

from .paths import (
    chan_path,
    fs_path,
    template_mri_path,
    exported_chan_path,
)

chan = Channels(chan_path)


def test_channels():
    assert chan.n_chan == 28

    xyz = chan.return_xyz()
    assert xyz.shape == (28, 3)

    labels = chan.return_label()
    assert len(labels) == 28


def test_channels_grid():
    grid_chan = chan(lambda x: x.label.startswith('grid'))
    assert grid_chan.n_chan == 16
def test_source_linear():
    surf = Surf(surf_path)
    channels = Channels(chan_path)

    Linear(surf, channels)