2121'''
2222from __future__ import division , print_function , absolute_import
2323import re
24- import collections
25-
24+ try :
25+ from collections .abc import MutableSequence , MutableMapping , Iterable
26+ except ImportError :
27+ # PY2 compatibility
28+ from collections import MutableSequence , MutableMapping , Iterable
29+ from collections import OrderedDict
2630from .. import xmlutils as xml
2731from ..filebasedimages import FileBasedHeader
2832from ..dataobj_images import DataobjImage
@@ -104,7 +108,7 @@ def _underscore(string):
104108 return re .sub (r'([a-z0-9])([A-Z])' , r'\1_\2' , string ).lower ()
105109
106110
107- class Cifti2MetaData (xml .XmlSerializable , collections . MutableMapping ):
111+ class Cifti2MetaData (xml .XmlSerializable , MutableMapping ):
108112 """ A list of name-value pairs
109113
110114 * Description - Provides a simple method for user-supplied metadata that
@@ -124,7 +128,7 @@ class Cifti2MetaData(xml.XmlSerializable, collections.MutableMapping):
124128 data : list of (name, value) tuples
125129 """
126130 def __init__ (self , metadata = None ):
127- self .data = collections . OrderedDict ()
131+ self .data = OrderedDict ()
128132 if metadata is not None :
129133 self .update (metadata )
130134
@@ -173,7 +177,7 @@ def _to_xml_element(self):
173177 return metadata
174178
175179
176- class Cifti2LabelTable (xml .XmlSerializable , collections . MutableMapping ):
180+ class Cifti2LabelTable (xml .XmlSerializable , MutableMapping ):
177181 """ CIFTI2 label table: a sequence of ``Cifti2Label``s
178182
179183 * Description - Used by NamedMap when IndicesMapToDataType is
@@ -191,7 +195,7 @@ class Cifti2LabelTable(xml.XmlSerializable, collections.MutableMapping):
191195 """
192196
193197 def __init__ (self ):
194- self ._labels = collections . OrderedDict ()
198+ self ._labels = OrderedDict ()
195199
196200 def __len__ (self ):
197201 return len (self ._labels )
@@ -427,7 +431,7 @@ def _to_xml_element(self):
427431 return surf
428432
429433
430- class Cifti2VoxelIndicesIJK (xml .XmlSerializable , collections . MutableSequence ):
434+ class Cifti2VoxelIndicesIJK (xml .XmlSerializable , MutableSequence ):
431435 """CIFTI2 VoxelIndicesIJK: Set of voxel indices contained in a structure
432436
433437 * Description - Identifies the voxels that model a brain structure, or
@@ -509,7 +513,7 @@ def _to_xml_element(self):
509513 return vox_ind
510514
511515
512- class Cifti2Vertices (xml .XmlSerializable , collections . MutableSequence ):
516+ class Cifti2Vertices (xml .XmlSerializable , MutableSequence ):
513517 """CIFTI2 vertices - association of brain structure and a list of vertices
514518
515519 * Description - Contains a BrainStructure type and a list of vertex indices
@@ -733,7 +737,7 @@ def _to_xml_element(self):
733737 return volume
734738
735739
736- class Cifti2VertexIndices (xml .XmlSerializable , collections . MutableSequence ):
740+ class Cifti2VertexIndices (xml .XmlSerializable , MutableSequence ):
737741 """CIFTI2 vertex indices: vertex indices for an associated brain model
738742
739743 The vertex indices (which are independent for each surface, and
@@ -889,7 +893,7 @@ def _to_xml_element(self):
889893 return brain_model
890894
891895
892- class Cifti2MatrixIndicesMap (xml .XmlSerializable , collections . MutableSequence ):
896+ class Cifti2MatrixIndicesMap (xml .XmlSerializable , MutableSequence ):
893897 """Class for Matrix Indices Map
894898
895899 * Description - Provides a mapping between matrix indices and their
@@ -1076,7 +1080,7 @@ def _to_xml_element(self):
10761080 return mat_ind_map
10771081
10781082
1079- class Cifti2Matrix (xml .XmlSerializable , collections . MutableSequence ):
1083+ class Cifti2Matrix (xml .XmlSerializable , MutableSequence ):
10801084 """ CIFTI2 Matrix object
10811085
10821086 This is a list-like container where the elements are instances of
@@ -1122,7 +1126,7 @@ def _get_indices_from_mim(self, mim):
11221126 applies_to_matrix_dimension = mim .applies_to_matrix_dimension
11231127 if not isinstance (
11241128 applies_to_matrix_dimension ,
1125- collections . Iterable
1129+ Iterable
11261130 ):
11271131 applies_to_matrix_dimension = (int (applies_to_matrix_dimension ),)
11281132 return applies_to_matrix_dimension
0 commit comments