Skip to content

Commit 722692e

Browse files
committed
second dipole object instead of heavy loop
1 parent 93be3a6 commit 722692e

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

tutorials/inverse/80_brainstorm_phantom_elekta.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
# %%
146146
# We can see that GOF varies between 50 and more than 95 %
147147
# variance explained for dipoles.
148-
# %%
148+
149149
# Estimated vs true dipole locations
150150
# -------------------------------
151151
# Finally, we compare the estimated to the true dipole locations.
@@ -190,7 +190,9 @@
190190
# of the estimated and true dipoles.
191191
actual_amp = np.ones(len(dip)) # fake amp, needed to create Dipole instance
192192
actual_gof = np.ones(len(dip)) # fake goodness-of-fit (GOF)
193+
# setup dipole objects for true and estimated dipoles
193194
dip_true = mne.Dipole(dip.times, actual_pos, actual_amp, actual_ori, actual_gof)
195+
dip_estimated = mne.Dipole(dip.times, dip_pos, dip_amplitude, dip_ori, actual_gof)
194196

195197
subject = "phantom_otaniemi"
196198
trans = mne.transforms.Transform("head", "mri", np.eye(4))
@@ -210,11 +212,10 @@
210212
fig = mne.viz.plot_dipole_locations(
211213
dipoles=dip_true, mode="arrow", subject=subject, color=(0.0, 0.0, 0.0), fig=fig
212214
)
213-
for dip in dip_all:
214-
# Plot the position and the orientation of the estimated dipole in green
215-
fig = mne.viz.plot_dipole_locations(
216-
dipoles=dip, mode="arrow", subject=subject, color=(0.2, 1.0, 0.5), fig=fig
217-
)
215+
# Plot the position and the orientation of the estimated dipole in green
216+
fig = mne.viz.plot_dipole_locations(
217+
dipoles=dip_estimated, mode="arrow", subject=subject, color=(0.2, 1.0, 0.5), fig=fig
218+
)
218219
mne.viz.set_3d_view(figure=fig, azimuth=70, elevation=80, distance=0.5)
219220
# %%
220221
# We can see that the dipoles overlap, have approximately the same magnitude

0 commit comments

Comments
 (0)