<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr"><p><span style="padding: 3px 10px; border-radius: 5px; color: #ffffff; font-weight: bold; display: inline-block; background-color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;External Email - Use Caution&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></p><p></p>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Hello,</p>
<p>I have mixed source estimates that I wish to morph to the fsaverage brain. To do so, I separated the mixed source estimates into a surface source estimate and a volume source estimate. When trying to morph the lastest (using morph_apply), I get the following
 error:</p>
<p><span style="color: rgb(255, 0, 0);">ValueError: vertices do not match between morph (453) and stc (216) for the volume:</span><br>
</p>
<p>(I believe there is a small mistake in morph_apply and what it means is actually that
<span>vertices do not match between morph (<b>216</b>) and stc (<b>453</b>) for the volume.)</span></p>
<p><br>
</p>
<p>Here is my code:</p>
<p></p>
<div>
<div><b>#recuperating volume source estimate from mixed source estimate stc<br>
</b>
<div><b>nb_sources_cortex&nbsp;=&nbsp;stc.vertices[0].shape[0]&nbsp;&#43;&nbsp;stc.vertices[1].shape[0]</b><b><br>
</b></div>
<div><b>vertices_vol&nbsp;=&nbsp;np.concatenate((stc.vertices[2],&nbsp;stc.vertices[3]))<br>
stc_volume&nbsp;=&nbsp;mne.VolSourceEstimate(stc.data[nb_sources_cortex:],&nbsp;vertices_vol,&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tmin=stc.tmin,&nbsp;tstep=stc.tstep,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;subject&nbsp;=&nbsp;subject_mri)</b></div>
<b>#Maybe not the cleanest way to isolate a volume source estimate from a mixed source estimate?<br>
</b>
<div><b><br>
#recuperating the source space I want to morph to</b><b><br>
</b></div>
<div><b>src_fsaverage_vol <span>= subjects_dir &#43; '/fsaverage/bem/fsaverage-vol-5-src.fif'</span><br>
</b></div>
</div>
<b>src_vol&nbsp;&nbsp;=&nbsp;mne.read_source_spaces(src_fsaverage_vol)</b></div>
<div><b><br>
</b></div>
<div><b>#recuperating the source space to morph from</b><b><br>
</b></div>
<div><b>cereb_used&nbsp;=&nbsp;mne.SourceSpaces(inverse_op['src'][2:])</b></div>
<div><b>#the source space <span>(<span>inverse_op['src'])</span></span></b><b> is made of 4 source spaces: 2 surface source spaces and 2 volume source spaces
<br>
</b></div>
<div><b>#- here I recuperate the 2 volume source spaces, made of 216 and 237 vertices (respectively)</b></div>
<div><b><br>
</b></div>
<div><b>morph&nbsp;=&nbsp;mne.compute_source_morph(src&nbsp;=&nbsp;cereb_used,&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb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sp;&nbsp;&nbsp;src_to=src_vol,&nbsp;verbose=True)</b></div>
<div><b><br>
</b></div>
<div><b>stc_vol&nbsp;=&nbsp;morph.apply(stc_vol)</b></div>
<b><br>
</b>
<p></p>
<p>I'm sorry that I cannot provide a replicable code.</p>
<p>I believe the error is coming from the fact that when computing the source morph, mne only considers the first of the two volume source spaces in cereb_used, hence generating a morph with 216 vertices instead of 216&#43;237 vertices, but I do not know how to
 fix it.</p>
<p>King regards,</p>
<p>Fleur<br>
</p>
</div>
</body>
</html>