def bbregplot(fixed_image, moving_image, contour, out_file='report.svg'):
    from nilearn.image import threshold_img, load_img, resample_img
    from niworkflows.viz.utils import plot_registration
    from niworkflows.viz.utils import cuts_from_bbox, compose_view
    import numpy as np
    fixed_image_nii = load_img(fixed_image)
    moving_image_nii = load_img(moving_image)
    moving_image_nii = resample_img(moving_image_nii, target_affine=np.eye(3), interpolation='nearest')
    contour_nii = (load_img(contour) if (contour is not None) else None)
    mask_nii = threshold_img(fixed_image_nii, 0.001)
    n_cuts = 7
    if contour_nii:
        cuts = cuts_from_bbox(contour_nii, cuts=n_cuts)
    else:
        cuts = cuts_from_bbox(mask_nii, cuts=n_cuts)
    compose_view(plot_registration(fixed_image_nii, 'fixed-image', estimate_brightness=True, cuts=cuts, label='fixed', contour=contour_nii, compress='auto'), plot_registration(moving_image_nii, 'moving-image', estimate_brightness=True, cuts=cuts, label='moving', contour=contour_nii, compress='auto'), out_file=out_file)
    return out_file
def bbregplot(fixed_image, moving_image, contour, out_file='report.svg'):
    from nilearn.image import threshold_img, load_img, resample_img
    from niworkflows.viz.utils import plot_registration
    from niworkflows.viz.utils import cuts_from_bbox, compose_view
    import numpy as np
    fixed_image_nii = load_img(fixed_image)
    moving_image_nii = load_img(moving_image)
    moving_image_nii = resample_img(moving_image_nii, target_affine=np.eye(3), interpolation='nearest')
    contour_nii = (load_img(contour) if (contour is not None) else None)
    mask_nii = threshold_img(fixed_image_nii, 0.001)
    n_cuts = 7
    if contour_nii:
        cuts = cuts_from_bbox(contour_nii, cuts=n_cuts)
    else:
        cuts = cuts_from_bbox(mask_nii, cuts=n_cuts)
    compose_view(plot_registration(fixed_image_nii, 'fixed-image', estimate_brightness=True, cuts=cuts, label='fixed', contour=contour_nii, compress='auto'), plot_registration(moving_image_nii, 'moving-image', estimate_brightness=True, cuts=cuts, label='moving', contour=contour_nii, compress='auto'), out_file=out_file)
    return out_file