예제 #1
0
def update_all(selected_proc, selected_scan, selected_sess, selected_proj,
               selected_time, selected_groupby, n_clicks):
    refresh = False

    logging.debug('update_all')

    # Load our data
    # This data will already be merged scans and assessors with
    # a row per scan or assessor
    ctx = dash.callback_context
    if was_triggered(ctx, 'button-qa-refresh'):
        # Refresh data if refresh button clicked
        logging.debug('refresh:clicks={}'.format(n_clicks))
        refresh = True

    logging.debug('loading data')
    #df = load_data(
    #    proj_filter=selected_proj,
    #    proc_filter=selected_proc,
    #    scan_filter=selected_scan,
    #    refresh=refresh)
    df = load_data(refresh=refresh)

    # Update lists of possible options for dropdowns (could have changed)
    # make these lists before we filter what to display
    proj = utils.make_options(load_proj_options())
    scan = utils.make_options(load_scan_options(selected_proj))
    sess = utils.make_options(load_sess_options(selected_proj))
    proc = utils.make_options(load_proc_options(selected_proj))

    # Filter data based on dropdown values
    df = data.filter_data(df, selected_proj, selected_proc, selected_scan,
                          selected_time, selected_sess)

    # Get the qa pivot from the filtered data
    dfp = qa_pivot(df)

    tabs = get_graph_content(dfp, selected_groupby)

    # Get the table data
    selected_cols = ['SESSION', 'PROJECT', 'DATE', 'SESSTYPE', 'SITE']

    if selected_proc:
        selected_cols += selected_proc

    if selected_scan:
        selected_cols += selected_scan

    columns = utils.make_columns(selected_cols)
    records = dfp.reset_index().to_dict('records')

    # TODO: should we only include data for selected columns here,
    # to reduce amount of data sent?

    # Return table, figure, dropdown options
    logging.debug('update_all:returning data')
    return [proc, scan, sess, proj, records, columns, tabs]
예제 #2
0
def update_stats(selected_proc, selected_proj, selected_time,
                 selected_sesstype, n_clicks):
    refresh = False

    logging.debug('update_all')

    # Load our data
    # This data will already be merged scans and assessors with
    # a row per scan or assessor
    ctx = dash.callback_context
    if was_triggered(ctx, 'button-stats-refresh'):
        # Refresh data if refresh button clicked
        logging.debug('refresh:clicks={}'.format(n_clicks))
        refresh = True

    # Load data with refresh if requested
    df = load_stats(refresh=refresh)

    # Update lists of possible options for dropdowns (could have changed)
    # make these lists before we filter what to display
    proc = utils.make_options(df.TYPE.unique())
    proj = utils.make_options(df.PROJECT.unique())

    # if none chose, default to the first proc
    #if not selected_proc:
    #    selected_proc = [(df.TYPE.unique())[0]]
    #    if 'fmri_msit_v2' in df.TYPE.unique():
    #        selected_proc = ['fmri_msit_v2']

    # Filter data based on dropdown values
    df = data.filter_data(df, selected_proj, selected_proc, selected_time,
                          selected_sesstype)

    # Get the graph content in tabs (currently only one tab)
    tabs = get_graph_content(df)

    # Determine columns to be included in the table
    _vars = data.get_vars()
    selected_cols = list(data.static_columns())
    selected_cols.extend(
        [x for x in df.columns if (x in _vars and not pd.isnull(df[x]).all())])

    # Get the table data
    columns = utils.make_columns(selected_cols)
    records = df.reset_index().to_dict('records')

    # Return table, figure, dropdown options
    logging.debug('update_all:returning data')
    return [proc, proj, records, columns, tabs]
예제 #3
0
	def __init__(self, width=600, height=300, plugins=(),
				 toolbars=u_settings.DEFAULT_TOOLBARS,
				 file_path='', image_path='', scrawl_path='',
				 image_manager_path='', css='',
				 options={}, attrs=None, **kwargs):
		self.ueditor_options = make_options(width, height, plugins, toolbars,
											file_path, image_path, scrawl_path,
											image_manager_path, css, options)
		super(UEditorWidget, self).__init__(attrs)
예제 #4
0
 def __init__(self, width=600, height=300, plugins=(),
              toolbars=u_settings.DEFAULT_TOOLBARS,
              file_path='', image_path='', scrawl_path='',
              image_manager_path='', css='',
              options={}, attrs=None, **kwargs):
     self.ueditor_options = make_options(width, height, plugins, toolbars,
                                         file_path, image_path, scrawl_path,
                                         image_manager_path, css, options)
     super(UEditorWidget, self).__init__(attrs)
예제 #5
0
def update_activity(
    selected_category,
    selected_project,
    selected_source,
    n_clicks
):
    refresh = False

    logging.debug('update_activity')

    # Load activity data
    ctx = dash.callback_context
    if was_triggered(ctx, 'button-activity-refresh'):
        # Refresh data if refresh button clicked
        logging.debug('activity refresh:clicks={}'.format(n_clicks))
        refresh = True

    logging.debug('loading activity data')
    df = load_activity(refresh=refresh)

    # Update lists of possible options for dropdowns (could have changed)
    # make these lists before we filter what to display
    projects = utils.make_options(load_project_options())
    categories = utils.make_options(load_category_options())
    sources = utils.make_options(load_source_options())

    # Filter data based on dropdown values
    df = filter_data(
        df,
        selected_project,
        selected_category,
        selected_source)

    tabs = get_graph_content(df)

    # Get the table data
    selected_cols = ['ID', 'DATETIME', 'DESCRIPTION']
    columns = utils.make_columns(selected_cols)
    records = df.reset_index().to_dict('records')

    # Return table, figure, dropdown options
    logging.debug('update_activity:returning data')

    return [categories, projects, sources, records, columns, tabs]
