Skip to content

Render or register brain with a volume overlay

Fa-Hsuan Lin edited this page Jun 25, 2022 · 5 revisions

Render or register brain with a volume overlay

This example shows how to paint values in a overlay volume file in both brain volume and surfaces of a subject. All data are shown in the native subject's anatomical space.

[A script file] can be downloaded from Google drive.

Render a brain volume overlay

Here, we took a overlay file (f.mgz) and painted the first time point of it over the brain volume and surface. A registration file (register.dat) is needed to co-register between the overlay and anatomical underlay. Since this overlay is just an EPI volume, its values were rather homogeneous across the whole brain.

Note You may use the FreeSurfer command mri_convert to convert the overlay file into the .mgz format.

The essential part of the script is to prepare the overlay volume and surfaces matched to the anatomical volume and surfaces.

%%% volume overlay
f=MRIread(file_overlay_vol);
r=etc_read_xfm('file_xfm',file_overlay_register);

%prepare overlay volume matched to the underlay volume
vol = etc_MRIvol2vol(f,mri,r,'frames',[1]); %only the first volume
 
%prepare overlay surface
vol2surf = etc_MRIvol2surf(f,surf,r,'subject',subject,'frames',[1],'hemi',hemi);

etc_render_fsbrain('surf',surf,'hemi',hemi,'subject',subject,'vol',mri,'talxfm',(talxfm),'overlay_vol',vol,'overlay_value',vol2surf,'overlay_vertex',[1:size(vol2surf,1)]-1,'overlay_threshold',overlay_threshold);

Overlaying data with multiple time points can be done by preparing volumes and surfaces.

Manually register between two brain volumes

  1. Run the script to render overlay and underlay brain volumes as described above.
  2. Press 'k' to invoke the registration window. Register between underlay and overlay brain volumes by rotation and translation.
  3. Export the transformation matrix to the Matlab work space by pressing the "Export" button. A variable overlay_xfm will be exported.
  4. Replace the transformation matrix in the file by the new transformation matrix R:

R = r * 'overlay_xfm',

where r is the transformation matrix read from the file defined in the script.

Clone this wiki locally