def load_current_fmri_clusters_labels_file(): constrast_name = bpy.context.scene.fmri_clusters_labels_files minmax_fname = op.join( mu.get_user_fol(), 'fmri', '{}_minmax.pkl'.format('_'.join(constrast_name.split('_')[:-1]))) minmax_exist = op.isfile(minmax_fname) # if minmax_exist and not _addon().colorbar_values_are_locked(): # min_val, max_val = mu.load(minmax_fname) # _addon().set_colorbar_max_min(max_val, min_val) fMRIPanel.constrast = {} for hemi in mu.HEMIS: contrast_fname = get_contrast_fname(constrast_name, hemi) if contrast_fname != '': print('Loading {}'.format(contrast_fname)) fMRIPanel.constrast[hemi] = np.load(contrast_fname) if not minmax_exist: data = None for hemi in mu.HEMIS: x_ravel = fMRIPanel.constrast[hemi] data = x_ravel if data is None else np.hstack((x_ravel, data)) norm_percs = (bpy.context.scene.fmri_blobs_percentile_min, bpy.context.scene.fmri_blobs_percentile_max) min_val, max_val = mu.calc_min_max(data, norm_percs=norm_percs) _addon().colorbar.set_colorbar_max_min(max_val, min_val, force_update=True) mu.save((min_val, max_val), minmax_fname)
def _calc_best_curves_sep(data, norm_percs=[3, 97]): if len(data) == 0: return 0 try: max_diff = max([np.diff(mu.calc_min_max(data[k], norm_percs=norm_percs))[0] for k in range(data.shape[0])]) return max_diff * 1.1 except: print('Error in _calc_best_curves_sep') return 0