Skip to content

Commit ffd150a

Browse files
committed
ENH: Add stubs from BIAP 9
1 parent 590b226 commit ffd150a

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

nibabel/coordimage.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
class CoordinateImage:
2+
"""
3+
Attributes
4+
----------
5+
header : a file-specific header
6+
coordaxis : ``CoordinateAxis``
7+
dataobj : array-like
8+
"""
9+
10+
11+
class CoordinateAxis:
12+
"""
13+
Attributes
14+
----------
15+
parcels : list of ``Parcel`` objects
16+
"""
17+
18+
def load_structures(self, mapping):
19+
"""
20+
Associate parcels to ``Pointset`` structures
21+
"""
22+
raise NotImplementedError
23+
24+
def __getitem__(self, slicer):
25+
"""
26+
Return a sub-sampled CoordinateAxis containing structures
27+
matching the indices provided.
28+
"""
29+
raise NotImplementedError
30+
31+
def get_indices(self, parcel, indices=None):
32+
"""
33+
Return the indices in the full axis that correspond to the
34+
requested parcel. If indices are provided, further subsample
35+
the requested parcel.
36+
"""
37+
raise NotImplementedError
38+
39+
40+
class Parcel:
41+
"""
42+
Attributes
43+
----------
44+
name : str
45+
structure : ``Pointset``
46+
indices : object that selects a subset of coordinates in structure
47+
"""
48+
49+
50+
class GeometryCollection:
51+
"""
52+
Attributes
53+
----------
54+
structures : dict
55+
Mapping from structure names to ``Pointset``
56+
"""
57+
58+
@classmethod
59+
def from_spec(klass, pathlike):
60+
"""Load a collection of geometries from a specification."""
61+
raise NotImplementedError

nibabel/pointset.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,37 @@ def get_coords(self, *, as_homogeneous: bool = False):
144144
return coords
145145

146146

147+
class TriangularMesh(Pointset):
148+
@property
149+
def n_triangles(self):
150+
"""Number of faces
151+
152+
Subclasses should override with more efficient implementations.
153+
"""
154+
return len(self.get_triangles())
155+
156+
def get_triangles(self, name=None):
157+
"""Mx3 array of indices into coordinate table"""
158+
raise NotImplementedError
159+
160+
def get_mesh(self, name=None):
161+
return self.get_coords(name=name), self.get_triangles(name=name)
162+
163+
def get_names(self):
164+
"""List of surface names that can be passed to
165+
``get_{coords,triangles,mesh}``
166+
"""
167+
raise NotImplementedError
168+
169+
## This method is called for by the BIAP, but it now seems simpler to wait to
170+
## provide it until there are any proposed implementations
171+
# def decimate(self, *, n_coords=None, ratio=None):
172+
# """ Return a TriangularMesh with a smaller number of vertices that
173+
# preserves the geometry of the original """
174+
# # To be overridden when a format provides optimization opportunities
175+
# raise NotImplementedError
176+
177+
147178
class Grid(Pointset):
148179
r"""A regularly-spaced collection of coordinates
149180

0 commit comments

Comments
 (0)