def plot(self, **kwargs): r"""Plot the graph. See :func:`pygsp.plotting.plot_graph`. """ from pygsp import plotting plotting.plot_graph(self, **kwargs)
def plot(self, **kwargs): r""" Plot the graph. See plotting doc. """ from pygsp import plotting plotting.plot_graph(self, show_plot=True, **kwargs)
def plot(self, **kwargs): r""" Plot the graph. See plotting doc. """ from pygsp import plotting plotting.plot_graph(self, **kwargs)
L_reg = Gs[i].L + reg_eps * sparse.eye(Gs[i].N) Gs[i].mr['K_reg'] = kronReduction(L_reg, ind) Gs[i].mr['green_kernel'] = filters.Filter(Gs[i], lambda x: 1. / (reg_eps + x)) return Gs G = graphs.SwissRoll(N=1000, seed=42) levels = 5 Gs = multiresolution(G, levels, sparsify=True) fig = plt.figure(figsize=(10, 2.5)) for i in range(4): ax = fig.add_subplot(1, 4, i + 1, projection='3d') plotting.plot_graph(Gs[i + 1], ax=ax) _ = ax.set_title( 'Pyramid Level: {} \n Number of nodes: {} \n Number of edges: {}'. format(i + 1, Gs[i + 1].N, Gs[i + 1].Ne)) ax.set_axis_off() fig.tight_layout() plt.show() G = graphs.Sensor(1200, distribute=True) levels = 5 Gs = multiresolution(G, levels, sparsify=True) fig = plt.figure(figsize=(10, 2.5)) for i in range(4): ax = fig.add_subplot(1, 4, i + 1) # , projection='3d' plotting.plot_graph(Gs[i + 1], ax=ax)
import numpy as np from pycgsp.graph import cvxhull_graph from pygsp.plotting import plot_graph theta, phi = np.linspace(0,np.pi,6, endpoint=False)[1:], np.linspace(0,2*np.pi,9, endpoint=False) theta, phi = np.meshgrid(theta, phi) x,y,z = np.cos(phi)*np.sin(theta), np.sin(phi)*np.sin(theta), np.cos(theta) R = np.stack((x.flatten(), y.flatten(), z.flatten()), axis=-1) G, _ = cvxhull_graph(R) plot_graph(G)
ch_names=montage, unit="m") C = np.matmul(X, X.T) / X.shape[1] C = C - np.eye(C.shape[0]) C[C < threshold] = 0 G = graphs.Graph(C, lap_type="normalized", coords=montage.get_pos2d()) print("- Nodes:", G.N) print("- Edges:", G.Ne) return G if __name__ == '__main__': from pygsp import plotting from applications.eeg.eye_dataset import MONTAGE s = load_subject(8, True) r = load_run_from_subject(s, 5) X, y = get_trial(r, 47) data, labels = get_subject_dataset(1, False) print(data.shape) q = 0.1 k = 0.15 plot_montage(MONTAGE) G = create_spatial_eeg_graph(MONTAGE, q, k) plotting.plot_graph(G, "matplotlib", save_as="graph") fig = plt.figure() plt.imshow(G.W.todense()) plt.colorbar() fig.savefig("W.jpg") # plot_spectrum(3, 2, q, k)
l, v = np.linalg.eig(C) l_0, v_0 = np.linalg.eig(C_0) l_1, v_1 = np.linalg.eig(C_1) P_0 = np.matmul(np.matmul(v_0.T, C_0), v_0) P_1 = np.matmul(np.matmul(v_1.T, C_1), v_1) P = np.matmul(np.matmul(v.T, C), v) print("P_0: %1.3f, P_1: %1.3f" % (np.matrix.trace(P_0), np.matrix.trace(P_1))) G_rbf = create_spatial_eeg_graph(MONTAGE, q=0.1, k=0.1) G_rbf.compute_laplacian("normalized") G_rbf.compute_fourier_basis() U_rbf = G_rbf.U plotting.plot_graph(G_rbf, "matplotlib", save_as="grap") fig = plt.figure() plt.imshow(G_rbf.W.todense()) plt.colorbar() fig.savefig("W.png") P_0_rbf = np.matmul(np.matmul(U_rbf.T, C_0), U_rbf) P_1_rbf = np.matmul(np.matmul(U_rbf.T, C_1), U_rbf) P_rbf = np.matmul(np.matmul(U_rbf.T, C), U_rbf) fig = plt.figure() plt.imshow(P_0_rbf) plt.colorbar() fig.savefig("P_0_rbf.png")