I’m sure this is simple, but I’m failing at it. I’ve computed mean values for each region (e.g. volume) in an atlas across my participants and want to plot the means on a brain. I know I can plot the mean values using
nilearn.plotting.plot_stat_map but I can’t figure out a simple way to reassign the region labels to the regional means using e.g. a CSV with columns
If someone as a ready snippet of code for transforming the atlas values, I’d greatly appreciate it.
Do you have masks for these ROIs? Ideally you would have a boolean mask (i.e. a 3d-matrix that is TRUE at all voxels where the region is and FALSE otherwise). Then, assuming you stick with Python/Nilearn, you create a 3d matrix the same dimensions as your standard space, and say
matrix is your initially empty 3d matrix,
mask_bool_inds is your boolean mask, and
ROI_value is the value from your CSV. Does that help / make sense?
There is a high level way to do it with Nilearn, that consists in re-using the masker object that you used to obtain per-roi signal, and call the
inverse_transform() method; providing as argument the per-roi quantity you want to plot. This will return an image at the original data resolution with the required value in each ROI.