예제 #6
0
    def __init__(self, verbose_name, width=600, height=300,
                 plugins=(), toolbars='normal', file_path='',
                 image_path='', scrawl_path='', image_manager_path='',
                 css='', options={}, **kwargs):
        self.ueditor_options = make_options(width, height, plugins, toolbars,
                                            file_path, image_path, scrawl_path,
                                            image_manager_path, css, options)
        kwargs["verbose_name"] = verbose_name

        super(UEditorField, self).__init__(**kwargs)
예제 #7
0
    def __init__(self, label, width=600, height=300, plugins=(),
                 toolbars=u_settings.DEFAULT_TOOLBARS, file_path='',
                 image_path='', scrawl_path='', image_manager_path='',
                 css='', options={}, *args, **kwargs):
        options = make_options(width, height, plugins, toolbars,
                               file_path, image_path, scrawl_path,
                               image_manager_path, css, options)

        kwargs['widget'] = UEditorWidget(**options)
        kwargs['label'] = label

        super(UEditorField, self).__init__(*args, **kwargs)
예제 #8
0
    def __init__(self,
                 label,
                 width=600,
                 height=300,
                 plugins=(),
                 toolbars=u_settings.DEFAULT_TOOLBARS,
                 file_path='',
                 image_path='',
                 scrawl_path='',
                 image_manager_path='',
                 css='',
                 options={},
                 *args,
                 **kwargs):
        options = make_options(width, height, plugins, toolbars, file_path,
                               image_path, scrawl_path, image_manager_path,
                               css, options)

        kwargs['widget'] = UEditorWidget(**options)
        kwargs['label'] = label

        super(UEditorField, self).__init__(*args, **kwargs)
예제 #9
0
파일: gui.py 프로젝트: bud42/dax-dashboard
def update_stats(
    selected_proc,
    selected_proj,
    selected_time,
    selected_pivot,
    n_clicks
):
    refresh = False

    logging.debug('update_all')

    # Load our data
    # This data will already be merged scans and assessors with
    # a row per scan or assessor
    ctx = dash.callback_context
    if was_triggered(ctx, 'button-stats-refresh'):
        # Refresh data if refresh button clicked
        logging.debug('refresh:clicks={}'.format(n_clicks))
        refresh = True

    # Load data with refresh if requested
    df = load_stats(refresh=refresh)

    # Update lists of possible options for dropdowns (could have changed)
    # make these lists before we filter what to display
    proc = utils.make_options(df.TYPE.unique())
    proj = utils.make_options(df.PROJECT.unique())

    # Filter data based on dropdown values
    selected_sesstype = 'all'
    df = data.filter_data(
        df,
        selected_proj,
        selected_proc,
        selected_time,
        selected_sesstype)

    # Get the graph content in tabs (currently only one tab)
    tabs = get_graph_content(df)

    # TODO: handle multiple of same type for a subject?
    if selected_pivot == 'subj':
        # Pivot to one row per subject

        _index = ['SUBJECT', 'PROJECT', 'AGE', 'SEX', 'DEPRESS', 'SITE']

        _vars = data.get_vars()

        _vars = [x for x in df.columns if (
            x in _vars and not pd.isnull(df[x]).all())]

        _cols = []
        if len(df.SESSTYPE.unique()) > 1:
            # Multiple session types, need prefix to disambiguate
            _cols += ['SESSTYPE']
        if len(df.TYPE.unique()) > 1:
            # Multiple processing types, need prefix to disambiguate
            _cols += ['TYPE']

        # Drop any duplicates found b/c redcap sync module does not prevent
        df = df.drop_duplicates()

        # Make the pivot table based on _index, _cols, _vars
        #print(_index)
        #print(_cols)
        #print(_vars)
        #print(df)
        dfp = df.pivot(index=_index, columns=_cols, values=_vars)

        # Concatenate column levels to get one level with delimiter
        dfp.columns = ['_'.join(reversed(t)) for t in dfp.columns]

        # Clear the index so all columns are named
        dfp = dfp.reset_index()

        columns = utils.make_columns(dfp.columns)
        records = dfp.to_dict('records')
    else:
        # Keep as to one row per assessor

        # Determine columns to be included in the table
        selected_cols = list(data.static_columns())
        _vars = data.get_vars()
        _vars = [x for x in df.columns if (
            x in _vars and not pd.isnull(df[x]).all())]
        selected_cols.extend(_vars)

        # Get the table data as one row per assessor
        columns = utils.make_columns(selected_cols)
        records = df.reset_index().to_dict('records')

    # Count how many rows are in the table
    rowcount = '{} rows'.format(len(records))

    # Return table, figure, dropdown options
    logging.debug('update_all:returning data')
    return [proc, proj, records, columns, tabs, rowcount]