mesh_freesurfer2emse - Convert FreeSurfer tesselation to EMSE USEAGE: [FV] = mesh_freesurfer2emse(sfile,rfile) This function will call several functions to (a) read a freesurfer surface (sfile), (b) read an EMSE registration file (rfile) and (c) output the surface as an EMSE wireframe file (*.wfr) in the registration space. The freesurfer surface is read with mesh_freesurfer2matlab. The EMSE registration file is read with emse_read_reg. The EMSE wireframe is writen with mesh_writ Websites: EMSE: http://www.sourcesignal.com/ Freesurfer: http://surfer.nmr.mgh.harvard.edu/
0001 function [FV] = mesh_freesurfer2emse(sfile,rfile) 0002 0003 % mesh_freesurfer2emse - Convert FreeSurfer tesselation to EMSE 0004 % 0005 % USEAGE: [FV] = mesh_freesurfer2emse(sfile,rfile) 0006 % 0007 % This function will call several functions to (a) read a 0008 % freesurfer surface (sfile), (b) read an EMSE registration 0009 % file (rfile) and (c) output the surface as an EMSE wireframe 0010 % file (*.wfr) in the registration space. 0011 % 0012 % The freesurfer surface is read with mesh_freesurfer2matlab. 0013 % The EMSE registration file is read with emse_read_reg. 0014 % The EMSE wireframe is writen with mesh_writ 0015 % Websites: 0016 % 0017 % EMSE: http://www.sourcesignal.com/ 0018 % Freesurfer: http://surfer.nmr.mgh.harvard.edu/ 0019 % 0020 0021 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:35 $ 0022 0023 % Licence: GNU GPL, no implied or express warranties 0024 % History: 08/2002, Darren.Weber_at_radiology.ucsf.edu 0025 % 0026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0027 0028 0029 0030 msg = sprintf('MESH_FREESURFER2EMSE: In development'); 0031 %error(msg); 0032 0033 0034 0035 datapath = '\\potzii\data\freesurfer\subjects\ptsdpet-c01keep\'; 0036 cd(datapath) 0037 0038 sfile = 'surf\rh.pial.asc'; 0039 rfile = 'mri\analyze\c01_orig_axial_ras.reg'; 0040 mfile = 'mri\analyze\c01_orig_axial_ras.img'; 0041 0042 % First read the freesurfer surface 0043 [FV] = mesh_freesurfer2matlab(sfile); 0044 0045 % Convert from mm to meters 0046 %FV.vertices = FV.vertices ./ 1000; 0047 0048 avw = avw_img_read(mfile); 0049 0050 0051 0052 keyboard 0053 0054 0055 0056 0057 % Now read the EMSE registration file 0058 %REG = emse_read_reg(rfile); 0059 %scale = ones(size(FV.vertices,1),1); 0060 %vert = [FV.vertices, scale]; 0061 %vert = vert * REG.mri2elec; 0062 %vert = Rz(vert(:,1:3),180,'degrees'); 0063 %FV.vertices = vert(:,1:3); 0064 0065 %EMSE.file = '\\POTZII\data\freesurfer\subjects\ptsdpet-c01keep\mri\analyze\c01_orig_axial_ras_scalp.wfr'; 0066 %[vertices,faces,edges,meshtype] = mesh_emse2matlab(EMSE.file,{'vertex','face'}); 0067 %EMSE.vertices = [vertices.x; vertices.y; vertices.z]'; 0068 %EMSE.faces = [faces.vertex1;faces.vertex2;faces.vertex3]'; 0069 % Rotate 90 degrees around Z for EMSE data 0070 %EMSE.vertices = Rz(EMSE.vertices,90,'degrees'); 0071 0072 %clear vertices faces edges meshtype; 0073 0074 % Plot EMSE scalp surface 0075 %figure; hold on 0076 %patch('vertices',EMSE.vertices,'faces',EMSE.faces,'FaceColor',[.6 .0 .0],'Edgecolor','none','FaceAlpha',.4); 0077 0078 % Plot freesurfer cortex and transformed vertices 0079 %patch('vertices',FV.vertices,'faces',FV.faces,'FaceColor',[.0 .0 .6],'Edgecolor','none'); 0080 %patch('vertices',vert,'faces',FV.faces,'FaceColor',[.6 .0 .0],'Edgecolor','none'); 0081 %set(gca,'Projection','perspective'); 0082 %set(gca,'DataAspectRatio',[1 1 1]); 0083 %axis off tight vis3d 0084 %light 0085 %mouse_rotate 0086 0087 0088 0089 %p.mesh.path = '\\potzii\data\freesurfer\subjects\ptsdpet-c01keep\mri\analyze\'; 0090 %p.mesh.file = 'c01_orig_axial_ras.wfr'; 0091 %p.mesh.data.meshtype{1} = 'pial'; 0092 %p.mesh.data.vertices{1} = FV.vertices; 0093 %p.mesh.data.faces{1} = FV.faces; 0094 %mesh_write_emse(p); 0095 0096 return 0097 0098 0099 0100 0101 % EMSE Voxel Coordinates 0102 % Voxel coordinates measure location in terms of the voxels inherent in 0103 % the given volumetric set. The origin is the bottom (inferior) axial 0104 % slice, the posterior row and in the rightmost column. This coordinate 0105 % system is right-handed (although, internally, the origin is in the 0106 % anterior row, and thus is left-handed; this representation is not 0107 % available to the user). The order of the displayed coordinates is 0108 % (slice#, row#, column#). 0109 % 0110 % EMSE MRI Coordinates 0111 % MRI coordinates share the same origin as internal voxel coordinates, 0112 % but differ from the latter in two ways: first, the coordinates 0113 % are measured in millimeters, not voxels. Secondly, the origin is that 0114 % of the internal representation; that is, the inferior slice, anterior 0115 % row and rightmost column. As mentioned above, this internal representation 0116 % is left-handed. To correct for this, the row axis is numbered in the 0117 % opposite direction, making the displayed coordinate system right-handed. 0118 % The order of the displayed coordinates is (x, y, z). 0119 0120 % Given a point P(x,y,z) in head frame (the activation point on the 0121 % cortical mesh) and you want to find the corresponding voxel in the 0122 % vmi file. Symbolically you have P(head) and you want to find P(voxel). 0123 % 0124 % 1. The registration file contains the matrix HeadToImage, 0125 % so P(MRI-mm) = HeadToImage*P(head), where P(MRI-mm) is the 0126 % point in MRI coordinates. 0127 % 2. From the voxel size, you can find P(MRI-voxel), which 0128 % is the MRI coordinates expressed in voxels 0129 % 3. Use the offset between the MRI coordinate frame and 0130 % the Image coordinate frame to find P(voxel). 0131 % 0132 %Demetrios Voreades, Ph.D. 0133 %Applications Engineer, Source Signal Imaging 0134 %