Exemplo n.º 1
0
def test_map_cifti2gifti_fails_when_not_matched_surface(cifti, gifti):

    import nibabel.gifti as ngif
    badNV = ngif.GiftiNVPairs(name="BAD", value="BAD")
    gifti.darrays[0].meta = ngif.GiftiMetaData(badNV)

    with pytest.raises(ValueError):
        niviz.surface.map_cifti_to_gifti(gifti, cifti)
Exemplo n.º 2
0
def test_write_newmetadata():
    img = gi.GiftiImage()
    attr = gi.GiftiNVPairs(name='mykey', value='val1')
    newmeta = gi.GiftiMetaData(attr)
    img.meta = newmeta
    myme = img.meta.metadata
    assert_true('mykey' in myme)
    newmeta = gi.GiftiMetaData.from_dict({'mykey1': 'val2'})
    img.meta = newmeta
    myme = img.meta.metadata
    assert_true('mykey1' in myme)
    assert_false('mykey' in myme)
Exemplo n.º 3
0
def bad_gifti():

    import nibabel.gifti as ngif

    g = ngif.GiftiImage()
    coords = np.random.uniform(size=(20, 3))
    trigs = np.random.randint(low=0, high=100, size=(5, 3))

    struct = ngif.GiftiNVPairs(name="AnatomicalStructurePrimary",
                               value="CortexLeft")
    meta = ngif.GiftiMetaData(struct)
    darray_coords = ngif.GiftiDataArray(data=coords,
                                        intent='NIFTI_INTENT_POINTSET',
                                        meta=meta)
    darray_trigs = ngif.GiftiDataArray(data=trigs, intent=1009)
    g.add_gifti_data_array(darray_coords)
    g.add_gifti_data_array(darray_trigs)
    return g