def have_same_affine(one_img, another_img, only_check_3d=False):
img1 = check_img(one_img)<EOL>img2 = check_img(another_img)<EOL>ndim1 = len(img1.shape)<EOL>ndim2 = len(img2.shape)<EOL>if ndim1 < <NUM_LIT:3>:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(repr_imgs(img1), ndim1))<EOL><DEDENT>if ndim2 < <NUM_LIT:3>:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(repr_imgs(img2), ndim1))<EOL><DEDENT>affine1 = img1.get_affine()<EOL>affine2 = img2.get_affine()<EOL>if only_check_3d:<EOL><INDENT>affine1 = affine1[:<NUM_LIT:3>, :<NUM_LIT:3>]<EOL>affine2 = affine2[:<NUM_LIT:3>, :<NUM_LIT:3>]<EOL><DEDENT>try:<EOL><INDENT>return np.allclose(affine1, affine2)<EOL><DEDENT>except ValueError:<EOL><INDENT>return False<EOL><DEDENT>except:<EOL><INDENT>raise<EOL><DEDENT>
Return True if the affine matrix of one_img is close to the affine matrix of another_img.
    False otherwise.

    Parameters
    ----------
    one_img: nibabel.Nifti1Image

    another_img: nibabel.Nifti1Image

    only_check_3d: bool
        If True will extract only the 3D part of the affine matrices when they have more dimensions.

    Returns
    -------
    bool

    Raises
    ------
    ValueError