def _calc_activity_colors(params): data, t, fol, scalar_map_big, scalar_map_small, threshold, do_print = params colors = utils.arr_to_colors_two_colors_maps(data, scalar_map_big=scalar_map_big, scalar_map_small=scalar_map_small, threshold=threshold, default_val=1)[:,:3] if do_print and t % 10 == 0: print(t) # colors = utils.arr_to_colors(data[:, t], 0, data_max, scalar_map=scalar_map)[:,:3] colors = np.hstack((np.reshape(data, (data.shape[0], 1)), colors)) np.save(os.path.join(fol, 't{}'.format(t)), colors)
def save_fmri_colors(subject, fmri_file, surf_name, output_file, threshold=0, cm_big='YlOrRd', cm_small='PuBu', flip_cm_big=True, flip_cm_small=False, norm_by_percentile=True, norm_percs=(2, 98)): data = {} hemis = ['rh', 'lh'] for hemi in hemis: data[hemi], _ = get_hemi_data(subject, hemi, fmri_file.format(hemi), surf_name) if norm_by_percentile: data_max = max( [np.percentile(data[hemi], norm_percs[1]) for hemi in hemis]) data_min = min( [np.percentile(data[hemi], norm_percs[0]) for hemi in hemis]) else: data_max = max([np.max(data[hemi]) for hemi in hemis]) data_min = min([np.min(data[hemi]) for hemi in hemis]) data_minmax = max(map(abs, [data_max, data_min])) for hemi in hemis: colors = utils.arr_to_colors_two_colors_maps( data[hemi], threshold=threshold, x_max=data_minmax, x_min=-data_minmax, cm_big=cm_big, cm_small=cm_small, default_val=1, flip_cm_big=flip_cm_big, flip_cm_small=flip_cm_small) data[hemi] = np.reshape(data[hemi], (len(data[hemi]), 1)) colors = np.hstack((data[hemi], colors)) np.save(output_file.format(hemi), colors)
def save_fmri_colors( subject, fmri_file, surf_name, output_file, threshold=0, cm_big="YlOrRd", cm_small="PuBu", flip_cm_big=True, flip_cm_small=False, norm_by_percentile=True, norm_percs=(2, 98), ): data = {} hemis = ["rh", "lh"] for hemi in hemis: data[hemi], _ = get_hemi_data(subject, hemi, fmri_file.format(hemi), surf_name) if norm_by_percentile: data_max = max([np.percentile(data[hemi], norm_percs[1]) for hemi in hemis]) data_min = min([np.percentile(data[hemi], norm_percs[0]) for hemi in hemis]) else: data_max = max([np.max(data[hemi]) for hemi in hemis]) data_min = min([np.min(data[hemi]) for hemi in hemis]) data_minmax = max(map(abs, [data_max, data_min])) for hemi in hemis: colors = utils.arr_to_colors_two_colors_maps( data[hemi], threshold=threshold, x_max=data_minmax, x_min=-data_minmax, cm_big=cm_big, cm_small=cm_small, default_val=1, flip_cm_big=flip_cm_big, flip_cm_small=flip_cm_small, ) data[hemi] = np.reshape(data[hemi], (len(data[hemi]), 1)) colors = np.hstack((data[hemi], colors)) np.save(output_file.format(hemi), colors)