Esempio n. 1
0
    def write(self, surface_obj, file_path):
        image_metadata = GiftiMetaData().from_dict(
            surface_obj.generic_metadata)
        vertices_metadata = GiftiMetaData().from_dict(
            surface_obj.vertices_metadata)
        triangles_metadata = GiftiMetaData().from_dict(
            surface_obj.triangles_metadata)

        gifti_image = GiftiImage()
        gifti_image.set_metadata(image_metadata)

        data = GiftiDataArray(surface_obj.vertices,
                              datatype='NIFTI_TYPE_FLOAT32',
                              intent='NIFTI_INTENT_POINTSET')
        data.meta = vertices_metadata
        data.coordsys = surface_obj.vertices_coord_system
        gifti_image.add_gifti_data_array(data)

        data = GiftiDataArray(surface_obj.triangles,
                              datatype='NIFTI_TYPE_INT32',
                              intent='NIFTI_INTENT_TRIANGLE')
        data.meta = triangles_metadata
        data.coordsys = None
        gifti_image.add_gifti_data_array(data)

        nibabel.save(gifti_image, file_path)
Esempio n. 2
0
    def write(self, surface_obj, file_path):
        image_metadata = GiftiMetaData().from_dict(surface_obj.generic_metadata)
        vertices_metadata = GiftiMetaData().from_dict(surface_obj.vertices_metadata)
        triangles_metadata = GiftiMetaData().from_dict(surface_obj.triangles_metadata)

        gifti_image = GiftiImage()
        gifti_image.set_metadata(image_metadata)

        data = GiftiDataArray(
            surface_obj.vertices, datatype='NIFTI_TYPE_FLOAT32', intent='NIFTI_INTENT_POINTSET')
        data.meta = vertices_metadata
        data.coordsys = surface_obj.vertices_coord_system
        gifti_image.add_gifti_data_array(data)

        data = GiftiDataArray(
            surface_obj.triangles, datatype='NIFTI_TYPE_INT32', intent='NIFTI_INTENT_TRIANGLE')
        data.meta = triangles_metadata
        data.coordsys = None
        gifti_image.add_gifti_data_array(data)

        nibabel.save(gifti_image, file_path)
Esempio n. 3
0
    def write_gifti(self, surface, surface_path):
        gifti_image = GiftiImage()

        data_array = [0 for _ in xrange(2)]
        data_array[0] = surface.vertices
        data_array[1] = surface.triangles

        image_metadata = GiftiMetaData().from_dict(surface.image_metadata)
        vertices_metadata = GiftiMetaData().from_dict(surface.vertices_metadata)
        triangles_metadata = GiftiMetaData().from_dict(surface.triangles_metadata)

        # TODO We currently write metadata of the old surface
        gifti_image.set_metadata(image_metadata)

        data = GiftiDataArray(data_array[0], datatype='NIFTI_TYPE_FLOAT32', intent='NIFTI_INTENT_POINTSET')
        data.meta = vertices_metadata
        data.coordsys = surface.vertices_coord_system
        gifti_image.add_gifti_data_array(data)
        data = GiftiDataArray(data_array[1], datatype='NIFTI_TYPE_INT32', intent='NIFTI_INTENT_TRIANGLE')
        data.meta = triangles_metadata
        data.coordsys = None
        gifti_image.add_gifti_data_array(data)

        nibabel.save(gifti_image, surface_path)