def OpenOtherFiles(self, group): # Retreaving matrix from image data self.matrix, scalar_range, self.filename = image_utils.img2memmap(group) hdr = group.header if group.affine.any(): self.affine = group.affine Publisher.sendMessage('Update affine matrix', affine=self.affine, status=True) hdr.set_data_dtype('int16') dims = hdr.get_zooms() dimsf = tuple([float(s) for s in dims]) wl = float((scalar_range[0] + scalar_range[1]) * 0.5) ww = float((scalar_range[1] - scalar_range[0])) self.Slice = sl.Slice() self.Slice.matrix = self.matrix self.Slice.matrix_filename = self.filename self.Slice.spacing = dimsf self.Slice.window_level = wl self.Slice.window_width = ww scalar_range = int(scalar_range[0]), int(scalar_range[1]) Publisher.sendMessage('Update threshold limits list', threshold_range=scalar_range) return self.matrix, self.filename
def OpenOtherFiles(self, group): # Retreaving matrix from image data self.matrix, scalar_range, self.filename = image_utils.img2memmap(group) hdr = group.header if group.affine.any(): self.affine = group.affine Publisher.sendMessage('Update affine matrix', affine=self.affine, status=True) hdr.set_data_dtype('int16') dims = hdr.get_zooms() dimsf = tuple([float(s) for s in dims]) wl = float((scalar_range[0] + scalar_range[1]) * 0.5) ww = float((scalar_range[1] - scalar_range[0])) self.Slice = sl.Slice() self.Slice.matrix = self.matrix self.Slice.matrix_filename = self.filename self.Slice.spacing = dimsf self.Slice.window_level = wl self.Slice.window_width = ww scalar_range = int(scalar_range[0]), int(scalar_range[1]) Publisher.sendMessage('Update threshold limits list', threshold_range=scalar_range) return self.matrix, self.filename
def OpenOtherFiles(self, group): # Retreaving matrix from image data self.matrix, scalar_range, self.filename = image_utils.img2memmap( group) hdr = group.header # if group.affine.any(): # self.affine = group.affine # Publisher.sendMessage('Update affine matrix', # affine=self.affine, status=True) hdr.set_data_dtype('int16') dims = hdr.get_zooms() dimsf = tuple([float(s) for s in dims]) wl = float((scalar_range[0] + scalar_range[1]) * 0.5) ww = float((scalar_range[1] - scalar_range[0])) self.Slice = sl.Slice() self.Slice.matrix = self.matrix self.Slice.matrix_filename = self.filename self.Slice.spacing = dimsf self.Slice.window_level = wl self.Slice.window_width = ww if group.affine.any(): # TODO: replace the inverse of the affine by the actual affine in the whole code # remove scaling factor for non-unitary voxel dimensions # self.affine = image_utils.world2invspace(affine=group.affine) scale, shear, angs, trans, persp = tr.decompose_matrix( group.affine) self.affine = np.linalg.inv( tr.compose_matrix(scale=None, shear=shear, angles=angs, translate=trans, perspective=persp)) # print("repos_img: {}".format(repos_img)) self.Slice.affine = self.affine Publisher.sendMessage('Update affine matrix', affine=self.affine, status=True) scalar_range = int(scalar_range[0]), int(scalar_range[1]) Publisher.sendMessage('Update threshold limits list', threshold_range=scalar_range) return self.matrix, self.filename
def OpenOtherFiles(self, group): # Retreaving matrix from image data self.matrix, scalar_range, self.filename = image_utils.img2memmap( group) hdr = group.header hdr.set_data_dtype('int16') wl = float((scalar_range[0] + scalar_range[1]) * 0.5) ww = float((scalar_range[1] - scalar_range[0])) self.Slice = sl.Slice() self.Slice.matrix = self.matrix self.Slice.matrix_filename = self.filename # even though the axes 0 and 2 are swapped when creating self.matrix # the spacing should be kept the original, as it is modified somewhere later # otherwise generate wrong results # also need to convert to float because original get_zooms return numpy.float32 # which is unsupported by the plist for saving the project self.Slice.spacing = tuple([float(s) for s in hdr.get_zooms()]) self.Slice.window_level = wl self.Slice.window_width = ww if group.affine.any(): # remove scaling factor for non-unitary voxel dimensions scale, shear, angs, trans, persp = tr.decompose_matrix( group.affine) self.Slice.affine = np.linalg.inv( tr.compose_matrix(scale=None, shear=shear, angles=angs, translate=trans, perspective=persp)) else: self.Slice.affine = None scalar_range = int(scalar_range[0]), int(scalar_range[1]) Publisher.sendMessage('Update threshold limits list', threshold_range=scalar_range) return self.matrix, self.filename