def test_probabilistic_labels(): """Test plotting of probabilistic labels """ mlab.options.backend = 'test' brain = Brain("fsaverage", "lh", "inflated", config_opts=dict(cortex="low_contrast")) brain.add_label("BA1", color="darkblue") brain.add_label("BA1", color="dodgerblue", scalar_thresh=.5) brain.add_label("BA45", color="firebrick", borders=True) brain.add_label("BA45", color="salmon", borders=True, scalar_thresh=.5) label_file = pjoin(subj_dir, "fsaverage", "label", "lh.BA6.label") prob_field = np.zeros_like(brain._geo.x) ids, probs = io.read_label(label_file, read_scalars=True) prob_field[ids] = probs brain.add_data(prob_field, thresh=1e-5) brain.data["colorbar"].number_of_colors = 10 brain.data["colorbar"].number_of_labels = 11 brain.close()
def mask_vtx_data(overlay_fname, cortex_fname, thresh): vtx_data = io.read_scalar_data(overlay_fname) cortex_data = io.read_label(cortex_fname) # Create a mask of 1s where there is cortex and 0s on the medial wall mask = np.zeros_like(vtx_data) mask[cortex_data] = 1 # Set all values that are not in cortex to thresh-1 vtx_data[mask == 0] = thresh-1 return vtx_data
def test_probabilistic_labels(): """Test plotting of probabilistic labels """ mlab.options.backend = 'test' brain = Brain("fsaverage", "lh", "inflated", config_opts=dict(cortex="low_contrast")) brain.add_label("BA1", color="darkblue") brain.add_label("BA1", color="dodgerblue", scalar_thresh=.5) brain.add_label("BA45", color="firebrick", borders=True) brain.add_label("BA45", color="salmon", borders=True, scalar_thresh=.5) label_file = pjoin(subj_dir, "fsaverage", "label", "lh.BA6.label") prob_field = np.zeros_like(brain._geo.x) ids, probs = io.read_label(label_file, read_scalars=True) prob_field[ids] = probs brain.add_data(prob_field, thresh=1e-5) brain.data["colorbar"].number_of_colors = 10 brain.data["colorbar"].number_of_labels = 11
You can also threshold based on the probability of that region being at each vertex. """ brain.add_label("BA1", color="#2B8CBE", scalar_thresh=.5) """ It's also possible to plot just the label boundary, in case you wanted to overlay the label on an activation plot to asses whether it falls within that region. """ brain.add_label("BA45", color="#F0F8FF", borders=True, scalar_thresh=.5) brain.add_label("BA45", color="#F0F8FF", alpha=.3, scalar_thresh=.5) """ Finally, with a few tricks, you can display the whole probabilistic map. """ subjects_dir = environ["SUBJECTS_DIR"] label_file = join(subjects_dir, "fsaverage", "label", "lh.BA6.label") prob_field = np.zeros_like(brain._geo.x) ids, probs = io.read_label(label_file, read_scalars=True) prob_field[ids] = probs brain.add_data(prob_field, thresh=1e-5, colormap="RdPu") """ Adjust the colorbar to represent the coarseness of the probability estimates more closely. """ brain.data["colorbar"].number_of_colors = 10 brain.data["colorbar"].number_of_labels = 11
""" You can also threshold based on the probability of that region being at each vertex. """ brain.add_label("BA1", color="dodgerblue", scalar_thresh=.5) """ It's also possible to plot just the label boundary, in case you wanted to overlay the label on an activation plot to asses whether it falls within that region. """ brain.add_label("BA45", color="firebrick", borders=True) brain.add_label("BA45", color="salmon", borders=True, scalar_thresh=.5) """ Finally, with a few tricks, you can display the whole probabilistic map. """ label_file = join(environ["SUBJECTS_DIR"], "fsaverage", "label", "lh.BA6.label") prob_field = np.zeros_like(brain._geo.x) ids, probs = io.read_label(label_file, read_scalars=True) prob_field[ids] = probs brain.add_data(prob_field, thresh=1e-5) """ Adjust the colorbar to represent the coarseness of the probability estimates more closely. """ brain.data["colorbar"].number_of_colors = 10 brain.data["colorbar"].number_of_labels = 11