def find_bounding_sphere(mrc, L): v = AIF.read_mrc(mrc) points = [] density_max = v.max() contour_level = L * density_max for ijk in np.ndindex(v.shape): if v[ijk] >= contour_level: points.append([float(ijk[0]), float(ijk[1]), float(ijk[2])]) points = np.asarray(points) # return boundingSphere.find_min_bounding_sphere(points) return miniball.Miniball(points)
def find_min_bounding_sphere(path, L): v = AIF.read_mrc(path) points = [] density_max = v.max() contour_level = L * density_max for ijk in np.ndindex(v.shape): if v[ijk] >= contour_level: points.append([float(ijk[0]), float(ijk[1]), float(ijk[2])]) R, C, Xb = exact_min_bound_sphere_3D(points) #print(R) #print(C) #print(Xb) #print(R, C, Xb) return R, C
M = N.zeros(Rsq.shape) M[ind] = Rsq[ind] / dif_ms[ind] return M else: return Rsq if __name__ == '__main__': import json import aitom.io.file as IF import aitom.filter.gaussian as FG with open('surface_feature__op.json') as f: op = json.load(f) im = IF.read_mrc(op['vol_file']) # voxel spacing in nm unit voxel_spacing = (im['header']['MRC']['xlen'] / im['header']['MRC']['nx']) * 0.1 print('voxel_spacing', voxel_spacing) v = im['value'] if 'debug' in op: se = N.array(op['debug']['start_end']) v = v[se[0, 0]:se[0, 1], se[1, 0]:se[1, 1], se[2, 0]:se[2, 1]] v = v.astype(N.float) v -= v.mean() IF.put_mrc(v, '/tmp/v.mrc', overwrite=True)