0001
0002 clear all
0003 close all
0004
0005 if isunix,
0006 dataPath = '/data/freesurfer/subjects/ucsf_mh/';
0007 else
0008 dataPath = 'e:\freesurfer\subjects\ucsf_mh\';
0009 end
0010
0011 plot_fs_surf = 0;
0012 plot_fs_voxels = 0;
0013 plot_ctf_voxels = 0;
0014
0015
0016 plot_fs_fid_ras = 0;
0017 plot_ctf_fid = 0;
0018
0019 plot_fs2ctf_fid = 0;
0020 plot_fs2ctf_surf = 0;
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 if isunix,
0046 ctfFile = [dataPath,'mri/analyze/ucsf_mh_orig_axial_las2ctf.mri'];
0047 else
0048 ctfFile = [dataPath,'mri\analyze\ucsf_mh_orig_axial_las2ctf.mri']
0049 end
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 ctf.mri = ctf_read_mri(ctfFile);
0065 headModel = ctf.mri.hdr.HeadModel_Info;
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086 ctf.volume_index.nas = [128 35 130];
0087 ctf.volume_index.lpa = [ 53 123 152];
0088 ctf.volume_index.rpa = [207 123 152];
0089
0090 ctf.volume_index.mat = [ctf.volume_index.nas; ctf.volume_index.lpa; ctf.volume_index.rpa ];
0091
0092 ctfVox = [ [ctf.volume_index.mat; 0 0 0] [ 1 1 1 0 ]' ];
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106 fs.volume_index.nas = [128 130 221];
0107 fs.volume_index.lpa = [203 152 133];
0108 fs.volume_index.rpa = [ 49 152 133];
0109
0110 fs.volume_index.mat = [fs.volume_index.nas; fs.volume_index.lpa; fs.volume_index.rpa ];
0111
0112 fsVox = [ [fs.volume_index.mat; 0 0 0] [1 1 1 0]']
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126 T.fs2ctf = [ -1 0 0 0 ;
0127 0 0 1 0 ;
0128 0 -1 0 0 ;
0129 256 256 0 1 ];
0130
0131
0132
0133 T.ctf2fs = [ -1 0 0 0 ;
0134 0 0 -1 0 ;
0135 0 1 0 0 ;
0136 256 0 256 1 ];
0137
0138
0139
0140 fs2ctf = fsVox * T.fs2ctf;
0141
0142 ctf2fs = ctfVox * T.ctf2fs;
0143
0144
0145
0146
0147
0148
0149
0150
0151 ctf.volume_xyz.sph = [ 0 0 5 ];
0152
0153
0154
0155
0156 ctf.volume_xyz.nas = [ 9.07 0.00 0.00];
0157 ctf.volume_xyz.lpa = [ 0.00 7.70 0.00];
0158 ctf.volume_xyz.rpa = [ 0.00 -7.70 0.00];
0159
0160 ctf.volume_xyz.mat = [ctf.volume_xyz.nas; ctf.volume_xyz.lpa; ctf.volume_xyz.rpa ];
0161
0162 ctfXYZ = [ [ctf.volume_xyz.mat; 0 0 0] [ 1 1 1 0 ]' ];
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183 if isunix,
0184 fsFile = [dataPath,'surf/rh.pial'];
0185 else
0186 fsFile = [dataPath,'surf\rh.pial'];
0187 end
0188 [fsSurf.vertices,fsSurf.faces] = freesurfer_read_surf(fsFile);
0189
0190
0191
0192
0193
0194
0195
0196
0197 fsVox.vertices = freesurfer_surf2voxels(fsSurf.vertices);
0198
0199 fsVox.faces = fsSurf.faces;
0200
0201
0202
0203
0204 ctf.vertices.mri = freesurfer_surf2ctf(fsSurf.vertices);
0205
0206 ctf.faces.mri = fsSurf.faces;
0207
0208 ctf_write_mrishape(ctf.vertices.mri,ctf.mri);
0209
0210
0211
0212
0213 ctf.vertices.head = ctf_mri2head(ctf.vertices.mri,ctf.mri);
0214
0215 ctf.faces.head = fsSurf.faces;
0216
0217 ctf_write_headshape(ctf.vertices.head,ctf.mri);
0218
0219
0220
0221
0222
0223 if isunix,
0224 dataPath = '/data/brainstorm_database/subjects/ucsf_mgh/';
0225 else
0226 dataPath = 'e:\brainstorm_database\subjects\ucsf_mgh\';
0227 end
0228
0229 subjecttessFile = [dataPath,'ucsf_mgh_subjecttess'];
0230
0231
0232 load( [subjecttessFile,'_backup'] )
0233 figure('name','current brainstorm')
0234 patch('vertices',Vertices{1}','faces',Faces{1},'facecolor',[.75 .7 .7],'edgecolor','none');
0235 view([0,0]); light
0236 figure('name','new brainstorm')
0237 patch('vertices',ctf.vertices.head / 100,'faces',ctf.faces.head,'facecolor',[.75 .7 .7],'edgecolor','none');
0238 view([0,0]); light
0239
0240
0241 Vertices{1} = ctf.vertices.head' / 100;
0242 Faces{1} = ctf.faces.head;
0243
0244 save(subjecttessFile, 'Comment', 'Faces', 'Vertices')
0245
0246 return
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261 if plot_fs_surf,
0262
0263
0264
0265 figure('name','FreeSurfer Surface')
0266 hold on
0267
0268 patch('faces',fsSurf.faces,'vertices',fsSurf.vertices, ...
0269 'edgecolor','none', ...
0270 'facecolor',[.8 .7 .7],'facealpha',0.5);
0271
0272 scatter3(fs.volume_xyz.nas(1),fs.volume_xyz.nas(2),fs.volume_xyz.nas(3),40,'r','filled');
0273 scatter3(fs.volume_xyz.lpa(1),fs.volume_xyz.lpa(2),fs.volume_xyz.lpa(3),40,'g','filled');
0274 scatter3(fs.volume_xyz.rpa(1),fs.volume_xyz.rpa(2),fs.volume_xyz.rpa(3),40,'b','filled');
0275 text(fs.volume_xyz.nas(1),fs.volume_xyz.nas(2),fs.volume_xyz.nas(3),'. nasion');
0276 text(fs.volume_xyz.lpa(1),fs.volume_xyz.lpa(2),fs.volume_xyz.lpa(3),'. left');
0277 text(fs.volume_xyz.rpa(1),fs.volume_xyz.rpa(2),fs.volume_xyz.rpa(3),'. right');
0278
0279 set(gca,'DataAspectRatio',[1 1 1]);
0280 set(gca,'Xlim',[-128 128],'Ylim',[-128 128],'Zlim',[-128 128])
0281 rotate3d
0282 view(2)
0283 light
0284 end
0285
0286 if plot_fs_voxels,
0287
0288
0289
0290 figure('name','FreeSurfer Voxels')
0291 hold on
0292
0293 patch('faces',fsVox.faces,'vertices',fsVox.vertices, ...
0294 'edgecolor','none', ...
0295 'facecolor',[.8 .7 .7],'facealpha',0.5);
0296
0297 scatter3(fs.volume_index.nas(1),fs.volume_index.nas(2),fs.volume_index.nas(3),40,'r','filled');
0298 scatter3(fs.volume_index.lpa(1),fs.volume_index.lpa(2),fs.volume_index.lpa(3),40,'g','filled');
0299 scatter3(fs.volume_index.rpa(1),fs.volume_index.rpa(2),fs.volume_index.rpa(3),40,'b','filled');
0300 text(fs.volume_index.nas(1),fs.volume_index.nas(2),fs.volume_index.nas(3),'. nasion');
0301 text(fs.volume_index.lpa(1),fs.volume_index.lpa(2),fs.volume_index.lpa(3),'. left');
0302 text(fs.volume_index.rpa(1),fs.volume_index.rpa(2),fs.volume_index.rpa(3),'. right');
0303
0304 set(gca,'DataAspectRatio',[1 1 1]);
0305 set(gca,'Xlim',[0 256],'Ylim',[0 256],'Zlim',[0 256])
0306 rotate3d
0307 view([0,0])
0308 light
0309
0310 end
0311
0312 if plot_ctf_voxels,
0313
0314
0315
0316
0317 figure('name','CTF Voxels')
0318 hold on
0319
0320 patch('faces',ctf.shape.faces,'vertices',ctf.shape.vertices, ...
0321 'edgecolor','none', ...
0322 'facecolor',[.8 .7 .7],'facealpha',0.5);
0323
0324 scatter3(ctf.volume_index.nas(1),ctf.volume_index.nas(2),ctf.volume_index.nas(3),40,'r','filled');
0325 scatter3(ctf.volume_index.lpa(1),ctf.volume_index.lpa(2),ctf.volume_index.lpa(3),40,'g','filled');
0326 scatter3(ctf.volume_index.rpa(1),ctf.volume_index.rpa(2),ctf.volume_index.rpa(3),40,'b','filled');
0327 text(ctf.volume_index.nas(1),ctf.volume_index.nas(2),ctf.volume_index.nas(3),'. nasion');
0328 text(ctf.volume_index.lpa(1),ctf.volume_index.lpa(2),ctf.volume_index.lpa(3),'. left');
0329 text(ctf.volume_index.rpa(1),ctf.volume_index.rpa(2),ctf.volume_index.rpa(3),'. right');
0330
0331 set(gca,'DataAspectRatio',[1 1 1]);
0332 set(gca,'Xlim',[0 256],'Ylim',[0 256],'Zlim',[0 256])
0333 rotate3d
0334 view([0,-90])
0335 light
0336 end