Skip to content

Commit c7ab610

Browse files
committed
TEST: Load CaretSpecFile as a GeometryCollection
1 parent 1138a95 commit c7ab610

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

nibabel/coordimage.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ class GeometryCollection:
107107
Mapping from structure names to ``Pointset``
108108
"""
109109

110+
def __init__(self, structures):
111+
self.structures = structures
112+
110113
@classmethod
111114
def from_spec(klass, pathlike):
112115
"""Load a collection of geometries from a specification."""

nibabel/tests/test_coordimage.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,27 @@ def from_spec(klass, pathlike):
2828
'lh': FreeSurferHemisphere.from_filename(surfs / 'lh.white'),
2929
'rh': FreeSurferHemisphere.from_filename(surfs / 'rh.white'),
3030
}
31-
subject = super().__init__(structures)
31+
subject = klass(structures)
3232
subject._subject_dir = subject_dir
3333
return subject
3434

3535

36+
class CaretSpec(ci.GeometryCollection):
37+
@classmethod
38+
def from_spec(klass, pathlike):
39+
from nibabel.cifti2.caretspec import CaretSpecFile
40+
41+
csf = CaretSpecFile.from_filename(pathlike)
42+
structures = {
43+
df.structure: df.uri
44+
for df in csf.data_files
45+
if df.selected # Use selected to avoid overloading for now
46+
}
47+
wbspec = klass(structures)
48+
wbspec._specfile = csf
49+
return wbspec
50+
51+
3652
def test_Cifti2Image_as_CoordImage():
3753
ones = nb.load(CIFTI2_DATA / 'ones.dscalar.nii')
3854
axes = [ones.header.get_axis(i) for i in range(ones.ndim)]

0 commit comments

Comments
 (0)