@@ -518,9 +518,10 @@ def _iterate_trans_views(function, alpha, **kwargs):
518518
519519 try :
520520 try :
521- return _itv (function , fig , surfaces = { "head-dense" : alpha }, ** kwargs )
521+ return _itv (function , fig , ** kwargs )
522522 except OSError :
523- return _itv (function , fig , surfaces = {"head" : alpha }, ** kwargs )
523+ kwargs ["surfaces" ] = {"head" : alpha }
524+ return _itv (function , fig , ** kwargs )
524525 finally :
525526 backend ._close_3d_figure (fig )
526527
@@ -1597,9 +1598,10 @@ def add_trans(
15971598 subject = None ,
15981599 subjects_dir = None ,
15991600 alpha = None ,
1601+ coord_frame = "mri" ,
1602+ plot_kwargs = None ,
16001603 tags = ("coregistration" ,),
16011604 section = None ,
1602- coord_frame = "mri" ,
16031605 replace = False ,
16041606 ):
16051607 """Add a coregistration visualization to the report.
@@ -1625,13 +1627,23 @@ def add_trans(
16251627 alpha : float | None
16261628 The level of opacity to apply to the head surface. If a float, must
16271629 be between 0 and 1 (inclusive), where 1 means fully opaque. If
1628- ``None``, will use the MNE-Python default value.
1630+ ``None``, will use the MNE-Python default value. See also ``plot_kwargs``.
1631+ coord_frame : 'auto' | 'head' | 'meg' | 'mri'
1632+ Coordinate frame used for plotting. See :func:`mne.viz.plot_alignment`
1633+ and ``plot_kwargs``.
1634+ plot_kwargs : dict | None
1635+ Plotting arguments to be passed to :func:`mne.viz.plot_alignment`.
1636+ If ``alpha`` is not ``None``, it will override a potential
1637+ ``plot_kwargs["alpha"]``. The ``coord_frame`` key word argument always
1638+ overrides a potential ``plot_kwargs["coord_frame"]``. If ``None``,
1639+ this defaults to
1640+ ``dict(dig=True, meg=("helmet", "sensors"), show_axes=True)``.
1641+
1642+ .. versionadded:: 1.10
16291643 %(tags_report)s
16301644 %(section_report)s
16311645
16321646 .. versionadded:: 1.9
1633- coord_frame : 'auto' | 'head' | 'meg' | 'mri'
1634- Coordinate frame used for plotting. See :func:`mne.viz.plot_alignment`.
16351647 %(replace_report)s
16361648
16371649 Notes
@@ -1645,6 +1657,7 @@ def add_trans(
16451657 subject = subject ,
16461658 subjects_dir = subjects_dir ,
16471659 alpha = alpha ,
1660+ plot_kwargs = plot_kwargs ,
16481661 title = title ,
16491662 section = section ,
16501663 tags = tags ,
@@ -4220,6 +4233,7 @@ def _add_trans(
42204233 subject ,
42214234 subjects_dir ,
42224235 alpha ,
4236+ plot_kwargs ,
42234237 title ,
42244238 section ,
42254239 tags ,
@@ -4232,22 +4246,40 @@ def _add_trans(
42324246 if not isinstance (info , Info ):
42334247 info = read_info (info )
42344248
4235- kwargs = dict (
4236- info = info ,
4237- trans = trans ,
4238- subject = subject ,
4239- subjects_dir = subjects_dir ,
4240- dig = True ,
4241- meg = [ "helmet" , "sensors" ] ,
4242- show_axes = True ,
4243- coord_frame = coord_frame ,
4249+ plot_kwargs = _handle_default ( "report_coreg" , plot_kwargs )
4250+
4251+ plot_kwargs . update (
4252+ dict (
4253+ info = info ,
4254+ trans = trans ,
4255+ subject = subject ,
4256+ subjects_dir = subjects_dir ,
4257+ )
42444258 )
4259+
4260+ # This potentially overwrites information
4261+ plot_kwargs ["coord_frame" ] = coord_frame
4262+
4263+ if alpha is not None :
4264+ # if not available, fall back to plot_alignment default: 'auto'
4265+ surfaces = plot_kwargs .get ("surfaces" , "auto" )
4266+ if isinstance (surfaces , dict ):
4267+ surfaces = list (surfaces .keys ())
4268+ elif isinstance (surfaces , list ):
4269+ pass
4270+ elif isinstance (surfaces , str ) and surfaces != "auto" :
4271+ surfaces = [surfaces ]
4272+ else :
4273+ surfaces = ["head-dense" ] # "auto"
4274+
4275+ surfaces = {surf : alpha for surf in surfaces }
4276+
42454277 img , caption = _iterate_trans_views (
42464278 function = plot_alignment ,
42474279 alpha = alpha ,
42484280 max_width = self .img_max_width ,
42494281 max_res = self .img_max_res ,
4250- ** kwargs ,
4282+ ** plot_kwargs ,
42514283 )
42524284 self ._add_image (
42534285 img = img ,
0 commit comments