def regularize_columns(df, mapping=None, snake_case=True):
    """
    Adjust the column names to use segyio / SEGY-SAK standard names.
    And optionally transform to snake case.
    """
    mapping = mapping or {'Inline': 'iline', 'inline': 'iline',
                          'Crossline': 'xline', 'crossline': 'xline',
                          'X': 'cdp_x', 'x': 'cdp_x',
                          'Y': 'cdp_y', 'y': 'cdp_y',
                          'Z': 'twt'}
    df = df.rename(columns=mapping)
    if snake_case:
        df.columns = [n.casefold().replace(' ', '_') for n in df.columns]
    return df