diff --git a/fsl/data/gifti.py b/fsl/data/gifti.py index ea14b4e2cc1ae25f317c48e0c70abbed96db75a5..41d38e3ba2aded4dd489722cdeebf8313dd80a75 100644 --- a/fsl/data/gifti.py +++ b/fsl/data/gifti.py @@ -23,6 +23,8 @@ are available: import os.path as op +import nibabel as nib + import fsl.utils.path as fslpath from . import mesh @@ -50,7 +52,6 @@ class GiftiSurface(mesh.TriangleMesh): :arg infile: A GIFTI surface file """ - import nibabel as nib surfimg = nib.load(infile) vertices, indices = extractGiftiSurface(surfimg) @@ -65,6 +66,16 @@ class GiftiSurface(mesh.TriangleMesh): self.surfImg = surfimg + def loadVertexData(self, dataSource): + """Attempts to load scalar data associated with each vertex of this + ``GiftiSurface`` from the given ``dataSource``. + """ + + # TODO make this more robust + norms = nib.load(dataSource) + return norms.darrays[0].data + + ALLOWED_EXTENSIONS = ['.surf.gii', '.gii'] """List of file extensions that a file containing Gifti surface data is expected to have. diff --git a/fsl/data/mesh.py b/fsl/data/mesh.py index 978fbbdd9297458b098f09762e9413b41314005a..d9afd3cf252bcb02c4432d57759626f978938136 100644 --- a/fsl/data/mesh.py +++ b/fsl/data/mesh.py @@ -55,6 +55,14 @@ class TriangleMesh(object): the vertex indices for :math:`M` triangles ============== ==================================================== + + And the following methods: + + .. autosummary:: + :nosignatures: + + getBounds + loadVertexData """ @@ -117,6 +125,15 @@ class TriangleMesh(object): return (self.__loBounds, self.__hiBounds) + def loadVertexData(self, dataSource): + """Attempts to load scalar data associated with each vertex of this + ``TriangleMesh`` from the given ``dataSource``. + + This method may be overridden by sub-classes. + """ + raise NotImplementedError('Not implemented yet') + + ALLOWED_EXTENSIONS = ['.vtk'] """A list of file extensions which could contain :class:`TriangleMesh` data. """