def display_TR_data(self, tr=-1): """display motion and any extras for the given TR (last if not set)""" if tr < 0: tr = len(self.motion[0])-1 if self.verb > 3: print('-- displaying data for TR %d' % tr) mprefix = "++ recv motion: " if self.version in [1,3,4]: eprefix = "++ recv %d extras: "%self.nextra elif self.version==2: eprefix = "++ recv %dx8 extras: "%(self.nextra//8) print(UTIL.float_list_string([self.motion[i][tr] for i in range(6)], nchar=9, ndec=5, nspaces=2, mesg=mprefix, left=1)) # version 1, all on one line if self.version == 1 and self.nextra > 0: self.print_floats_one_line(self.extras, self.nextra, tr, eprefix) # version 2, each voxel on one line elif self.version in [2,3] and self.nextra > 0: self.print_floats_multi_line(self.extras, self.nextra, tr, eprefix) # version 4, ADDITIONALLY show extras2 elif self.version == 4 and (self.nextra > 0 or self.nextra2 > 0): ep2 = "++ recv %d extra2: "%(self.nextra2) self.print_floats_multi_line(self.extras, self.nextra, tr, eprefix) self.print_floats_multi_line(self.extra2, self.nextra2, tr, ep2)
def axis_posn(self, ax): """return error code, posn array""" # first attempt is to look for simple array return try: posn = ax.get_position() except: if self.verb > 1: print('** failed ax.get_position()') return 1, None # have list, ready for some return if type(posn) == type([]): if len(posn) < 4: if self.verb > 1: print('** get_position returns len %d list' % len(posn)) return 1, None if self.verb > 2: print('-- get_position returns list %s' % \ UTIL.float_list_string(posn)) return 0, posn # no list, assume Bbox and expect get_points() to return 2x2 numpy array try: plist = posn.get_points() except: if self.verb > 1: print('** failed posn.get_points()') return 1, None if type(plist) != type(N.array([])): if self.verb > 1: print('** posn.get_points() does not return N.array?') return 1, None try: pnlist = [plist[0][0], plist[0][1], plist[1][0], plist[1][1]] except: if self.verb > 1: print('** bad plist shape %s' % plist.shape) return 1, None if self.verb > 2: print('-- get_position returns Bbox list: %s' % \ UTIL.float_list_string(pnlist)) return 0, pnlist