help > RE: Plot Values onto Volume Files
May 29, 2019  06:05 AM | Mingrui Xia
RE: Plot Values onto Volume Files
Dear Adam,

Please try the following MATLAB codes:

Assuming that M is a n*1 vector containing value for each parcel of an atlas and n corresponding to the number of parcels. 

hdr = spm_vol('atlas.nii');  %atlas.nii is the filename of your atlas nifti file
vol = spm_read_vols(hdr);
vol_new = zeros(hdr.dim);
for i = 1:n % change n to the real number of your atlas
vol_new(vol==i) = M(i);
hdr_new = hdr;
hdr_new.fname = 'newfile.nii'; %replace newfile.nii as any filename you want
hdr_new.dt(1) = 32;


Originally posted by Adam Weinberger:
Hi Everyone,

I would like to prepare a figure that takes a value for each parcellation in an atlas and then plots it back onto the brain, (i.e. if I wanted to create a brain that mapped correlations between network measurements in a parcellation and a behavior variable). I know that this involves editing the atlas file (or creating a text file that maps a value onto each vertex) and then putting that in as the volume file in BrainNet, but I simply cannot figure out a way to do this. I've tried through SPM, MATLAB, and FSL but to no avail. Conceivably this is something that others have been able to do, so I'm hopeful that someone might be able to provide guidance on how to accomplish this. 



Threaded View

Adam Weinberger May 28, 2019
RE: Plot Values onto Volume Files
Mingrui Xia May 29, 2019