Python Library to Read and Write Surface Files in Freesurfer's TriangularSurface Format
Project description
Python Library to Read and Write Surface Files in Freesurfer’s TriangularSurface Format
compatible with Freesurfer’s MRISwriteTriangularSurface() https://github.com/freesurfer/freesurfer/blob/release_6_0_0/include/mrisurf.h#L1281 https://github.com/freesurfer/freesurfer/blob/release_6_0_0/utils/mrisurf.c https://raw.githubusercontent.com/freesurfer/freesurfer/release_6_0_0/utils/mrisurf.c
Freesurfer https://surfer.nmr.mgh.harvard.edu/
Edit Surface File >>> from freesurfer_surface import Surface, Vertex, Triangle >>> >>> surface = Surface.read_triangular(‘bert/surf/lh.pial’)) >>> >>> vertex_a = surface.add_vertex(Vertex(0.0, 0.0, 0.0)) >>> vertex_b = surface.add_vertex(Vertex(1.0, 1.0, 1.0)) >>> vertex_c = surface.add_vertex(Vertex(2.0, 2.0, 2.0)) >>> surface.triangles.append(Triangle((vertex_a, vertex_b, vertex_c))) >>> >>> surface.write_triangular(‘somewhere/else/lh.pial’)
List Labels in Annotation File >>> from freesurfer_surface import Annotation >>> >>> annotation = Annotation.read(‘bert/label/lh.aparc.annot’) >>> for label in annotation.labels.values(): >>> print(label.index, label.hex_color_code, label.name)
Find Border of Labelled Region >>> surface = Surface.read_triangular(‘bert/surf/lh.pial’)) >>> surface.load_annotation_file(‘bert/label/lh.aparc.annot’) >>> region, = filter(lambda l: l.name == ‘precentral’, >>> annotation.labels.values()) >>> print(surface.find_label_border_polygonal_chains(region))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for freesurfer_surface-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7fba9e11e367119f4f4ec2b86668890311f1aff63233b1cf00e31202bbbbb44 |
|
MD5 | f6a4b61aa0deb569ee876e35abeb7a05 |
|
BLAKE2b-256 | 1dd45406ce2c8beb7fa280f6a17d8c761bb94ea5fc1edc99e2f729e6d45d2537 |