Skip to content

Commit ce6e9e9

Browse files
committed
TEST: Load CaretSpecFile as a GeometryCollection
1 parent 44ef9ea commit ce6e9e9

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

nibabel/coordimage.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ class GeometryCollection:
103103
structures : dict
104104
Mapping from structure names to ``Pointset``
105105
"""
106+
def __init__(self, structures):
107+
self.structures = structures
106108

107109
@classmethod
108110
def from_spec(klass, pathlike):

nibabel/tests/test_coordimage.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,26 @@ def from_spec(klass, pathlike):
2727
"lh": FreeSurferHemisphere.from_filename(surfs / "lh.white"),
2828
"rh": FreeSurferHemisphere.from_filename(surfs / "rh.white"),
2929
}
30-
subject = super().__init__(structures)
30+
subject = klass(structures)
3131
subject._subject_dir = subject_dir
3232
return subject
3333

3434

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

0 commit comments

Comments
 (0)