<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Dear FieldTrip community,</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I am using the function ft_dipolefitting to retrieve the dipole position and moment from simulated EEG readings using my own forward solver (so I know the true solution).</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
First I created the raw data as follows:</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
raw = [];</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
raw.datatype = 'raw';</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
raw.time={zeros(1,Ntime_samples)};</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
raw.iseeg='yes';</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
raw.label=labels;</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
raw.chanunit='V';</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
raw.senstype='eeg';</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
raw.trial = {repmat(ElectrodeVoltages,1,Ntime_samples)};</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
<br>
</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
for i = 0:(Ntime_samples-1)</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
    raw.time{1}(i+1)=i/Ntime_samples;</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
end</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
<br>
</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
if ft_datatype(raw,'raw')</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
    disp("Raw data created succesfully.")</div>
<div class="elementToProof" style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
end</div>
<div class="elementToProof" style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Where ElectrodeVoltages is an N_electrodes x 1 vector with values in Volts (V).</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
After this is done I do the following:</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
disp("Dipole fit with real initial value")</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
cfg = [];</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
cfg.numdipoles = 1;</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
cfg.gridsearch = 'no';</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
cfg.headmodel = head_model;</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
cfg.dip.pos = dip0.dip.pos;</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
cfg.elec=elec;</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
<br>
</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
dip = ft_dipolefitting(cfg, raw);</div>
<div class="elementToProof" style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
disp("Dipole fit completed!")</div>
<div class="elementToProof" style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Here, dip0.dip is the original dipole, for which I have the position dip0.dip.pos and moment information dip0.dip.mom. In other words, I do a dipole fit with the true dipole position as the intial position. The head model is a 3-layer model with millimeter
 units (mm).</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Here is the structure that I get for dip.dip:</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
>> dip.dip</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
<br>
</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
ans = </div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
<br>
</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
  struct with fields:</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
<br>
</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
     pos: [-16.4780 -12.0334 47.4920]</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
     mom: [3×10 double]</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
     pot: [256×10 double]</div>
<div style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
      rv: [1.2740e-04 1.2740e-04 1.2740e-04 1.2740e-04 1.2740e-04 1.2740e-04 1.2740e-04 1.2740e-04 … ]</div>
<div class="elementToProof" style="font-family: Aptos Mono, Aptos_EmbeddedFont, Aptos_MSFontService, monospace; font-size: 10pt; color: rgb(102, 102, 102);">
    unit: 'mm'</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The distance and orientation of the fitted dipole are very close to the distance and orientation of the original dipole.</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Now, the issue is that the moment of my original dipole is Ampere times meter (A m). But I don't know how I should interpret the output dipole moment. The only clue is the field dip.dip.unit ('mm').</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
If the units are Amperes times millimeters (A mm), then the difference between both dipole moments is very large. However, if the units are milli Amperes times millimeter (mA m), then we have very good agreement.</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
How can I know what are the units of the output?</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thank you!</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Guillermo Nunez Ponasso</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Post-doc, Electrical Engineering. WPI</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
</body>
</html>