def load_surface(self, surf_fi_name): ''' Load a new FreeSurfer ASC surface and make it active. Args: surf_fi_name: The path to the surface file ''' try: res = FsF.read_surface(surf_fi_name) self.x_range = res["x_range"] self.y_range = res["y_range"] self.z_range = res["z_range"] self.nodes = res["nodes"] self.triangles = res["triangles"] #self.normals = res['normals'] self.no_surface = False except IOError as e: #TODO: Rethink error handling print "Could not open surface file: %s"%str(e) tkMessageBox.showerror("Could not open surface file", "%s Try reloading the dataset."%(str(e))) self.no_surface = True raise except (ValueError, struct_error) as e: if e.message != "COVI only supports FreeSurfer ASCII surfaces at this time.": print "Error reading surface file: %s"%str(e) tkMessageBox.showerror("Error reading surface file", "%s"%(str(e))) raise
def load_annot(self, annot_fi_name): ''' Load a FreeSurfer annot file with included color table. Args: annot_fi_name: The path to the annot file ''' try: data, color_table = FsF.read_annot(annot_fi_name) self.annot = [color_table[i] for i in data] test_val = self.annot[0] # Make sure we have an annot file that doesn't need a cmap if type(test_val) != list or len(test_val) != 5: tkMessageBox.showwarning("Could not read annot file", "The annot file in this dataset can't be read by COVI, "+ "but SUMA should display the name of the cortical area.") self.annot = False except (IOError, ValueError, struct_error) as e: tkMessageBox.showerror("Could not read annot file", "%s If you want annotation data, "+ "try reloading the dataset."%str(e)) raise