<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hi Laura,
<div class=""><br class="">
</div>
<div class="">I’ll have to defer your question about <font face="SauceCodePowerline-Regular" class="">
sample</font>’s fiducials to the dev’s. There’s no file in the sample data, as you point out, and I’m not certain where such information get saved, if indeed they do. But you could always just use
<font face="SauceCodePowerline-Regular" class="">mne.gui.coregistration</font>; in your use case the precise locations on the MR won’t matter much.</div>
<div class=""><br class="">
</div>
<div class="">Yes, you’d first need to transform the standard montage coordinates to sample’s head frame. Following your option 1), you could generate MEG(head) -&gt; MRI, and EEG(no frame) -&gt; MRI, then invert the former and apply on the latter (montage -&gt; MRI
 -&gt; head; I haven’t tested this, but it might work…?). Then you’ll have to hack the EEG electrode coordinates in
<font face="SauceCodePowerline-Regular" class="">fake_info['chs’]</font>&nbsp;to match. Important elements to focus on are ‘<font face="SauceCodePowerline-Regular" class="">loc</font>’ and ‘<font face="SauceCodePowerline-Regular" class="">coord_frame</font>’, but
 Here be Dragons… I’m pretty sure neither linear algebra nor anatomy are the sticking points here, but certainly understanding how mne deals with sensor locations and transformations will be ;)</div>
<div class=""><br class="">
</div>
<div class="">I can’t send this without repeating (to posterity) that IMHO using a single-subject brain as a template for source reconstruction will not result in ‘localisations’ that are meaningful (they may be pretty, though). I would argue that the information
 that can be gleaned on spatial source distribution in a case like yours is fully contained in sensor-level topographies. Many would disagree ;) Good luck!</div>
<div class=""><br class="">
</div>
<div class="">/Chris</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On 27 Nov 2017, at 22.20, Laura Novelinkova &lt;<a href="mailto:l.novelinkova@gmail.com" class="">l.novelinkova@gmail.com</a>&gt; wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">Hi Chris,
<div class=""><br class="">
</div>
<div class="">thank you for replying.</div>
<div class=""><br class="">
</div>
<div class="">I want(ed) to use the 'sample' subject as my default brain because I already used it for the MEG data and wanted to do the same analysis on my EEG data and use the same source space. 'fsaverage' approach would have probably been more appropriate
 and I plan to go this route in future when I get my hands on a Linux machine. create_default_subject requires me to have freesurfer as far as I understood and my machine is not powerful enough to run a Freesurfer virtual machine. I could probably do the copying
 manually on Windows but I would rather do it normally once I have Linux.</div>
<div class=""><br class="">
</div>
<div class="">For now, I think, I want to stick to the 'sample' subject. So, I have two ways to proceed the way I see it:<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">1) Do two coregistrations of MEG and EEG montages writing down the coordinates of the fiducials on the first run so that the coregistrations are the same. I am not sure about this because in the mne's manual and elsewhere I read that it is not
 something that should be done by someone as inexperienced as I am.</div>
<div class=""><br class="">
</div>
<div class="">2) Find the information about fiducials somewhere in the sample's files. Use it to manually construct transformation,</div>
<div class=""><br class="">
</div>
<div class="">To me, the second route seems to be the better one because I am more familiar with linear algebra than anatomy. I am still not sure about what transformations are applied to what in&nbsp;mne though. When I ran mne.viz.plot_alignment with the sample
 data but with trans=None, nothing was co-aligned. Then I changed trans to&nbsp;<span style="color:rgb(0,128,128);font-weight:bold;font-family:&quot;Courier New&quot;;font-size:9pt" class="">'sample_audvis_raw-trans.<wbr class="">fif'.&nbsp;</span>As the result, source space and
 the head became co-aligned, but electrodes did not because, as you wrote, their coordinates are not in the head coordinate system as mne.viz.plot_alignment assumes.&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">So what I need is to transform the locations from the standard montage to the head coordinate system, for which I need the coordinate of fiducial points in that coordinate system.</div>
