21
21
'''
22
22
from __future__ import division , print_function , absolute_import
23
23
import re
24
- import collections
25
-
24
+ try :
25
+ from collections .abc import MutableSequence , MutableMapping , Iterable
26
+ except ImportError :
27
+ from collections import MutableSequence , MutableMapping , Iterable
28
+ from collections import OrderedDict
26
29
from .. import xmlutils as xml
27
30
from ..filebasedimages import FileBasedHeader
28
31
from ..dataobj_images import DataobjImage
@@ -104,7 +107,7 @@ def _underscore(string):
104
107
return re .sub (r'([a-z0-9])([A-Z])' , r'\1_\2' , string ).lower ()
105
108
106
109
107
- class Cifti2MetaData (xml .XmlSerializable , collections . MutableMapping ):
110
+ class Cifti2MetaData (xml .XmlSerializable , MutableMapping ):
108
111
""" A list of name-value pairs
109
112
110
113
* Description - Provides a simple method for user-supplied metadata that
@@ -124,7 +127,7 @@ class Cifti2MetaData(xml.XmlSerializable, collections.MutableMapping):
124
127
data : list of (name, value) tuples
125
128
"""
126
129
def __init__ (self , metadata = None ):
127
- self .data = collections . OrderedDict ()
130
+ self .data = OrderedDict ()
128
131
if metadata is not None :
129
132
self .update (metadata )
130
133
@@ -173,7 +176,7 @@ def _to_xml_element(self):
173
176
return metadata
174
177
175
178
176
- class Cifti2LabelTable (xml .XmlSerializable , collections . MutableMapping ):
179
+ class Cifti2LabelTable (xml .XmlSerializable , MutableMapping ):
177
180
""" CIFTI2 label table: a sequence of ``Cifti2Label``s
178
181
179
182
* Description - Used by NamedMap when IndicesMapToDataType is
@@ -191,7 +194,7 @@ class Cifti2LabelTable(xml.XmlSerializable, collections.MutableMapping):
191
194
"""
192
195
193
196
def __init__ (self ):
194
- self ._labels = collections . OrderedDict ()
197
+ self ._labels = OrderedDict ()
195
198
196
199
def __len__ (self ):
197
200
return len (self ._labels )
@@ -427,7 +430,7 @@ def _to_xml_element(self):
427
430
return surf
428
431
429
432
430
- class Cifti2VoxelIndicesIJK (xml .XmlSerializable , collections . MutableSequence ):
433
+ class Cifti2VoxelIndicesIJK (xml .XmlSerializable , MutableSequence ):
431
434
"""CIFTI2 VoxelIndicesIJK: Set of voxel indices contained in a structure
432
435
433
436
* Description - Identifies the voxels that model a brain structure, or
@@ -509,7 +512,7 @@ def _to_xml_element(self):
509
512
return vox_ind
510
513
511
514
512
- class Cifti2Vertices (xml .XmlSerializable , collections . MutableSequence ):
515
+ class Cifti2Vertices (xml .XmlSerializable , MutableSequence ):
513
516
"""CIFTI2 vertices - association of brain structure and a list of vertices
514
517
515
518
* Description - Contains a BrainStructure type and a list of vertex indices
@@ -733,7 +736,7 @@ def _to_xml_element(self):
733
736
return volume
734
737
735
738
736
- class Cifti2VertexIndices (xml .XmlSerializable , collections . MutableSequence ):
739
+ class Cifti2VertexIndices (xml .XmlSerializable , MutableSequence ):
737
740
"""CIFTI2 vertex indices: vertex indices for an associated brain model
738
741
739
742
The vertex indices (which are independent for each surface, and
@@ -889,7 +892,7 @@ def _to_xml_element(self):
889
892
return brain_model
890
893
891
894
892
- class Cifti2MatrixIndicesMap (xml .XmlSerializable , collections . MutableSequence ):
895
+ class Cifti2MatrixIndicesMap (xml .XmlSerializable , MutableSequence ):
893
896
"""Class for Matrix Indices Map
894
897
895
898
* Description - Provides a mapping between matrix indices and their
@@ -1076,7 +1079,7 @@ def _to_xml_element(self):
1076
1079
return mat_ind_map
1077
1080
1078
1081
1079
- class Cifti2Matrix (xml .XmlSerializable , collections . MutableSequence ):
1082
+ class Cifti2Matrix (xml .XmlSerializable , MutableSequence ):
1080
1083
""" CIFTI2 Matrix object
1081
1084
1082
1085
This is a list-like container where the elements are instances of
@@ -1122,7 +1125,7 @@ def _get_indices_from_mim(self, mim):
1122
1125
applies_to_matrix_dimension = mim .applies_to_matrix_dimension
1123
1126
if not isinstance (
1124
1127
applies_to_matrix_dimension ,
1125
- collections . Iterable
1128
+ Iterable
1126
1129
):
1127
1130
applies_to_matrix_dimension = (int (applies_to_matrix_dimension ),)
1128
1131
return applies_to_matrix_dimension
0 commit comments