def _segregate_NREM_runs(runs, min_separation):
    """
    Differentiate successive runs of NREM based on gap durations separating them.

    Stage 2 of detecting NREM cycles - minimum separation of successive runs

    Parameters
    ----------
    runs : pd.DataFrame
        Successive NREM runs with onsets and offsets, thresholded based on durations.
        Output of _detect_NREM_runs()
    min_separation : int or float, positive non-zero
        Minimum duration in minutes for thresholding gaps between consecutive NREM runs.

    Returns
    -------
    runs : pd.DataFrame
        Updated with NREM cycle numbers and gap from next run.

    """
    # Calculate gap or separation between successive runs
    runs["Next_Run"] = runs["Onset"].shift(-1) - runs["Offset"]

    # Specify filtering condition
    condition = runs["Next_Run"] > min_separation

    # Get numbered cycles based on condtion, starting from 1
    cycle_numbers = (1 + (condition).cumsum()).shift(fill_value=1)

    # Add a string identifier column
    runs["CYC"] = "CYC_" + (cycle_numbers).astype("str")

    return runs