Ejemplo n.º 1
0
import nibabel as nib
from nibabel import cifti2 as ci
from nibabel.cifti2.parse_cifti2 import _Cifti2AsNiftiHeader

from nibabel.tmpdirs import InTemporaryDirectory
from nibabel.tests.nibabel_data import get_nibabel_data, needs_nibabel_data
from nibabel.tests.test_nifti2 import TestNifti2SingleHeader

from numpy.testing import assert_array_almost_equal
from nose.tools import (assert_true, assert_equal, assert_raises)

NIBABEL_TEST_DATA = pjoin(dirname(nib.__file__), 'tests', 'data')
NIFTI2_DATA = pjoin(NIBABEL_TEST_DATA, 'example_nifti2.nii.gz')

CIFTI2_DATA = pjoin(get_nibabel_data(), 'nitest-cifti2')

DATA_FILE1 = pjoin(CIFTI2_DATA, '')
DATA_FILE2 = pjoin(CIFTI2_DATA,
                   'Conte69.MyelinAndCorrThickness.32k_fs_LR.dscalar.nii')
DATA_FILE3 = pjoin(CIFTI2_DATA,
                   'Conte69.MyelinAndCorrThickness.32k_fs_LR.dtseries.nii')
DATA_FILE4 = pjoin(CIFTI2_DATA,
                   'Conte69.MyelinAndCorrThickness.32k_fs_LR.ptseries.nii')
DATA_FILE5 = pjoin(CIFTI2_DATA,
                   'Conte69.parcellations_VGD11b.32k_fs_LR.dlabel.nii')
DATA_FILE6 = pjoin(CIFTI2_DATA, 'ones.dscalar.nii')
datafiles = [DATA_FILE2, DATA_FILE3, DATA_FILE4, DATA_FILE5, DATA_FILE6]


def test_read_nifti2():
Ejemplo n.º 2
0
from .. import io, axis
from nibabel.tests.nibabel_data import get_nibabel_data, needs_nibabel_data
import os
import numpy as np
import tempfile

dirname = os.path.join(get_nibabel_data(), 'nitest-cifti2')

hcp_labels = [
    'CortexLeft', 'CortexRight', 'AccumbensLeft', 'AccumbensRight',
    'AmygdalaLeft', 'AmygdalaRight', 'brain_stem', 'CaudateLeft',
    'CaudateRight', 'CerebellumLeft', 'CerebellumRight',
    'Diencephalon_ventral_left', 'Diencephalon_ventral_right',
    'HippocampusLeft', 'HippocampusRight', 'PallidumLeft', 'PallidumRight',
    'PutamenLeft', 'PutamenRight', 'ThalamusLeft', 'ThalamusRight'
]

hcp_n_elements = [
    29696, 29716, 135, 140, 315, 332, 3472, 728, 755, 8709, 9144, 706, 712,
    764, 795, 297, 260, 1060, 1010, 1288, 1248
]

hcp_affine = np.array([[-2., 0., 0., 90.], [0., 2., 0., -126.],
                       [0., 0., 2., -72.], [0., 0., 0., 1.]])


def check_hcp_grayordinates(brain_model):
    """Checks that a BrainModel matches the expected 32k HCP grayordinates
    """
    assert isinstance(brain_model, axis.BrainModel)
    structures = list(brain_model.iter_structures())
Ejemplo n.º 3
0
from nibabel.cifti2 import cifti2_axes, cifti2
from nibabel.tests.nibabel_data import get_nibabel_data, needs_nibabel_data
import nibabel as nib
import os
import numpy as np
import tempfile

test_directory = os.path.join(get_nibabel_data(), 'nitest-cifti2')

hcp_labels = ['CortexLeft', 'CortexRight', 'AccumbensLeft', 'AccumbensRight', 'AmygdalaLeft', 'AmygdalaRight',
              'brain_stem', 'CaudateLeft', 'CaudateRight', 'CerebellumLeft', 'CerebellumRight',
              'Diencephalon_ventral_left', 'Diencephalon_ventral_right', 'HippocampusLeft', 'HippocampusRight',
              'PallidumLeft', 'PallidumRight', 'PutamenLeft', 'PutamenRight', 'ThalamusLeft', 'ThalamusRight']

hcp_n_elements = [29696, 29716, 135, 140, 315, 332, 3472, 728, 755, 8709, 9144, 706,
                  712, 764, 795, 297, 260, 1060, 1010, 1288, 1248]

hcp_affine = np.array([[  -2.,    0.,    0.,   90.],
                       [   0.,    2.,    0., -126.],
                       [   0.,    0.,    2.,  -72.],
                       [   0.,    0.,    0.,    1.]])


def check_hcp_grayordinates(brain_model):
    """Checks that a BrainModelAxis matches the expected 32k HCP grayordinates
    """
    assert isinstance(brain_model, cifti2_axes.BrainModelAxis)
    structures = list(brain_model.iter_structures())
    assert len(structures) == len(hcp_labels)
    idx_start = 0
    for idx, (name, _, bm), label, nel in zip(range(len(structures)), structures, hcp_labels, hcp_n_elements):
Ejemplo n.º 4
0
from nibabel.cifti2 import cifti2_axes, cifti2
from nibabel.tests.nibabel_data import get_nibabel_data, needs_nibabel_data
import nibabel as nib
import os
import numpy as np
import tempfile

test_directory = os.path.join(get_nibabel_data(), 'nitest-cifti2')

hcp_labels = [
    'CortexLeft', 'CortexRight', 'AccumbensLeft', 'AccumbensRight',
    'AmygdalaLeft', 'AmygdalaRight', 'brain_stem', 'CaudateLeft',
    'CaudateRight', 'CerebellumLeft', 'CerebellumRight',
    'Diencephalon_ventral_left', 'Diencephalon_ventral_right',
    'HippocampusLeft', 'HippocampusRight', 'PallidumLeft', 'PallidumRight',
    'PutamenLeft', 'PutamenRight', 'ThalamusLeft', 'ThalamusRight'
]

hcp_n_elements = [
    29696, 29716, 135, 140, 315, 332, 3472, 728, 755, 8709, 9144, 706, 712,
    764, 795, 297, 260, 1060, 1010, 1288, 1248
]

hcp_affine = np.array([[-2., 0., 0., 90.], [0., 2., 0., -126.],
                       [0., 0., 2., -72.], [0., 0., 0., 1.]])


def check_hcp_grayordinates(brain_model):
    """Checks that a BrainModelAxis matches the expected 32k HCP grayordinates
    """
    assert isinstance(brain_model, cifti2_axes.BrainModelAxis)