Coordinate Transform between Brainstorm, Freesurfer and Curry8

2 minute read

Brainstorm & freesurfer

Requirement:

  • The Brainstorm MRI is the T1.mgz generated by the freesurfer OR
  • Export the MRI image from Brainstorm and directly used as the input for Freesurfer (not going through our softwares or transformations)

Method 1: (tested in Brainstorm version 2021)

In Brainstorm, import surfaces (*h.pial), merge surfaces, and it will be in the correct Brainstorm coordinate.

Method 2: (coordinate conversion in Matlab)

  1. Read the files: Export Brainstorm MRI to Matlab (Variable name: sMri). Read freesurfer cortext file into Matlab using mne_read_surface (comes with Brainstorm) or freesurfer_read_surf from bioelectromagnetism. Those two function is the same, but the first function returns coordinate in unit m, while the latter returns in unit mm.
    [verts1, faces1] = mne_read_surface('lh.pial');
    [verts2, faces2] = mne_read_surface('rh.pial');
    verts = [verts1;verts2];
    faces = [faces1;faces2];
    
  2. Shift
    pos_bs2 = bst_bsxfun(@plus, verts, (size(sMri.Cube)/2 + [0 1 0]) .* sMri.Voxsize / 1000);
    
  3. Transform
    pos_bs = cs_convert(sMri, 'mri', 'scs', pos_bs2);
    

    The pos_bs will be the Freesurfer pial surface in Brainstorm coordinate.

Similarly, to go from brainstorm to freesurfer coordinates, we need

pos_fs = cs_convert(sMri, 'scs', 'mri', bs.Vertices);
pos_fs = bst_bsxfun(@minus, pos_fs, (size(sMri.Cube)/2 + [0 1 0]) .* sMri.Voxsize / 1000)*1000; 

Curry8 & freesurfer

Case 1:

  • The Curry MRI is the T1.mgz generated by freesurfer.
  • Simply do –> Results –> Coordinates: Freesurfer, NifTi (R,A,S) –> Sufaces: Load from –> select the pial

Case 2:

  • The MRI is not the T1.mgz. There are already surfaces and points generated in the original MRI coordinate.
  • Steps:
    1. Export image data from Curry
    2. After recon-all in Freesurfer, run
      tkregister2 --mov rawavg.mgz --targ T1.mgz --reg register.native.dat --noedit --regheader
      mri_surf2surf --sval-xyz pial --reg register.native.dat rawavg.mgz --tval lh.pial.native --tval-xyz rawavg.mgz --hemi lh --s subjectname
      
    3. Import *h.pial.native following the steps in case 1.

Brainstorm and Curry 8

From Brainstorm to Curry 8 (one MRI)

  1. Export Brainstorm MRI, and load into Curry 8. Select mirror when importing the .nii MRI into Curry
  2. Record the fiducials in Brainstorm in the MRI coordinate into a txt
  3. In Curry 8: Coordinates: Image Data (R,A,S) –> Localizer Load the txt –> Save and use as image landmark
  4. Save any points you want to export to Curry in MRI coordinate and load to Curry in Image Data (R,A,S) coordinates
  5. Or
    • Export sEEG to file in .res format.

    In Matlab: brainstorm to curry

     curryPos = bsPos;
     curryPos(:,1) = -bsPos(:,2);
     curryPos(:,2) = bsPos(:,1);
     curryPos = curryPos * 1000;
    
    • Then in Curry localziter, open the .res file in PAN coordinate.

From Brainstorm to Curry 8 (two MRI)

  1. Coregister the first MRI using steps above as Image Data (1) in Curry.
  2. Import the second MRI to Curry, change it to the default MRI (Image Data 1), and follow the steps above. (Curry 8 perform “Save and use as image landmark” only on Image Data 1, so we need to change the new MRI as the default one.)

References:

  1. The code for import surface mesh in brainstorm
  2. Freesurfer to native anatomy

Categories:

Updated: