MCPcopy
hub / github.com/mne-tools/mne-python / _itv

Function _itv

mne/report/report.py:573–625  ·  view source on GitHub ↗
(function, fig, *, max_width=MAX_IMG_WIDTH, max_res=MAX_IMG_RES, **kwargs)

Source from the content-addressed store, hash-verified

571
572
573def _itv(function, fig, *, max_width=MAX_IMG_WIDTH, max_res=MAX_IMG_RES, **kwargs):
574 from ..viz.backends.renderer import MNE_3D_BACKEND_TESTING, backend
575
576 function(fig=fig, **kwargs)
577
578 views = (
579 "right_lateral",
580 "right_anterolateral",
581 "anterior",
582 "left_anterolateral",
583 "left_lateral",
584 "superior",
585 "right_posterolateral",
586 "posterior",
587 "left_posterolateral",
588 "inferior",
589 )
590
591 images = []
592 for view in views:
593 if not MNE_3D_BACKEND_TESTING:
594 set_3d_view(fig, **views_dicts["both"][view])
595 backend._check_3d_figure(fig)
596 im = backend._take_3d_screenshot(figure=fig)
597 else: # Testing mode
598 im = np.zeros((2, 2, 3))
599 images.append(im)
600
601 images = np.concatenate(
602 [np.concatenate(images[:5], axis=1), np.concatenate(images[5:], axis=1)], axis=0
603 )
604
605 if "info" in kwargs: # fwd/inv do not have dig points
606 try:
607 dists = dig_mri_distances(
608 info=kwargs["info"],
609 trans=kwargs["trans"],
610 subject=kwargs["subject"],
611 subjects_dir=kwargs["subjects_dir"],
612 on_defects="ignore",
613 )
614 caption = (
615 f"Average distance from {len(dists)} digitized points to "
616 f"head: {1e3 * np.mean(dists):.2f} mm"
617 )
618 except BaseException as e:
619 caption = "Distances could not be calculated from digitized points"
620 warn(f"{caption}: {e}")
621 else:
622 caption = None
623 img = _fig_to_img(images, image_format="png", max_width=max_width, max_res=max_res)
624
625 return img, caption
626
627
628def _plot_ica_properties_as_arrays(

Callers 2

_iterate_alignment_viewsFunction · 0.85
_iterate_trans_viewsFunction · 0.85

Calls 6

set_3d_viewFunction · 0.85
dig_mri_distancesFunction · 0.85
warnFunction · 0.85
_fig_to_imgFunction · 0.85
appendMethod · 0.45
meanMethod · 0.45

Tested by

no test coverage detected