예제 #1
0
파일: test_texture.py 프로젝트: Anthys/slam
 def test_copy_modif_texture(self):
     test_textureA = texture.TextureND()
     darrayA = np.zeros((4, 1))
     test_textureA.update_darray(darrayA)
     test_textureB = test_textureA.copy()
     test_textureB.darray[0][0] = 1
     assert not (test_textureA.darray == test_textureB.darray).all()
예제 #2
0
파일: io.py 프로젝트: tianqisong0117/slam
def load_texture(gifti_file):
    """
    load gifti_file and create a TextureND object (multidimensional)
    :param gifti_file: str, path to the gifti file on the disk
    :return: the corresponding TextureND object
    """
    # read the gifti usinng nibabel
    nb_texture = nb.gifti.read(gifti_file)
    # concatenate all the data arrays in a single numpy array
    cat_darrays = [
        nb_texture.darrays[i].data for i in range(len(nb_texture.darrays))
    ]
    return texture.TextureND(darray=np.array(cat_darrays),
                             metadata=nb_texture.meta.metadata)
예제 #3
0
파일: test_texture.py 프로젝트: Anthys/slam
    def test_z_score_texture(self):
        darrayA = np.array([
            [5, 3, 2],
            [7, 2, 1],
            [4, 7, 4],
        ])
        outA = np.array([
            [3, 3, 3],
            [2, 2, 1],
            [4, 4, 4],
        ])

        test_textureA = texture.TextureND()
        test_textureA.update_darray(darrayA)
        test_textureA.z_score_filtering(1)
        assert test_textureA.darray.all() == outA.all()
def main(arguments):
    if len(arguments)==3:
        meshN = arguments[1]
        texN = arguments[2]

        mesh = sio.load_mesh(meshN)

        maxCurv = maxAbsCurvature(mesh)

        # visb_sc = splt.visbrain_plot(mesh=mesh, tex=maxCurv,
        #                              caption='max absolute curvature',
        #                              cblabel='max absolute curvature')
        # visb_sc.preview()

        sio.write_texture(stex.TextureND(darray=maxCurv), texN)
    else:
        print('Usage:')
        print('python computeMaxCurvature.py mesh curvTex')
예제 #5
0
def test_update_darray():
    test_texture = texture.TextureND()
    darray = np.zeros((4, 1))
    test_texture.update_darray(darray)
    assert test_texture.shape == darray.shape
예제 #6
0
파일: test_texture.py 프로젝트: Anthys/slam
 def test_copy_texture(self):
     test_textureA = texture.TextureND()
     darray = np.zeros((4, 1))
     test_textureA.update_darray(darray)
     test_textureB = test_textureA.copy()
     assert (test_textureA.darray == test_textureB.darray).all()
예제 #7
0
import numpy as np
from slam import texture
from slam import io as sio

if __name__ == '__main__':

    tex = sio.load_texture('data/example_texture.gii')
    print(tex)
    print(tex.metadata)
    print(tex.shape)
    print(tex.dtype)
    print(tex.min())
    print(tex.max())

    darray = np.zeros((2, 3))
    tex2 = texture.TextureND(darray=darray)
    print(tex2.metadata)
    print(tex2)
    print(tex2.shape)
    print(tex2.dtype)
    print(tex2.min())
    print(tex2.max())
    sio.write_texture(tex2, 'test.gii')
        tex_files = list()
        for subject_mesh_file in subjects_mesh_files:
            filename_split = subject_mesh_file.split('/')
            subj = filename_split[6]
            filename = filename_split[-1]
            side = filename[0]
            print(subj + ' ' + side)
            curv = os.path.join(
                output_folder, subj + '.' + side + 'h.white_curv_' +
                curv_type + '_NN_FSsphere.ico7.gii')
            if not os.path.exists(curv):
                mesh_files.append(subject_mesh_file)
                tex_files.append(curv)

        print('nb of meshes to be processed: ' + str(len(mesh_files)))
        #mesh_files_i = mesh_files[:2]
        #tex_files_i = tex_files[:2]
        for mesh_file, tex_file in zip(mesh_files, tex_files):
            print('remeshing for ' + tex_file)
            file_tex_in = tex_file[:-21] + '.gii'
            print(file_tex_in)

            source_tex = sio.load_texture(file_tex_in)
            source_spherical_mesh = sio.load_mesh(mesh_file)
            interpolated_tex = \
                srem.spherical_interpolation_nearest_neigbhor(source_spherical_mesh, target_spherical_mesh, source_tex.darray)
            #splt.pyglet_plot(target_spherical_mesh, interpolated_tex, -1, 1)

            output_texture = stex.TextureND(darray=interpolated_tex)
            sio.write_texture(output_texture, tex_file)