@@ -419,14 +419,15 @@ class GiftiImage(xml.XmlSerializable, FileBasedImage):
419419 valid_exts = ('.gii' ,)
420420 files_types = (('image' , '.gii' ),)
421421
422+ # The parser will in due course be a GiftiImageParser, but we can't set
423+ # that now, because it would result in a circular import. We set it after
424+ # the class has been defined, at the end of the class definition.
425+ parser = None
426+
422427 def __init__ (self , header = None , extra = None , file_map = None , meta = None ,
423428 labeltable = None , darrays = None , version = "1.0" ):
424429 super (GiftiImage , self ).__init__ (header = header , extra = extra ,
425430 file_map = file_map )
426- # placed here temporarily for git diff purposes
427- from .parse_gifti_fast import GiftiImageParser
428- GiftiImage .parser = GiftiImageParser
429-
430431 if darrays is None :
431432 darrays = []
432433 if meta is None :
@@ -606,3 +607,8 @@ def from_filename(klass, filename, buffer_size=35000000):
606607 file_map = klass .filespec_to_file_map (filename )
607608 img = klass .from_file_map (file_map , buffer_size = buffer_size )
608609 return img
610+
611+
612+ # Now GiftiImage is defined, we can import the parser module and set the parser
613+ from .parse_gifti_fast import GiftiImageParser
614+ GiftiImage .parser = GiftiImageParser
0 commit comments