The mgh files look like surface overlays judging from their dimensions (163842 x 1).  The values are for corresponding surface vertices. I’m not sure if Freesurfer already has a program to do the conversion. But I think you can do it with the following steps:

 

1. locate the surface file that the mgh will be overlaid with. This is to retrieve the surface vertex coordinates XYZ in tkr space.

2. get the matrix vox2ras-tkr using ‘mris_info <surface_file>’

3. for each surface vertex

- convert ras-tkr to vox, CRS=inv(vox2ras-tkr)*XYZ

- retrieve the overlay value for the corresponding vertex from mgh

- write the value to a 3D volume at the computed CRS location

 

Yujing

 

From: freesurfer-bounces@nmr.mgh.harvard.edu <freesurfer-bounces@nmr.mgh.harvard.edu> On Behalf Of Melissa Thalhammer
Sent: Tuesday, February 25, 2025 11:08 AM
To: Freesurfer@nmr.mgh.harvard.edu
Subject: [Freesurfer] Convert 1D mgh back to 3D

 

        External Email - Use Caution        

Dear everyone,

I know that this might be not exactly the right place to ask, but I unfortunately did not reach the authors of the publication so far.

I want to work with the evolutionary expansion map by Wei et al. published in Nat Comm (2019; MailScanner has detected a possible fraud attempt from "secure-web.cisco.com" claiming to be https://doi.org/10.1038/s41467-019-12764-8). On their website, they provide a download link leading to two mgh files (attached; MailScanner has detected a possible fraud attempt from "secure-web.cisco.com" claiming to be https://www.dutchconnectomelab.nl/wordpress/wp-content/uploads/Wei_et_al_2019_NatureComms.zip). I read them with the Matlab load_mgh.m function provided here (MailScanner has detected a possible fraud attempt from "secure-web.cisco.com" claiming to be https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/MghFormat) and it shows a 163842 x 1 vector (which probably corresponds to fsaverage6 I guess...). I now want to convertthe 1D vector back into 3D. I have come across save_mgh.m but don't know what should be put in as M (4x4 vox2ras transform). Any ideas what is the correct way to do that?

Thank you!

Best, Melissa