def __init__(self,filename): try: f = EdfFile.EdfFile(filename) except: raise UserInputException("""Unable to read in the file \ %s because the Object EdfFile that I am using to read in edf data \ raised an error when trying to read in the file. This probably means \ that there is something wrong \ with the file that you are trying to open""" % filename) data = f.GetData(0) if not alltrue(alltrue(less_equal(data,2147483647))): print """Warning, some of the data stored in the \ file %s has an intensity larger then 2^31-1 which is too big for this \ program to hold. Any of these large values were clipped to have a value of 2^31-1.""" % filename # clip any data that is too big mask1 = data <= 2147483647 mask2 = data > 2147483647 masked_data = data*mask1 + (pow(2,31)-1) * mask2 masked_data = masked_data.astype(Numeric.Int32) self.size = max(masked_data.shape[0],masked_data.shape[1]) # pad values if necessary - create an array to put everything in self.data = Numeric.zeros((self.size,self.size),Numeric.Int32) # copy the data into the padded array self.data[0:masked_data.shape[0],0:masked_data.shape[1]] = masked_data self.data = Numeric.transpose(self.data)
def __init__(self, filename): try: f = EdfFile.EdfFile(filename) except: raise UserInputException("""Unable to read in the file \ %s because the Object EdfFile that I am using to read in edf data \ raised an error when trying to read in the file. This probably means \ that there is something wrong \ with the file that you are trying to open""" % filename) data = f.GetData(0) if not alltrue(alltrue(less_equal(data, 2147483647))): print """Warning, some of the data stored in the \ file %s has an intensity larger then 2^31-1 which is too big for this \ program to hold. Any of these large values were clipped to have a value of 2^31-1.""" % filename # clip any data that is too big mask1 = data <= 2147483647 mask2 = data > 2147483647 masked_data = data * mask1 + (pow(2, 31) - 1) * mask2 masked_data = masked_data.astype(Numeric.Int32) self.size = max(masked_data.shape[0], masked_data.shape[1]) # pad values if necessary - create an array to put everything in self.data = Numeric.zeros((self.size, self.size), Numeric.Int32) # copy the data into the padded array self.data[0:masked_data.shape[0], 0:masked_data.shape[1]] = masked_data self.data = Numeric.transpose(self.data)
def testAngleBetween(self): vector1 = array((1, 0, 0)) vector2 = array((0, 1, 0)) angle = angleBetween(vector1, vector2) assert angle == 90, "Fails sanity check" assert alltrue(vector1 == array((1, 0, 0))) and \ alltrue(vector2 == array((0, 1, 0))), \ "Arguments were modified (recurrence of bug ####)"
def all(a, axis=None): '''Numpy-compatible version of all()''' if axis is None: return alltrue(ravel(a)) else: return alltrue(a, axis)