0001
0002
0003
0004
0005
0006
0007
0008 clear all
0009
0010 coregister = 0;
0011 elecplot = 0;
0012
0013
0014
0015
0016
0017
0018 mriFID.sub{ 1} = 'c01';
0019 mriFID.xyz{ 1} = [ 0.005 0.097 -0.022; 0.071 0.023 -0.052; -0.072 0.016 -0.050 ];
0020 mriFID.sub{ 2} = 'c02';
0021 mriFID.xyz{ 2} = [ 0.007 0.088 -0.007; 0.081 0.015 -0.046; -0.070 0.012 -0.051 ];
0022 mriFID.sub{ 3} = 'c03';
0023 mriFID.xyz{ 3} = [ -0.002 0.098 -0.008; 0.055 0.040 -0.038; -0.095 0.030 -0.046 ];
0024 mriFID.sub{ 4} = 'c04';
0025 mriFID.xyz{ 4} = [ 0.000 0.092 0.000; 0.070 0.024 -0.036; -0.076 0.031 -0.036 ];
0026 mriFID.sub{ 5} = 'c05';
0027 mriFID.xyz{ 5} = [ 0.010 0.094 -0.010; 0.075 0.024 -0.048; -0.072 0.024 -0.052 ];
0028 mriFID.sub{ 6} = 'c06';
0029 mriFID.xyz{ 6} = [ -0.002 0.088 0.000; 0.077 0.008 -0.048; -0.075 -0.008 -0.048 ];
0030 mriFID.sub{ 7} = 'c07';
0031 mriFID.xyz{ 7} = [ -0.001 0.097 -0.018; 0.078 0.008 -0.055; -0.076 0.008 -0.055 ];
0032 mriFID.sub{ 8} = 'c08';
0033 mriFID.xyz{ 8} = [ 0.000 0.096 -0.019; 0.087 0.005 -0.039; -0.065 0.004 -0.038 ];
0034 mriFID.sub{ 9} = 'c09';
0035 mriFID.xyz{ 9} = [ 0.010 0.086 -0.020; 0.100 -0.020 -0.080; -0.060 0.020 -0.058 ];
0036 mriFID.sub{10} = 'c10';
0037 mriFID.xyz{10} = [ 0.000 0.091 -0.018; 0.076 0.011 -0.052; -0.068 0.006 -0.052 ];
0038
0039 mriFID.sub{11} = 'p02';
0040 mriFID.xyz{11} = [ 0.002 0.091 0.016; 0.080 0.025 -0.036; -0.080 0.015 -0.043 ];
0041 mriFID.sub{12} = 'p04';
0042 mriFID.xyz{12} = [ -0.001 0.086 -0.009; 0.086 0.002 -0.062; -0.070 0.003 -0.065 ];
0043 mriFID.sub{13} = 'p05';
0044 mriFID.xyz{13} = [ -0.002 0.094 -0.001; 0.068 0.025 -0.040; -0.071 0.005 -0.042 ];
0045 mriFID.sub{14} = 'p06';
0046 mriFID.xyz{14} = [ -0.002 0.084 0.000; 0.082 0.013 -0.050; -0.066 0.013 -0.052 ];
0047 mriFID.sub{15} = 'p07';
0048 mriFID.xyz{15} = [ 0.001 0.092 0.015; 0.080 0.003 -0.033; -0.070 0.004 -0.032 ];
0049 mriFID.sub{16} = 'p08';
0050 mriFID.xyz{16} = [ -0.003 0.095 -0.002; 0.070 0.018 -0.040; -0.074 0.022 -0.035 ];
0051 mriFID.sub{17} = 'p09';
0052 mriFID.xyz{17} = [ -0.002 0.100 0.004; 0.100 0.002 -0.028; -0.050 0.000 -0.036 ];
0053
0054
0055
0056
0057
0058 data = 'd:\matlab\brainstorm_v1\subjects\';
0059
0060 cd(data);
0061
0062
0063 for s = {'c01','c02','c03','c04','c05','c06','c07','c08','c09','c10',...
0064 'p02', 'p04','p05','p06','p07','p08','p09'},
0065
0066 sub = sprintf('%s',char(s));
0067 cd(sub)
0068
0069 p = eeg_toolbox_defaults;
0070
0071
0072 p.mri.path = sprintf('d:\\freesurfer\\subjects\\ptsdpet-%s\\mri\\analyze\\',char(sub));
0073 p.mri.file = sprintf('%s_orig_axial_ras.img',char(sub));
0074 p.mri.plot = 0;
0075 p = mri_open(p);
0076
0077
0078
0079
0080 Nfid = strmatch(sub,mriFID.sub);
0081
0082
0083
0084 p.mriFID = [mriFID.xyz{Nfid} .* 1000 + 128; 128 128 128]';
0085
0086 PCS.R = eye(3);
0087 PCS.t = zeros(3,1);
0088 PCS.Comment = 'NEUROMAG';
0089 PCS.PCSFiducial(:,1) = p.mriFID(:,1);
0090 PCS.PCSFiducial(:,2) = p.mriFID(:,3);
0091 PCS.PCSFiducial(:,3) = p.mriFID(:,2);
0092 PCS.PCSFiducial(:,4) = p.mriFID(:,4);
0093 PCS.CubeFiducial = PCS.PCSFiducial;
0094 PCS.FiducialName = {'NAS' 'LPA' 'RPA' 'Origin'};
0095
0096
0097 p.mesh.path = sprintf('d:\\data_source\\%s\\meshes\\',char(sub));
0098 p.mesh.file = sprintf('%s_scalp.wfr',char(sub));
0099 p.mesh.type = 'emse';
0100 p = mesh_open(p);
0101
0102 Scalp = p.mesh.data.vertices{1}';
0103
0104
0105
0106
0107 if coregister,
0108
0109
0110 Nfid = strmatch(sub,mriFID.sub);
0111
0112 p.mriFID = mriFID.xyz{Nfid};
0113
0114
0115 p.elec.path = sprintf('d:\\data_source\\%s\\meshes\\',char(sub));
0116 p.elec.file = sprintf('%s_124fit.txt',char(sub));
0117 p.elec.plot = 0;
0118 p = elec_open(p);
0119
0120
0121 Efid = [p.elec.data.nasion; p.elec.data.rpa; p.elec.data.lpa];
0122
0123
0124 T = elec_coregister(Efid,p.mriFID);
0125
0126 PCS.R = T([1:3;1:3]);
0127 PCS.t = T(4,1:3);
0128 end
0129
0130 if elecplot,
0131 patch('vertices',p.mesh.data.vertices{1},'faces',p.mesh.data.faces{1},...
0132 'FaceColor',[1 0 0],'Edgecolor','none','FaceAlpha',.6);
0133 lighting phong, material dull, camlight headlight, hold on
0134
0135 p.elec.path = sprintf('d:\\matlab\\brainstorm_v1\\studies\\%s\\',char(sub));
0136 p.elec.file = sprintf('%s_channel.mat',char(sub));
0137 p.elec.type = 'brainstorm';
0138 p.elec.plot = 0;
0139 p = elec_open(p);
0140 plot3(p.elec.data.x,...
0141 p.elec.data.y,...
0142 p.elec.data.z,'bo')
0143 daspect([1 1 1]); axis tight
0144 mouse_rotate
0145 return
0146 end
0147
0148
0149
0150 Segment = [];
0151
0152 p.mri.data.fileprefix = sprintf('%s',char(sub));
0153 avw2brainstorm(p.mri.data,Segment,Scalp,PCS);
0154
0155 cd ..
0156
0157 end