Update source and controls with data loaded from selected directory

def callback_datadirs(attr, old, new):
    '''Update source and controls with data loaded from selected directory'''
    import os

    global data

    try:
        # Load data from new data directory
        path_dir = os.path.join(parent_input.value, new)
        data, params_tag, params_data = load_data(path_dir)

        # Make title with new data directory
        p.title.text = 'Calibrating {}'.format(params_tag['experiment'])

        # Update `source` data fields from dataframe
        dt_str = [dt.strftime(dt_fmt) for dt in data['datetimes']]
        source.data = dict(x      = list(data['acceleration_x']),
                           y      = list(data['acceleration_y']),
                           z      = list(data['acceleration_z']),
                           ind    = list(data.index),
                           dt     = list(data['datetimes']),
                           dt_str = dt_str)

        # Update values for control widgets
        param_checkbox.active = [0, 1, 2]
        param_select.options = params_data
        param_select.value = params_data[0]
        regions = ['lower', 'upper']
        region_select.options = regions
        region_select.value = regions[0]
        start_input.value = str(data.index[0])
        end_input.value = str(data.index[-1])
    except Exception as e:
        msg = '''
              Problem loading data directory `{}`.

              Please check that data exists in that directory.

              Details:
              {}
              '''.format(new, e)
        output_window.text = output_template.format(msg)


    return None