def compute(files, output_filename, thresholds, n_samples=1024):

    thresholds = thresholds.astype(float)

    data_stream = event_stream(files)
    # data_stream = trigger.fill_event_type(data_stream, flag=8)
    data_stream = filters.filter_event_types(data_stream,
                                             flags=CameraEventType.INTERNAL)
    data_stream = baseline.fill_baseline_r0(data_stream, n_bins=n_samples)
    data_stream = filters.filter_missing_baseline(data_stream)
    data_stream = trigger.fill_trigger_patch(data_stream)
    data_stream = trigger.fill_trigger_input_7(data_stream)
    data_stream = trigger.fill_trigger_input_19(data_stream)
    output = compute_bias_curve(
        data_stream,
        thresholds=thresholds,
    )

    rate, rate_error, cluster_rate, cluster_rate_error, thresholds, \
    start_event_id, end_event_id, start_event_time, end_event_time = output

    with fitsio.FITS(output_filename, mode='rw', clobber=True) as f:

        f.write([np.array([start_event_id, end_event_id]),
                 np.array([start_event_time, end_event_time])],
                extname='meta',
                names=['event_id', 'time'])
        f.write(thresholds, extname='threshold', compress='gzip')
        f.write([rate, rate_error], extname='camera', names=['rate', 'error'],
                compress='gzip')
        f.write([cluster_rate, cluster_rate_error], names=['rate', 'error'],
                extname='cluster',
                compress='gzip')

    return output