Hi, <br><br>I've tried to make changes to the megplanar code in FieldTrip so that
it can be used for our Yokogawa (axial gradiometer) MEG system.  I was
wondering if anyone familar with the planar gradient approximation code in megplanar and/or the Yokogawa system could take a quick look at the changes  that I've made
and the results of simulations that I've done and see if they look
reasonable.<br>Output images generated by the simulation code (code pasted below) are at:<br><br><a href="http://clayspace.psych.nyu.edu/lab-members/sangita-dandekar/planarsims/" target="_blank">http://clayspace.psych.nyu.edu/lab-members/sangita-dandekar/planarsims/</a><br>


<br><br>The simulation just consisted of pointing dipoles along the major axes and getting planar approximations for every dipole orientation.  The output images are at the above link.<br><br>Also pasted below are changes to segments of the combineplanar and
planarchannelset functions that I made for the yokogawa system.  (The
only change that I ended up making in the original megplanar.m function
was to comment out the <br>
code that causes an error if the input data is from an MEG system other than the supported ones)<br><br>The original grad struct that I am using the for the unmodified axial gradiometer data for the yokogawa system looks like this:<br>


<br>ftdata.grad<br><br>ans = <br><br>      pnt: [314x3 double]<br>      ori: [314x3 double]<br>      tra: [157x314 double]<br>    label: {157x1 cell}<br>     unit: 'cm'<br><br>The
hope is that I can use the megplanar code (probably using the 'sincos'
method) to get the planar gradient approximation, then apply
freqanalysis to the horizontal and vertical components separately,  and
then finally recombine/sum the vertical and horizontal components using
combineplanar.  Any advice would be appreciated.<br><br>Thanks in advance for any help!<br>Sangita Dandekar<br><br>%*******Simulation code to produce axial and planar  x, y, and z images as shown at link above <br><br>cfg.grad=ftdata.grad<br>
cfg.dip.pos=[ftdata.grad.pnt(57,1)   ftdata.grad.pnt(57, 2)  ftdata.grad.pnt(57,3)-5]; %5 cm below lower coil of gradiometer 57<br><div>
cfg.dip.mom=[0 1 0]; %also varied to point along x ([1 0 0]) and z ([0 0 1])<br>cfg.vol.r=10;<br>cfg.vol.o=[mean(ftdata.grad.pnt(:,1)) mean(ftdata.grad.pnt(:,2)) mean(ftdata.grad.pnt(:,3))]<br>cfg.dip.signal=[ 1 1 1 ];<br>


data=dipolesimulation(cfg);<br>%get planar approximation:<br>cfg=[];<br>cfg.planarmethod='sincos';<br>cfg.channel=ftdata.grad.label;<br>[interp]=megplanar_yokogawa(cfg, data)<br>%recombine horizontal and vertical components:<br>
cfg=[];<br>cfg.combinegrad='yes';<br>cfg.combmethod='sum';<br>

[interpcomb]=combineplanar_yokogawa(cfg, interp)<br><br>figure;<br>cfgplot=[];<br>cfgplot.electrodes='numbers';<br>avg=timelockanalysis(cfgplot, interpcomb); %plot planar approximation<br>topoplotER(cfgplot, avg)<br>
<br><br>figure<br>avg=timelockanalysis(cfgplot, data);<br>

topoplotER(cfgplot, avg)<br>avg=timelockanalysis(cfgplot, data); %plot original axial gradiometer output<br>topoplotER(cfgplot, avg)<br><br><br>%*****************CHANGES TO COMBINEPLANAR (combineplanar_yokogawa.m):<br><br>
<br>if strcmp(cfg.combinegrad, 'no') && ~isfield(data, 'grad')<br>

  % the planar gradiometer definition was already removed<br>  % nothing needs to be done here<br>elseif strcmp(cfg.combinegrad, 'no') && isfield(data, 'grad')<br>  % remove the planar gradiometer definition since it does not match the data any more<br>


  data = rmfield(data, 'grad');<br>elseif strcmp(cfg.combinegrad, 'yes') && ~isfield(data, 'grad')<br>  % there is no gradiometer definition, impossible to reconstruct it<br>  error('the planar gradiometer definition is missing, cannot convert it back to axial');<br>


