@@ -344,63 +344,48 @@ def get_metadata(self):
344344
345345
346346class GiftiImage (object ):
347-
348- numDA = int
349- version = str
350- filename = str
351-
352347 def __init__ (self , meta = None , labeltable = None , darrays = None ,
353348 version = "1.0" ):
354349 if darrays is None :
355350 darrays = []
356- self .darrays = darrays
357351 if meta is None :
358- self .meta = GiftiMetaData ()
359- else :
360- self .meta = meta
352+ meta = GiftiMetaData ()
361353 if labeltable is None :
362- self .labeltable = GiftiLabelTable ()
363- else :
364- self .labeltable = labeltable
365- self .numDA = len (self .darrays )
354+ labeltable = GiftiLabelTable ()
355+
356+ self ._labeltable = labeltable
357+ self ._meta = meta
358+
359+ self .darrays = darrays
366360 self .version = version
367361
368- # @classmethod
369- # def from_array(cls):
370- # pass
371- #def GiftiImage_fromarray(data, intent = GiftiIntentCode.NIFTI_INTENT_NONE, encoding=GiftiEncoding.GIFTI_ENCODING_B64GZ, endian = GiftiEndian.GIFTI_ENDIAN_LITTLE):
372- # """ Returns a GiftiImage from a Numpy array with a given intent code and
373- # encoding """
374-
375- # @classmethod
376- # def from_vertices_and_triangles(cls):
377- # pass
378- # def from_vertices_and_triangles(cls, vertices, triangles, coordsys = None, \
379- # encoding = GiftiEncoding.GIFTI_ENCODING_B64GZ,\
380- # endian = GiftiEndian.GIFTI_ENDIAN_LITTLE):
381- # """ Returns a GiftiImage from two numpy arrays representing the vertices
382- # and the triangles. Additionally defining the coordinate system and encoding """
383-
384- def get_labeltable (self ):
385- return self .labeltable
386-
387- def set_labeltable (self , labeltable ):
362+ @property
363+ def numDA (self ):
364+ return len (self .darrays )
365+
366+ @property
367+ def labeltable (self ):
368+ return self ._labeltable
369+
370+ @labeltable .setter
371+ def labeltable (self , labeltable ):
388372 """ Set the labeltable for this GiftiImage
389373
390374 Parameters
391375 ----------
392376 labeltable : GiftiLabelTable
393377
394378 """
395- if isinstance (labeltable , GiftiLabelTable ):
396- self .labeltable = labeltable
397- else :
398- print ("Not a valid GiftiLabelTable instance" )
379+ if not isinstance (labeltable , GiftiLabelTable ):
380+ raise ValueError ("Not a valid GiftiLabelTable instance" )
381+ self ._labeltable = labeltable
399382
400- def get_metadata (self ):
401- return self .meta
383+ @property
384+ def meta (self ):
385+ return self ._meta
402386
403- def set_metadata (self , meta ):
387+ @meta .setter
388+ def meta (self , meta ):
404389 """ Set the metadata for this GiftiImage
405390
406391 Parameters
@@ -411,13 +396,10 @@ def set_metadata(self, meta):
411396 -------
412397 None
413398 """
414- if isinstance (meta , GiftiMetaData ):
415- self .meta = meta
416- print ("New Metadata set. Be aware of changing "
417- "coordinate transformation!" )
418- else :
419- print ("Not a valid GiftiMetaData instance" )
420-
399+ if not isinstance (meta , GiftiMetaData ):
400+ raise ValueError ("Not a valid GiftiMetaData instance" )
401+ self ._meta = meta
402+
421403 def add_gifti_data_array (self , dataarr ):
422404 """ Adds a data array to the GiftiImage
423405
@@ -427,22 +409,19 @@ def add_gifti_data_array(self, dataarr):
427409 """
428410 if isinstance (dataarr , GiftiDataArray ):
429411 self .darrays .append (dataarr )
430- self .numDA += 1
431412 else :
432413 print ("dataarr paramater must be of tzpe GiftiDataArray" )
433414
434415 def remove_gifti_data_array (self , ith ):
435416 """ Removes the ith data array element from the GiftiImage """
436417 self .darrays .pop (ith )
437- self .numDA -= 1
438418
439419 def remove_gifti_data_array_by_intent (self , intent ):
440420 """ Removes all the data arrays with the given intent type """
441421 intent2remove = intent_codes .code [intent ]
442422 for dele in self .darrays :
443423 if dele .intent == intent2remove :
444424 self .darrays .remove (dele )
445- self .numDA -= 1
446425
447426 def get_arrays_from_intent (self , intent ):
448427 """ Returns a a list of GiftiDataArray elements matching
0 commit comments