<div class=""><br class="">
</div>
I guess my question is this: does any of the sample's files contain the coordinates of the fiducials in the head coordinate system (or MRI) that were used during the construction of the inverse solution?
<div class="">
<div class="gmail_extra"><br class="">
<div class="gmail_quote">On Mon, Nov 27, 2017 at 5:12 PM, Christopher Bailey <span dir="ltr" class="">
&lt;<a href="mailto:cjb@cfin.au.dk" target="_blank" class="">cjb@cfin.au.dk</a>&gt;</span> wrote:<br class="">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div style="word-wrap:break-word" class="">Hi Laura,
<div class=""><br class="">
</div>
<div class="">Are you sure you want to use the `<font face="SauceCodePowerline-Regular" class="">sample</font>` subject as your anatomy? If you’re aiming at some sort of ‘template brain’ source localisation approach, would something like the ‘<font face="SauceCodePowerline-Regular" class="">fsaverage</font>’
 brain be more appropriate?</div>
<div class=""><br class="">
</div>
<div class="">The problem is that the transformation you load is between <font face="SauceCodePowerline-Regular" class="">
sample</font>’s fiducial head coordinates and <font face="SauceCodePowerline-Regular" class="">
sample</font>’s MRI. The default montage you load is however not in <font face="SauceCodePowerline-Regular" class="">
sample</font>’s head frame, so your coreg is off.&nbsp;</div>
<div class="">
<div class=""><br class="">
</div>
<div class="">For the&nbsp;<span style="font-family:SauceCodePowerline-Regular" class="">fsaverage</span>-approach, something like the following might work.
<b class="">NB: there’s a small bug that’s being fixed on github</b> (see [1]). You can either wait until it’s in master, or check out the fix yourself.</div>
<div class=""><br class="">
</div>
<div class="">[1](<a href="https://github.com/mne-tools/mne-python/issues/4783" target="_blank" class="">https://github.com/mne-too<wbr class="">ls/mne-python/issues/4783</a>)</div>
<div class=""><br class="">
</div>
<div class="">/Chris</div>
<div class=""><br class="">
</div>
<div class="">
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class="">subject = 'fsaverage'</font></div>
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class="">subjects_dir = '/Users/cjb/tmp/subs_dir’ &nbsp;# change appropriately</font></div>
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class="">mne.create_default_subject(sub<wbr class="">jects_dir=subjects_dir)</font></div>
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class=""><br class="">
</font></div>
<div class=""><span class="m_5984096326910013923gmail-">
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class="">montage_1005 = mne.channels.read_montage(kind<wbr class="">='standard_1005')</font></div>
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class="">fake_info = mne.create_info(ch_names=monta<wbr class="">ge_1005.ch_names, sfreq=1000, ch_types='eeg', montage=montage_1005)</font></div>
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class=""><br class="">
</font></div>
</span>
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class=""># need to write a file to load into coregistration, not possible to pass info directly</font></div>
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class="">fake_raw = mne.io.RawArray(np.zeros((len(<wbr class="">fake_info['ch_names']), 1)), fake_info)</font></div>
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class="">fake_raw.save('fake_raw.fif', overwrite=True)</font></div>
</div>
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class=""><br class="">
</font></div>
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class=""># coregister and save trans</font></div>
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class="">mne.gui.coregistration(inst='f<wbr class="">ake_raw.fif', subject=subject, subjects_dir=subjects_dir)</font></div>
</div>
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class=""><br class="">
</font></div>
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class="">trans = _path_to_saved_trans.fif_</font></div>
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class=""><br class="">
</font></div>
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class=""># set src=None, or calculate a source space, e.g.</font></div>
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class="">#&nbsp;</font><font face="SauceCodePowerline-Regular" class=""><span style="font-size:11px" class="">src = mne.setup_source_space(subject<wbr class="">, subjects_dir=subjects_dir,</span></font></div>
<font face="SauceCodePowerline-Regular" class=""><span style="font-size:11px" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;spacing='oct5’)</span></font></div>
<div class=""><font face="SauceCodePowerline-Regular" class=""><span style="font-size:11px" class=""><br class="">
</span></font>
<div class="">
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class="">mne.viz.plot_alignment(info=fa<wbr class="">ke_info, trans=trans, subject=subject, dig=True,</font></div>
<div class=""><font face="SauceCodePowerline-Regular" style="font-size:11px" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;meg=False, src=None, subjects_dir=subjects_dir)</font></div>
</div>
<div class=""><br class="">
</div>
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">
<div class="m_5984096326910013923gmail-h5">
<div class="">On 26 Nov 2017, at 13.05, Laura Novelinkova &lt;<a href="mailto:l.novelinkova@gmail.com" target="_blank" class="">l.novelinkova@gmail.com</a>&gt; wrote:</div>
<br class="m_5984096326910013923gmail-m_-7679087832512950130Apple-interchange-newline">
</div>
</div>
<div class="">
<div dir="ltr" class="">
<div class="">
<div class="m_5984096326910013923gmail-h5">Hello,
<div class=""><br class="">
</div>
<div class="">I am trying to create an EEG forward model using&nbsp;</div>
<div class="">
<ol class="">
<li class="">anatomy from the sample dataset&nbsp;</li><li class="">source space from&nbsp;<span style="color:rgb(0,128,128);font-weight:bold;font-family:&quot;Courier New&quot;;font-size:9pt" class="">sample_audvis-meg-oct-6-m<wbr class="">eg-inv.fif</span><br class="">
</li><li class="">standard 1005 montage</li></ol>
</div>
<div class="">When I check the consistency of the coordinate systems with&nbsp;<span style="font-family:&quot;Courier New&quot;;font-size:9pt" class="">plot_alignment,&nbsp;</span>I see that the electrode locations are off.&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">I think that I need to add transformation information to the info I make based off the standard montage. Am I right? If yes, could you please advise me what transformation should I use? And if no, what should I do instead?</div>
<div class=""><br class="">
</div>
<div class="">Any help will be greatly appreciated.</div>
<div class=""><br class="">
</div>
<div class="">Sincerely, Laura Novelinkova</div>
<div class=""><br class="">
</div>
<div class="">Additional info: I am on Windows 7, Python version is 2.7, mne version is 15, I run the code in iPython console. Below is my current code and the output of&nbsp;<span style="font-family:&quot;Courier New&quot;;font-size:12px" class="">plot_alignment</span>:</div>
</div>
</div>
<div class="">
<div class="">
<div class="m_5984096326910013923gmail-h5">
<pre style="font-family:&quot;Courier New&quot;;font-size:9pt" class=""><span style="color:rgb(0,0,128);font-weight:bold" class="">from </span>mayavi <span style="color:rgb(0,0,128);font-weight:bold" class="">import </span>mlab  <span style="color:rgb(128,128,128);font-style:italic" class=""># without this the windows show nothing and hang python<br class=""></span><span style="color:rgb(0,0,128);font-weight:bold" class="">import </span>mne<br class=""><span style="color:rgb(0,0,128);font-weight:bold" class="">from </span>mne.datasets <span style="color:rgb(0,0,128);font-weight:bold" class="">import </span>sample<br class=""><span style="color:rgb(0,0,128);font-weight:bold" class="">import </span>os<br class=""><br class="">%gui qt<br class=""><br class="">subject = <span style="color:rgb(0,128,128);font-weight:bold" class="">'sample'<br class=""></span>data_path = sample.data_path()<br class="">inverse_operator_file_path = os.path.join(data_path, <span style="color:rgb(0,128,128);font-weight:bold" class="">'MEG'</span>, <span style="color:rgb(0,128,128);font-weight:bold" class="">'sample'</span>, <span style="color:rgb(0,128,128);font-weight:bold" class="">'sample_audvis-meg-oct-6-meg-i<wbr class="">nv.fif'</span>)<br class="">subjects_dir = os.path.join(data_path, <span style="color:rgb(0,128,128);font-weight:bold" class="">'subjects'</span>)<br class=""><br class="">montage_1005 = mne.channels.read_montage(<span style="color:rgb(102,0,153)" class="">kind</span><wbr class="">=<span style="color:rgb(0,128,128);font-weight:bold" class="">'standard_1005'</span>)<br class="">fake_info = mne.create_info(<span style="color:rgb(102,0,153)" class="">ch_names</span>=monta<wbr class="">ge_1005.ch_names, <span style="color:rgb(102,0,153)" class="">sfreq</span>=<span style="color:rgb(0,0,255)" class="">1000</span>, <span style="color:rgb(102,0,153)" class="">ch_types</span>=<span style="color:rgb(0,128,128);font-weight:bold" class="">'eeg'</span>, <span style="color:rgb(102,0,153)" class="">montage</span>=montage_1005)<br class="">trans = os.path.join(data_path, <span style="color:rgb(0,128,128);font-weight:bold" class="">'MEG'</span>, <span style="color:rgb(0,128,128);font-weight:bold" class="">'sample'</span>, <span style="color:rgb(0,128,128);font-weight:bold" class="">'sample_audvis_raw-trans.fif'</span>)<br class="">source_space = mne.read_source_spaces(inverse<wbr class="">_operator_file_path)<br class=""><br class=""><br class="">mne.viz.plot_alignment(<span style="color:rgb(102,0,153)" class="">info</span>=fa<wbr class="">ke_info, <span style="color:rgb(102,0,153)" class="">trans</span>=trans, <span style="color:rgb(102,0,153)" class="">subject</span>=subject, <span style="color:rgb(102,0,153)" class="">dig</span>=<span style="color:rgb(0,0,128);font-weight:bold" class="">True</span>,<br class="">                       <span style="color:rgb(102,0,153)" class="">meg</span>=<span style="color:rgb(0,0,128);font-weight:bold" class="">False</span>, <span style="color:rgb(102,0,153)" class="">src</span>=source_space, <span style="color:rgb(102,0,153)" class="">subjects_dir</span>=subjects_dir)</pre>
<pre style="font-family:&quot;Courier New&quot;;font-size:9pt" class=""><br class=""></pre>
</div>
</div>
<pre style="font-family:&quot;Courier New&quot;;font-size:9pt" class=""><span id="m_5984096326910013923gmail-m_-7679087832512950130cid:ii_15ff8373de6ee475" class="">&lt;misaligned_electrodes.png&gt;</span><br class=""></pre>
</div>
</div>
<div id="m_5984096326910013923gmail-m_-7679087832512950130DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" class="">
<br class="">
<table style="border-top:1px solid rgb(211,212,222)" class="">
<tbody class="">
<tr class="">
<td style="width:55px;padding-top:13px" class=""><a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail&amp;utm_term=icon" target="_blank" class=""><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width:46px;height:29px" class=""></a></td>
<td style="width:470px;padding-top:12px;color:rgb(65,66,78);font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px" class="">
Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail&amp;utm_term=link" style="color:rgb(68,83,234)" target="_blank" class="">
www.avast.com</a> </td>
</tr>
</tbody>
</table>
<a width="1" height="1" class=""></a></div>
______________________________<wbr class="">_________________<br class="">
Mne_analysis mailing list<br class="">
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu" target="_blank" class="">Mne_analysis@nmr.mgh.harvard.e<wbr class="">du</a><br class="">
<a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis" target="_blank" class="">https://mail.nmr.mgh.harvard.e<wbr class="">du/mailman/listinfo/mne_analys<wbr class="">is</a><br class="">
<br class="">
<br class="">
The information in this e-mail is intended only for the person to whom it is<br class="">
addressed. If you believe this e-mail was sent to you in error and the e-mail<br class="">
contains patient information, please contact the Partners Compliance HelpLine at<br class="">
<a href="http://www.partners.org/complianceline" target="_blank" class="">http://www.partners.org/compli<wbr class="">anceline</a> . If the e-mail was sent to you in error<br class="">
but does not contain patient information, please contact the sender and properly<br class="">
dispose of the e-mail.<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
<br class="">
______________________________<wbr class="">_________________<br class="">
Mne_analysis mailing list<br class="">
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu" target="_blank" class="">Mne_analysis@nmr.mgh.harvard.e<wbr class="">du</a><br class="">
<a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis" rel="noreferrer" target="_blank" class="">https://mail.nmr.mgh.harvard.e<wbr class="">du/mailman/listinfo/mne_analys<wbr class="">is</a><br class="">
<br class="">
<br class="">
The information in this e-mail is intended only for the person to whom it is<br class="">
addressed. If you believe this e-mail was sent to you in error and the e-mail<br class="">
contains patient information, please contact the Partners Compliance HelpLine at<br class="">
<a href="http://www.partners.org/complianceline" rel="noreferrer" target="_blank" class="">http://www.partners.org/compli<wbr class="">anceline</a> . If the e-mail was sent to you in error<br class="">
but does not contain patient information, please contact the sender and properly<br class="">
dispose of the e-mail.<br class="">
<br class="">
</blockquote>
</div>
<br class="">
</div>
</div>
<div class="gmail_extra"><br class="">
</div>
</div>
_______________________________________________<br class="">
Mne_analysis mailing list<br class="">
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu" class="">Mne_analysis@nmr.mgh.harvard.edu</a><br class="">
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis<br class="">
<br class="">
<br class="">
The information in this e-mail is intended only for the person to whom it is<br class="">
addressed. If you believe this e-mail was sent to you in error and the e-mail<br class="">
contains patient information, please contact the Partners Compliance HelpLine at<br class="">
http://www.partners.org/complianceline . If the e-mail was sent to you in error<br class="">
but does not contain patient information, please contact the sender and properly<br class="">
dispose of the e-mail.<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>