xs = fitted[:, 0] ys = fitted[:, 1] zs = fitted[:, 2] utils.plot_3d_mod(xs, ys, zs, title='wf{} {}'.format(wf, scid), s=5, edge='navy', xlabel='PC1', ylabel='PC2', zlabel='PC3', add_info='PAT{} ({})'.format(wf, scid)) if input('Satisfied? (y|N)\n') != 'y': raise Exception('Not satisified :(') # ============================================================================= # Gaussian Mixture Models and, if needed, additional clustering n_components = int(input('Type the number of components to split into: ')) fitted_copy = fitted cluster_means, clusters, ns, ks, clusters_list = utils.gaussian_mixture_pca_projections( fitted, waves, n_components, npat=None, scid=scid, wave_type=wave_type, n_init=5)
zlabel = 'PC3', add_info = 'PAT{} ({})'.format(patient_nr, scid)) if input('Satisfied? (y|N)\n') != 'y': raise Exception('Not satisified :(') """ # ============================================================================= # Gaussian Mixture Models and, if needed, additional clustering n_components = int(input('Type the number of components to split into: ')) fitted_copy = fitted cluster_means, clusters, ns, ks, clusters_list = utils.gaussian_mixture_pca_projections( fitted, waves, n_components, npat=patient_nr, scid=scid, wave_type=wave_type, n_init=1, random_state=120000) # ============================================================================= # Plot random ABP waves and their ICP counterparts """ utils.plot_random_wave_samples(waves, wave_type='abp', seg_type=scid, rand_list=clusters_list[-1]) icp_waves = utils.acces_waves_by_type(None, stacked_waves, 'icp') utils.plot_random_wave_samples(icp_waves, wave_type='icp', seg_type=scid, rand_list=clusters_list[-1]) """ # ============================================================================= # Fit-Transforming PCA on acquired waves: print('\n\nAnalysis of corresponding counterparts:') wave_type = 'icp'
add_info = '({})'.format(scid)) if input('\nSatisfied? (y|N)\n') != 'y': raise Exception('Not satisified :(') """ # ============================================================================= # Gaussian Mixture Models OR HDBSCAN and, if needed, additional clustering * decision = input('dbscan or gmm: ') if decision == 'gmm': n_components = int(input('Type the number of components to split into: ')) cluster_means, clusters, ns, ks, clusters_list = utils.gaussian_mixture_pca_projections( fitted, waves, n_components, npat=None, scid=scid, wave_type='icp', n_init=1, random_state=3) print('That was it.') # ______________________________________________________________________________ elif decision == 'dbscan': labels, sub_colors, n_clusters = utils.hdbscan_(fitted) xs = fitted[:, 0] ys = fitted[:, 1] zs = fitted[:, 2] N = len(np.unique(sub_colors)) labels += 1 #print(waves[2 == np.where(wf_types == 1)].shape)
utils.plot_3d(xs, ys, zs, title='NFPAT{} {} PCA projection'.format(patient_nr, scid), xlabel='PC1', ylabel='PC2', zlabel='PC3', s=1) # Gaussian Mixture Models and, if needed, additional clustering n_components = int(input('Type the number of components to split into: ')) cluster_means, clusters, ns, ks = utils.gaussian_mixture_pca_projections( fitted, concatenated_waves, n_components, patient_nr, scid, with_mahal=False) clusters = np.asarray(clusters) if input('Continue with cleaning and saving? ') != 'yes': import sys sys.exit() else: # Cleaning (only if additional clustering was needed): if ns is not None: print('\nCleaning...') x = cluster_means.shape[0]
scid = 'nsc' utils.plot_3d(xs, ys, zs, title='PCA projection'.format(scid), xlabel='PC1', ylabel='PC2', zlabel='PC3', s=1) # Gaussian Mixture Models and, if needed, additional clustering n_components = int(input('Type the number of components to split into: ')) cluster_means, clusters, ns, ks = utils.gaussian_mixture_pca_projections( fitted, concatenated_waves, n_components) """ clusters = np.asarray(clusters) # Cleaning (only if additional clustering was needed): if ns is not None: print('\nCleaning...') x = cluster_means.shape[0] # Means: cluster_means = np.delete(cluster_means, ns, axis=0) # Clusters: clusters = np.delete(clusters, ns, axis=0) assert cluster_means.shape[0] == clusters.shape[0] print('{} cluster(s) removed!'.format(x - cluster_means.shape[0]))