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+ from collections import MutableSequence , MutableMapping , Iterable
28+ from collections import OrderedDict
2629from .. import xmlutils as xml
2730from ..filebasedimages import FileBasedHeader
2831from ..dataobj_images import DataobjImage
@@ -104,7 +107,7 @@ def _underscore(string):
104107 return re .sub (r'([a-z0-9])([A-Z])' , r'\1_\2' , string ).lower ()
105108
106109
107- class Cifti2MetaData (xml .XmlSerializable , collections . MutableMapping ):
110+ class Cifti2MetaData (xml .XmlSerializable , MutableMapping ):
108111 """ A list of name-value pairs
109112
110113 * Description - Provides a simple method for user-supplied metadata that
@@ -124,7 +127,7 @@ class Cifti2MetaData(xml.XmlSerializable, collections.MutableMapping):
124127 data : list of (name, value) tuples
125128 """
126129 def __init__ (self , metadata = None ):
127- self .data = collections . OrderedDict ()
130+ self .data = OrderedDict ()
128131 if metadata is not None :
129132 self .update (metadata )
130133
@@ -173,7 +176,7 @@ def _to_xml_element(self):
173176 return metadata
174177
175178
176- class Cifti2LabelTable (xml .XmlSerializable , collections . MutableMapping ):
179+ class Cifti2LabelTable (xml .XmlSerializable , MutableMapping ):
177180 """ CIFTI2 label table: a sequence of ``Cifti2Label``s
178181
179182 * Description - Used by NamedMap when IndicesMapToDataType is
@@ -191,7 +194,7 @@ class Cifti2LabelTable(xml.XmlSerializable, collections.MutableMapping):
191194 """
192195
193196 def __init__ (self ):
194- self ._labels = collections . OrderedDict ()
197+ self ._labels = OrderedDict ()
195198
196199 def __len__ (self ):
197200 return len (self ._labels )
@@ -427,7 +430,7 @@ def _to_xml_element(self):
427430 return surf
428431
429432
430- class Cifti2VoxelIndicesIJK (xml .XmlSerializable , collections . MutableSequence ):
433+ class Cifti2VoxelIndicesIJK (xml .XmlSerializable , MutableSequence ):
431434 """CIFTI2 VoxelIndicesIJK: Set of voxel indices contained in a structure
432435
433436 * Description - Identifies the voxels that model a brain structure, or
@@ -509,7 +512,7 @@ def _to_xml_element(self):
509512 return vox_ind
510513
511514
512- class Cifti2Vertices (xml .XmlSerializable , collections . MutableSequence ):
515+ class Cifti2Vertices (xml .XmlSerializable , MutableSequence ):
513516 """CIFTI2 vertices - association of brain structure and a list of vertices
514517
515518 * Description - Contains a BrainStructure type and a list of vertex indices
@@ -733,7 +736,7 @@ def _to_xml_element(self):
733736 return volume
734737
735738
736- class Cifti2VertexIndices (xml .XmlSerializable , collections . MutableSequence ):
739+ class Cifti2VertexIndices (xml .XmlSerializable , MutableSequence ):
737740 """CIFTI2 vertex indices: vertex indices for an associated brain model
738741
739742 The vertex indices (which are independent for each surface, and
@@ -889,7 +892,7 @@ def _to_xml_element(self):
889892 return brain_model
890893
891894
892- class Cifti2MatrixIndicesMap (xml .XmlSerializable , collections . MutableSequence ):
895+ class Cifti2MatrixIndicesMap (xml .XmlSerializable , MutableSequence ):
893896 """Class for Matrix Indices Map
894897
895898 * Description - Provides a mapping between matrix indices and their
@@ -1076,7 +1079,7 @@ def _to_xml_element(self):
10761079 return mat_ind_map
10771080
10781081
1079- class Cifti2Matrix (xml .XmlSerializable , collections . MutableSequence ):
1082+ class Cifti2Matrix (xml .XmlSerializable , MutableSequence ):
10801083 """ CIFTI2 Matrix object
10811084
10821085 This is a list-like container where the elements are instances of
@@ -1122,7 +1125,7 @@ def _get_indices_from_mim(self, mim):
11221125 applies_to_matrix_dimension = mim .applies_to_matrix_dimension
11231126 if not isinstance (
11241127 applies_to_matrix_dimension ,
1125- collections . Iterable
1128+ Iterable
11261129 ):
11271130 applies_to_matrix_dimension = (int (applies_to_matrix_dimension ),)
11281131 return applies_to_matrix_dimension
0 commit comments