@staticmethod
def add_arguments(parser, diff=None, diff_ratio=None, diff_frames=None,
    diff_max_bins=None, positive_diffs=None):
    """
        Add spectrogram difference related arguments to an existing parser.

        Parameters
        ----------
        parser : argparse parser instance
            Existing argparse parser object.
        diff : bool, optional
            Take the difference of the spectrogram.
        diff_ratio : float, optional
            Calculate the difference to the frame at which the window used for
            the STFT yields this ratio of the maximum height.
        diff_frames : int, optional
            Calculate the difference to the `diff_frames`-th previous frame (if
            set, this overrides the value calculated from the `diff_ratio`)
        diff_max_bins : int, optional
            Apply a maximum filter with this width (in bins in frequency
            dimension) to the spectrogram the difference is calculated to.
        positive_diffs : bool, optional
            Keep only the positive differences, i.e. set all diff values < 0
            to 0.

        Returns
        -------
        argparse argument group
            Spectrogram difference argument parser group.

        Notes
        -----
        Parameters are included in the group only if they are not 'None'.

        Only the `diff_frames` parameter behaves differently, it is included
        if either the `diff_ratio` is set or a value != 'None' is given.

        """
    g = parser.add_argument_group('spectrogram difference arguments')
    if diff is True:
        g.add_argument('--no_diff', dest='diff', action='store_false', help
            ='use the spectrogram [default=differences of the spectrogram]')
    elif diff is False:
        g.add_argument('--diff', action='store_true', help=
            'use the differences of the spectrogram [default=spectrogram]')
    if diff_ratio is not None:
        g.add_argument('--diff_ratio', action='store', type=float, default=
            diff_ratio, help=
            'calculate the difference to the frame at which the window of the STFT have this ratio of the maximum height [default=%(default).1f]'
            )
    if diff_ratio is not None or diff_frames:
        g.add_argument('--diff_frames', action='store', type=int, default=
            diff_frames, help=
            'calculate the difference to the N-th previous frame (this overrides the value calculated with `diff_ratio`) [default=%(default)s]'
            )
    if positive_diffs is True:
        g.add_argument('--all_diffs', dest='positive_diffs', action=
            'store_false', help=
            'keep both positive and negative diffs [default=only the positive diffs]'
            )
    elif positive_diffs is False:
        g.add_argument('--positive_diffs', action='store_true', help=
            'keep only positive diffs [default=positive and negative diffs]')
    if diff_max_bins is not None:
        g.add_argument('--max_bins', action='store', type=int, dest=
            'diff_max_bins', default=diff_max_bins, help=
            'apply a maximum filter with this width (in frequency bins) [default=%(default)d]'
            )
    return g
