def write_results(seed_ts, fc_map, global_signal, hdr, input_type, zero_mask): analysis_str = 'fc_map' if global_signal: analysis_str += '_gs' pickle.dump([seed_ts, fc_map], open(f'{analysis_str}_results.pkl', 'wb')) if input_type == 'cifti': write_to_cifti(fc_map, hdr, fc_map.shape[0], analysis_str) elif input_type == 'gifti': write_to_gifti(fc_map[np.newaxis, :], hdr, analysis_str, zero_mask)
def write_results(input_type, lag_results, lag_projection, hdr, global_signal, zero_mask): if global_signal: analysis_str = 'lag_projection_gs' else: analysis_str = 'lag_projection' pickle.dump(lag_results, open(f'{analysis_str}_results.pkl', 'wb')) if input_type == 'cifti': write_to_cifti(lag_projection, hdr, n_comps, analysis_str) elif input_type == 'gifti': write_to_gifti(lag_projection, hdr, analysis_str, zero_mask)
def write_results(input_type, spatial_map, ica_ts, hdr, global_signal, zero_mask, real_complex): analysis_str = 'ica' if global_signal: analysis_str += '_gs' if real_complex == 'complex': analysis_str += '_complex' comp_weights_real = np.real(spatial_map) comp_weights_imag = np.imag(spatial_map) comp_weights_ang = np.angle(spatial_map) pickle.dump([spatial_map, ica_ts], open(f'{analysis_str}_results.pkl', 'wb')) if input_type == 'cifti': if real_complex == 'real': write_to_cifti(spatial_map, hdr, spatial_map.shape[0], analysis_str) elif real_complex == 'complex': write_to_cifti(comp_weights_real, hdr, n_comps, f'{analysis_str}_real') write_to_cifti(comp_weights_imag, hdr, n_comps, f'{analysis_str}_imag') write_to_cifti(comp_weights_ang, hdr, n_comps, f'{analysis_str}_ang') elif input_type == 'gifti': if real_complex == 'real': write_to_gifti(spatial_map, hdr, analysis_str, zero_mask) elif real_complex == 'complex': write_to_gifti(comp_weights_real, hdr, f'{analysis_str}_real', zero_mask) write_to_gifti(comp_weights_imag, hdr, f'{analysis_str}_imag', zero_mask) write_to_gifti(comp_weights_ang, hdr, f'{analysis_str}_ang', zero_mask)
def write_results(input_type, hmm_results, mean_maps, n_comps, hdr, global_signal, zero_mask): if global_signal: analysis_str = 'hmm_gs' else: analysis_str = 'hmm' pickle.dump(hmm_results, open(f'{analysis_str}_results.pkl', 'wb')) if n_comps == 1: mean_maps = mean_maps[np.newaxis, :] if input_type == 'cifti': write_to_cifti(mean_maps, hdr, n_comps, f'{analysis_str}_mean_map') elif input_type == 'gifti': write_to_gifti(mean_maps, hdr, f'{analysis_str}_mean_map', zero_mask)
def write_results(emb_weights, hdr, input_type, gradient_algorithm, global_signal, zero_mask): if gradient_algorithm == 'laplacian': analysis_str = 'eigenmap' else: analysis_str = 'kpca' if global_signal: analysis_str += '_gs' pickle.dump(emb_weights, open(f'{analysis_str}_results.pkl', 'wb')) if input_type == 'cifti': write_to_cifti(emb_weights, hdr, emb_weights.shape[0], analysis_str) elif input_type == 'gifti': write_to_gifti(emb_weights, hdr, analysis_str, zero_mask)
def write_results(input_type, pca_output, rotate, comp_weights, n_comps, hdr, pca_type, global_signal, zero_mask): if global_signal: analysis_str = 'pca_gs' else: analysis_str = 'pca' if rotate: analysis_str += f'_{rotate}' if pca_type == 'complex': analysis_str += '_complex' pickle.dump( { 'pca': pca_output, 'metadata': [input_type, hdr, zero_mask] }, open(f'{analysis_str}_results.pkl', 'wb')) comp_weights_real = np.real(comp_weights) comp_weights_imag = np.imag(comp_weights) comp_weights_ang = np.angle(comp_weights) comp_weights_amp = np.abs(comp_weights) if input_type == 'cifti': write_to_cifti(comp_weights_real, hdr, n_comps, f'{analysis_str}_real') write_to_cifti(comp_weights_imag, hdr, n_comps, f'{analysis_str}_imag') write_to_cifti(comp_weights_ang, hdr, n_comps, f'{analysis_str}_ang') write_to_cifti(comp_weights_amp, hdr, n_comps, f'{analysis_str}_amp') elif input_type == 'gifti': write_to_gifti(comp_weights_real, hdr, f'{analysis_str}_real', zero_mask) write_to_gifti(comp_weights_imag, hdr, f'{analysis_str}_imag', zero_mask) write_to_gifti(comp_weights_ang, hdr, f'{analysis_str}_ang', zero_mask) write_to_gifti(comp_weights_amp, hdr, f'{analysis_str}_amp', zero_mask) elif pca_type == 'real': pickle.dump(pca_output, open(f'{analysis_str}_results.pkl', 'wb')) if input_type == 'cifti': write_to_cifti(comp_weights, hdr, n_comps, analysis_str) elif input_type == 'gifti': write_to_gifti(comp_weights, hdr, analysis_str, zero_mask)
def write_results(peak_avg, hdr, input_type, global_signal, zero_mask, peak_ts=None): if global_signal: analysis_str = 'peak_average_gs' else: analysis_str = 'peak_average' pickle.dump(peak_avg, open(f'{analysis_str}_results.pkl', 'wb')) if peak_ts is not None: for i, window in enumerate(peak_ts): write_to_gifti(window, hdr, f'{analysis_str}_ts_sample_{i}', zero_mask) if input_type == 'cifti': write_to_cifti(peak_avg, hdr, peak_avg.shape[0], analysis_str) elif input_type == 'gifti': write_to_gifti(peak_avg, hdr, analysis_str, zero_mask)
def write_results(cluster_centroid, cluster_indx, selected_tps, cluster_win_avgs, window_avg, norm, vertex_input, global_signal, hdr, input_type, zero_mask): analysis_str = 'caps' if global_signal: analysis_str += '_gs' if norm: analysis_str += '_norm' output = [cluster_centroid, cluster_indx, selected_tps] if window_avg: output += cluster_win_avgs for indx, win_avg in enumerate(cluster_win_avgs): tmp_str = analysis_str + f'_window_avg_clus{indx}' write_to_gifti(win_avg, hdr, tmp_str, zero_mask) pickle.dump(output, open(f'{analysis_str}_results.pkl', 'wb')) if input_type == 'cifti': write_to_cifti(cluster_centroid, hdr, cluster_centroid.shape[0], analysis_str) elif input_type == 'gifti': write_to_gifti(cluster_centroid, hdr, analysis_str, zero_mask)
def write_results(peak_avg, peak_avg_gs, global_signal, gs_map, hdr, input_type, zero_mask): analysis_str = f'gs' pickle.dump(global_signal, open(f'{analysis_str}_results.pkl', 'wb')) if input_type == 'cifti': write_to_cifti(peak_avg, hdr, peak_avg.shape[0], analysis_str + '_peak_avg') write_to_cifti(peak_avg_gs, hdr, peak_avg.shape[0], analysis_str + '_peak_avg_gsremoved') write_to_cifti(gs_map, hdr, gs_map.shape[0], analysis_str + '_map') elif input_type == 'gifti': write_to_gifti(peak_avg, hdr, analysis_str + '_peak_avg', zero_mask) write_to_gifti(peak_avg_gs, hdr, analysis_str + '_peak_avg_gsremoved', zero_mask) write_to_gifti(gs_map, hdr, analysis_str + '_map', zero_mask)