elseif strcmp(cfg.combinegrad, 'yes') && isfield(data, 'grad')<br>  warning('trying to convert planar to axial gradiometers, this is experimental');<br>  % try to reconstruct the original axial gradiometer array from the planar gradiometer definition<br>


  orig = data.grad<br>  <br>  if all(size(orig.pnt)==[314 3]) && ...<br>    all(size(orig.pnt)==[314 3]) && ...<br>    all(size(orig.tra)==[314 314]) && ...<br>    length(orig.label)==314 && ...<br>


    all(sum(orig.tra~=0,1)>2)<br>    % This looks as if it was made using the MEGPLANAR nearest neighbour approach<br>    % which means that the coil position and orientation still correspond<br>    % with those of the original axial gradiometer. Only the label and tra<br>


    % have been modified and have to be restored to their original values.<br>    axial.pnt = orig.pnt;<br>    axial.ori = orig.ori;<br>    for i=1:157<br>      axial.label{i} = orig.label{i}(1:(end-3));<br>    end<br>    if all(orig.ori(1,:)==orig.ori(158,:))<br>


      % orientation is the same, the subtraction should be in "tra"<br>      axial.tra = [eye(157) -eye(157)];<br>    else<br>      % orientation is opposite, the subtraction should not be in "tra"<br>


      axial.tra = [eye(157) eye(157)];<br>    end<br>    try<br>      axial.unit = orig.unit;<br>    end<br>  else<br>    error('cannot convert gradiometer definition back to axial, please contact Robert');<br>  end<br>


  data.grad = axial;<br>end<br><br><br><br>%*****************CHANGES TO PLANARCHANNELSET %(planarchannelset_yokogawa.m):**<br><br><br>case 'meg'<br>        <br>   planar={<br>       '1_dH'    '1_dV'    '1'<br>


    '2_dH'        '2_dV'    '2'<br>    '3_dH'        '3_dV'    '3'<br>    '4_dH'        '4_dV'    '4'<br>    '5_dH'        '5_dV'    '5'<br>


    '6_dH'        '6_dV'    '6'<br>    '7_dH'        '7_dV'    '7'<br>    '8_dH'        '8_dV'    '8'<br>    '9_dH'        '9_dV'    '9'<br>


    '10_dH'        '10_dV'    '10'<br>    '11_dH'        '11_dV'    '11'<br>    '12_dH'        '12_dV'    '12'<br>    '13_dH'        '13_dV'    '13'<br>


    '14_dH'        '14_dV'    '14'<br>    '15_dH'        '15_dV'    '15'<br>    '16_dH'        '16_dV'    '16'<br>    '17_dH'        '17_dV'    '17'<br>


    '18_dH'        '18_dV'    '18'<br>    '19_dH'        '19_dV'    '19'<br>    '20_dH'        '20_dV'    '20'<br>    '21_dH'        '21_dV'    '21'<br>


    '22_dH'        '22_dV'    '22'<br>    '23_dH'        '23_dV'    '23'<br>    '24_dH'        '24_dV'    '24'<br>    '25_dH'        '25_dV'    '25'<br>


    '26_dH'        '26_dV'    '26'<br>    '27_dH'        '27_dV'    '27'<br>    '28_dH'        '28_dV'    '28'<br>    '29_dH'        '29_dV'    '29'<br>


    '30_dH'        '30_dV'    '30'<br>    '31_dH'        '31_dV'    '31'<br>    '32_dH'        '32_dV'    '32'<br>    '33_dH'        '33_dV'    '33'<br>


    '34_dH'        '34_dV'    '34'<br>    '35_dH'        '35_dV'    '35'<br>    '36_dH'        '36_dV'    '36'<br>    '37_dH'        '37_dV'    '37'<br>


    '38_dH'        '38_dV'    '38'<br>    '39_dH'        '39_dV'    '39'<br>    '40_dH'        '40_dV'    '40'<br>    '41_dH'        '41_dV'    '41'<br>


    '42_dH'        '42_dV'    '42'<br>    '43_dH'        '43_dV'    '43'<br>    '44_dH'        '44_dV'    '44'<br>    '45_dH'        '45_dV'    '45'<br>


    '46_dH'        '46_dV'    '46'<br>    '47_dH'        '47_dV'    '47'<br>    '48_dH'        '48_dV'    '48'<br>    '49_dH'        '49_dV'    '49'<br>


    '50_dH'        '50_dV'    '50'<br>    '51_dH'        '51_dV'    '51'<br>    '52_dH'        '52_dV'    '52'<br>    '53_dH'        '53_dV'    '53'<br>


    '54_dH'        '54_dV'    '54'<br>    '55_dH'        '55_dV'    '55'<br>    '56_dH'        '56_dV'    '56'<br>    '57_dH'        '57_dV'    '57'<br>


    '58_dH'        '58_dV'    '58'<br>    '59_dH'        '59_dV'    '59'<br>    '60_dH'        '60_dV'    '60'<br>    '61_dH'        '61_dV'    '61'<br>


    '62_dH'        '62_dV'    '62'<br>    '63_dH'        '63_dV'    '63'<br>    '64_dH'        '64_dV'    '64'<br>    '65_dH'        '65_dV'    '65'<br>


    '66_dH'        '66_dV'    '66'<br>    '67_dH'        '67_dV'    '67'<br>    '68_dH'        '68_dV'    '68'<br>    '69_dH'        '69_dV'    '69'<br>


    '70_dH'        '70_dV'    '70'<br>    '71_dH'        '71_dV'    '71'<br>    '72_dH'        '72_dV'    '72'<br>    '73_dH'        '73_dV'    '73'<br>


    '74_dH'        '74_dV'    '74'<br>    '75_dH'        '75_dV'    '75'<br>    '76_dH'        '76_dV'    '76'<br>    '77_dH'        '77_dV'    '77'<br>


    '78_dH'        '78_dV'    '78'<br>    '79_dH'        '79_dV'    '79'<br>    '80_dH'        '80_dV'    '80'<br>    '81_dH'        '81_dV'    '81'<br>


    '82_dH'        '82_dV'    '82'<br>    '83_dH'        '83_dV'    '83'<br>    '84_dH'        '84_dV'    '84'<br>    '85_dH'        '85_dV'    '85'<br>


    '86_dH'        '86_dV'    '86'<br>    '87_dH'        '87_dV'    '87'<br>    '88_dH'        '88_dV'    '88'<br>    '89_dH'        '89_dV'    '89'<br>


    '90_dH'        '90_dV'    '90'<br>    '91_dH'        '91_dV'    '91'<br>    '92_dH'        '92_dV'    '92'<br>    '93_dH'        '93_dV'    '93'<br>


    '94_dH'        '94_dV'    '94'<br>    '95_dH'        '95_dV'    '95'<br>    '96_dH'        '96_dV'    '96'<br>    '97_dH'        '97_dV'    '97'<br>


    '98_dH'        '98_dV'    '98'<br>    '99_dH'        '99_dV'    '99'<br>    '100_dH'        '100_dV'    '100'<br>    '101_dH'        '101_dV'    '101'<br>


    '102_dH'        '102_dV'    '102'<br>    '103_dH'        '103_dV'    '103'<br>    '104_dH'        '104_dV'    '104'<br>    '105_dH'        '105_dV'    '105'<br>


    '106_dH'        '106_dV'    '106'<br>    '107_dH'        '107_dV'    '107'<br>    '108_dH'        '108_dV'    '108'<br>    '109_dH'        '109_dV'    '109'<br>


    '110_dH'        '110_dV'    '110'<br>    '111_dH'        '111_dV'    '111'<br>    '112_dH'        '112_dV'    '112'<br>    '113_dH'        '113_dV'    '113'<br>


    '114_dH'        '114_dV'    '114'<br>    '115_dH'        '115_dV'    '115'<br>    '116_dH'        '116_dV'    '116'<br>    '117_dH'        '117_dV'    '117'<br>


    '118_dH'        '118_dV'    '118'<br>    '119_dH'        '119_dV'    '119'<br>    '120_dH'        '120_dV'    '120'<br>    '121_dH'        '121_dV'    '121'<br>


    '122_dH'        '122_dV'    '122'<br>    '123_dH'        '123_dV'    '123'<br>    '124_dH'        '124_dV'    '124'<br>    '125_dH'        '125_dV'    '125'<br>


    '126_dH'        '126_dV'    '126'<br>    '127_dH'        '127_dV'    '127'<br>    '128_dH'        '128_dV'    '128'<br>    '129_dH'        '129_dV'    '129'<br>


    '130_dH'        '130_dV'    '130'<br>    '131_dH'        '131_dV'    '131'<br>    '132_dH'        '132_dV'    '132'<br>    '133_dH'        '133_dV'    '133'<br>


    '134_dH'        '134_dV'    '134'<br>    '135_dH'        '135_dV'    '135'<br>    '136_dH'        '136_dV'    '136'<br>    '137_dH'        '137_dV'    '137'<br>


    '138_dH'        '138_dV'    '138'<br>    '139_dH'        '139_dV'    '139'<br>    '140_dH'        '140_dV'    '140'<br>    '141_dH'        '141_dV'    '141'<br>


    '142_dH'        '142_dV'    '142'<br>    '143_dH'        '143_dV'    '143'<br>    '144_dH'        '144_dV'    '144'<br>    '145_dH'        '145_dV'    '145'<br>


    '146_dH'        '146_dV'    '146'<br>    '147_dH'        '147_dV'    '147'<br>    '148_dH'        '148_dV'    '148'<br>    '149_dH'        '149_dV'    '149'<br>


    '150_dH'        '150_dV'    '150'<br>    '151_dH'        '151_dV'    '151'<br>    '152_dH'        '152_dV'    '152'<br>    '153_dH'        '153_dV'    '153'<br>


    '154_dH'        '154_dV'    '154'<br>    '155_dH'        '155_dV'    '155'<br>    '156_dH'        '156_dV'    '156'<br>    '157_dH'        '157_dV'    '157'<br>


   <br>   <br>   };<br>    </div>
<p>----------------------------------</p>
<p>The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis.</p>
<p>  http://listserv.surfnet.nl/archives/fieldtrip.html</p>
<p>  http://www.ru.nl/fcdonders/fieldtrip/</p>