def get_num_channels(image5d):
    """Get the number of channels in a 5D image.

    Args:
        image5d (:obj:`np.ndarray`): Numpy arry in the order, `t,z,y,x[,c]`.

    Returns:
        int: Number of channels inferred based on the presence and length
        of the 5th dimension.

    """
    return 1 if image5d is None or image5d.ndim <= 4 else image5d.shape[4]