def get_segment_length(fs, resolution_shift=0):
    """
    Calculates a segment length such that the frequency resolution of the resulting analysis is in the region of
    ~1Hz subject to a lower limit of the number of samples in the signal.
    For example, if we have a 10s signal with an fs is 500 then we convert fs-1 to the number of bits required to
    hold this number in binary (i.e. 111110011 so 9 bits) and then do 1 << 9 which gives us 100000000 aka 512. Thus
    we have ~1Hz resolution.
    :param resolution_shift: shifts the resolution up or down by the specified number of bits.
    :return: the segment length.
    """
    return 1 << ((fs - 1).bit_length() - int(resolution_shift))