Skip to content

Commit badbbca

Browse files
TEST: define volume dimensions, affine & number of vertices
1 parent f651b07 commit badbbca

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

nibabel/cifti2/tests/test_new_cifti2.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ def create_geometry_map(applies_to_matrix_dimension):
3434
vertices = ci.Cifti2VertexIndices(np.array(brain_models[1][1]))
3535
left_cortex = ci.Cifti2BrainModel(index_offset=4, index_count=5, model_type='CIFTI_MODEL_TYPE_SURFACE',
3636
brain_structure=brain_models[1][0], vertex_indices=vertices)
37+
left_cortex.surface_number_of_vertices = number_of_vertices
38+
volume = ci.Cifti2Volume(dimensions, ci.Cifti2TransformationMatrixVoxelIndicesIJKtoXYZ(-3, affine))
3739
return ci.Cifti2MatrixIndicesMap(applies_to_matrix_dimension, 'CIFTI_INDEX_TYPE_BRAIN_MODELS',
38-
maps=[left_thalamus, left_cortex])
40+
maps=[left_thalamus, left_cortex, volume])
3941

4042

4143
def check_geometry_map(mapping):
@@ -48,6 +50,7 @@ def check_geometry_map(mapping):
4850
assert_equal(left_thalamus.model_type, 'CIFTI_MODEL_TYPE_VOXELS')
4951
assert_equal(left_thalamus.brain_structure, brain_models[0][0])
5052
assert_equal(left_thalamus.vertex_indices, None)
53+
assert_equal(left_thalamus.surface_number_of_vertices, None)
5154
assert_equal(left_thalamus.voxel_indices_ijk._indices, brain_models[0][1])
5255

5356
assert_equal(left_cortex.index_offset, 4)
@@ -56,7 +59,10 @@ def check_geometry_map(mapping):
5659
assert_equal(left_cortex.brain_structure, brain_models[1][0])
5760
assert_equal(left_cortex.voxel_indices_ijk, None)
5861
assert_equal(left_cortex.vertex_indices._indices, brain_models[1][1])
62+
assert_equal(left_cortex.surface_number_of_vertices, number_of_vertices)
5963

64+
assert_equal(mapping.volume.volume_dimensions, dimensions)
65+
assert_true((mapping.volume.transformation_matrix_voxel_indices_ijk_to_xyz.matrix == affine).all())
6066

6167
parcels = [('volume_parcel', ([[60, 60, 60],
6268
[61, 59, 60],
@@ -80,6 +86,10 @@ def create_parcel_map(applies_to_matrix_dimension):
8086
else:
8187
volume = ci.Cifti2VoxelIndicesIJK(element)
8288
mapping.append(ci.Cifti2Parcel(name, volume, surfaces))
89+
90+
mapping.extend([ci.Cifti2Surface('CIFTI_STRUCTURE_CORTEX_%s' % orientation,
91+
number_of_vertices) for orientation in ['LEFT', 'RIGHT']])
92+
mapping.volume = ci.Cifti2Volume(dimensions, ci.Cifti2TransformationMatrixVoxelIndicesIJKtoXYZ(-3, affine))
8393
return mapping
8494

8595

@@ -98,14 +108,24 @@ def check_parcel_map(mapping):
98108
else:
99109
assert_equal(parcel.voxel_indices_ijk._indices, element)
100110

111+
for surface, orientation in zip(mapping.surfaces, ('LEFT', 'RIGHT')):
112+
assert_equal(surface.brain_structure, 'CIFTI_STRUCTURE_CORTEX_%s' % orientation)
113+
assert_equal(surface.surface_number_of_vertices, number_of_vertices)
114+
115+
assert_equal(mapping.volume.volume_dimensions, dimensions)
116+
assert_true((mapping.volume.transformation_matrix_voxel_indices_ijk_to_xyz.matrix == affine).all())
117+
118+
101119
scalars = [('first_name', {'meta_key': 'some_metadata'}),
102120
('another name', {})]
103121

122+
104123
def create_scalar_map(applies_to_matrix_dimension):
105124
maps = [ci.Cifti2NamedMap(name, ci.Cifti2MetaData(meta)) for name, meta in scalars]
106125
return ci.Cifti2MatrixIndicesMap(applies_to_matrix_dimension, 'CIFTI_INDEX_TYPE_SCALARS',
107126
maps=maps)
108127

128+
109129
def check_scalar_map(mapping):
110130
assert_equal(mapping.indices_map_to_data_type, 'CIFTI_INDEX_TYPE_SCALARS')
111131
assert_equal(len(list(mapping.named_maps)), 2)
@@ -134,6 +154,7 @@ def create_label_map(applies_to_matrix_dimension):
134154
return ci.Cifti2MatrixIndicesMap(applies_to_matrix_dimension, 'CIFTI_INDEX_TYPE_LABELS',
135155
maps=maps)
136156

157+
137158
def check_label_map(mapping):
138159
assert_equal(mapping.indices_map_to_data_type, 'CIFTI_INDEX_TYPE_LABELS')
139160
assert_equal(len(list(mapping.named_maps)), 2)

0 commit comments

Comments
 (0)