Example #1
0
            value = type(value)
    return value


@app.callback([Output(prefix + 'csv_file_upload_output', 'children'), Output(prefix + 'csv_file_path', 'value')],
              [Input(prefix + 'csv_file_upload', 'filename')])
def update_output(csv_file, *args):
    if csv_file is None or len(csv_file) == 0:
        return '', ''
    return html.Span(children=csv_file), DOWNLOADS_PATH + csv_file


@app.callback(
    Output(prefix + 'results_container', 'children'),
    [Input(prefix + 'button', 'n_clicks')],
    gui_utils.get_states(parameters, False, prefix))
def run(n_clicks, *args):
    csv_file = get_state_field('csv_file_path', prefix=prefix, type=str)
    if csv_file == '':
        return []

    state_params = dash.callback_context.states
    # remove prefix and .value from
    params = {}
    for key in state_params:
        params[key.replace(prefix, '').replace('.value', '')] = state_params[key]
    time_series_orig = pd.read_csv(csv_file, parse_dates=True, index_col=[0])
    time_series = time_series_orig

    locations = pd.read_csv(csv_file.split('.')[0] + '-locations.csv', parse_dates=True, index_col=[0])
    res = two_step_regression_handler(time_series, 60, locations, csv_file)
Example #2
0
               "RespSupport": {"phrase": ("need respiratory support","needing"), "classifiers": (classifiers[12], classifiers[13])},
               }
to_use = {"positive test": ["Hosp", "IC1", "Outcome1"], "hospitalized": ["IC2", "RespSupport","Outcome2"],
          "intensive care": ["Outcome3"]}
translations = {"Hosp": "Hospitalization", "IC1": "Intensive Care", "IC2": "Intensive Care", "Outcome1": "Outcome",
                "Outcome2": "Outcome", "Outcome3": "Outcome","RespSupport": "Respiratory Support"}
age_mean= 48.026216
age_std = 24.804093

''' ==========================='''
''' ====== C: UPDATE GUI ====== '''
''' =========================== '''

app = dash.Dash(__name__, assets_folder = 'assets', include_assets_files = True) 

@app.callback(Output('result','children'),[Input('button','n_clicks')],gui_utils.get_states(parameters)) #[State('stage','value'),State('age','value'),State('gender','value'),State('comorbidities','value')])
def update_map(inp,*args):
    states = dash.callback_context.states
    print("states",states)
    if inp is None: return result
    stage = states['stage.value']
    age = (int(states['age.value']) - age_mean) / age_std
    gender = 0 if states['gender.value'] == "female" else 1
    data = [age, gender]
    sel_comorbidities = states['comorbidities.value']
    #################################################
    if stage == "hospitalized" or stage == "intensive care": data.append(1)
    if stage == "intensive care": data.append(1)
    for comorb in comorbidities:
        if comorb in sel_comorbidities: data.append(1)
        else: data.append(0)
Example #3
0
                                                      hidden=True)
        res.append(children)

    return res


@app.callback([
    Output(prefix + 'charts', 'children'),
    Output(prefix + 'biclusters', 'options'),
    Output(prefix + 'attributes', 'options'),
    Output(prefix + 'biclusters_cache', 'value'),
    Output(prefix + 'series_cache', 'value')
], [
    Input(prefix + 'button', 'n_clicks'),
    Input(prefix + 'attributes', 'value')
], gui_utils.get_states(parameters + get_all_method_params(), False, prefix))
def run_discovery(n_clicks, attributes, *args):
    attributes_opts = []
    if not n_clicks:
        return [[], default_biclusters_options, attributes_opts, '', '']

    trigger = dash.callback_context.triggered[0]
    data_cached = False
    if 'button' in trigger['prop_id']:
        attributes = None
    else:
        data_cached = True

    # Date range
    start_date = pd.to_datetime(get_state_field('date', 'start_date', prefix))
    end_date = pd.to_datetime(get_state_field('date', 'end_date', prefix))