m = 4 # number of sources to estimate h = 66 # number of lags for whiteness test i = 0 for p in [22, 33]: i += 1 print("Model order:", p) print(" Performing CSPVARICA") var = scot.backend["var"](p) result = cspvarica(data, var, classes, m) if result.a.is_stable(): s = "" else: s = "*NOT* " print(" VAR model is {}stable.".format(s)) # discard the first p residuals # r = result.var_residuals[p:, :, :] print(" Testing VAR residuals for whiteness up to lag", h) pr = splot.plot_whiteness(result.a, h, repeats=100, axis=plt.subplot(2, 1, i)) if pr < 0.05: plt.gca().set_title("model order {}: residuals significantly " "non-white with p={:f}".format(p, pr)) else: plt.gca().set_title("model order {}: residuals white " "with p={:f}".format(p, pr)) splot.show_plots()
i += 1 print('Model order:', p) print(' Performing CSPVARICA') var = scot.backend['var'](p) result = cspvarica(data, var, classes, m) if result.a.is_stable(): s = '' else: s = '*NOT* ' print(' VAR model is {}stable.'.format(s)) # discard the first p residuals # r = result.var_residuals[p:, :, :] print(' Testing VAR residuals for whiteness up to lag', h) pr = splot.plot_whiteness(result.a, h, repeats=100, axis=plt.subplot(2, 1, i)) if pr < 0.05: plt.gca().set_title('model order {}: residuals significantly ' 'non-white with p={:f}'.format(p, pr)) else: plt.gca().set_title('model order {}: residuals white ' 'with p={:f}'.format(p, pr)) splot.show_plots()
np.fill_diagonal(alpha['foot'], 0) order = None for cls in ['hand', 'foot']: np.fill_diagonal(alpha[cls], 0) w = alpha[cls] m = alpha[cls] > 4 # use same ordering of components for each class if not order: order = cuthill_mckee(m) # fixed color, but alpha varies with connectivity strength r = np.ones(w.shape) g = np.zeros(w.shape) b = np.zeros(w.shape) a = (alpha[cls] - 4) / max(np.max(alpha['hand'] - 4), np.max(alpha['foot'] - 4)) c = np.dstack([r, g, b, a]) plotting.plot_circular(colors=c, widths=w, mask=m, topo=topo, topomaps=mixmaps, order=order) plt.title(cls) plotting.show_plots()
topo.set_locations(locs) mixmaps = plotting.prepare_topoplots(topo, ws.mixing_) # Force diagonal (self-connectivity) to 0 np.fill_diagonal(alpha['hand'], 0) np.fill_diagonal(alpha['foot'], 0) order = None for cls in ['hand', 'foot']: np.fill_diagonal(alpha[cls], 0) w = alpha[cls] m = alpha[cls] > 4 # use same ordering of components for each class if not order: order = cuthill_mckee(m) # fixed color, but alpha varies with connectivity strength r = np.ones(w.shape) g = np.zeros(w.shape) b = np.zeros(w.shape) a = (alpha[cls]-4) / max(np.max(alpha['hand']-4), np.max(alpha['foot']-4)) c = np.dstack([r, g, b, a]) plotting.plot_circular(colors=c, widths=w, mask=m, topo=topo, topomaps=mixmaps, order=order) plt.title(cls) plotting.show_plots()