How to use the dax.utilities function in dax

To help you get started, we’ve selected a few dax examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github VUIIS / dax / bin / supplemental_tools / Xnatreport_assessor.py View on Github external
R = list()
for assr in Assrs :

    if assr.get('proctype') != proctype : continue

    #print(assr['assessor_label'])

    # Get desired fields
    thisR = {}
    for key in ('project_label','subject_label','session_label','proctype',
                'assessor_id','procstatus','qcstatus','assessor_label') :
        thisR[key] = assr[key]

    # Clean up the inputs field, split on / and keep the last bit
    inps = utilities.decode_url_json_string(assr['inputs'])
    #inps = json.loads(assr['inputs'].replace('"','"'))
    for key in inps.keys() :
        thisR[key] = inps[key].split('/')[-1]
    
    # We need to explicitly copy here to avoid overwriting R
    R.append(thisR.copy())


D = pandas.DataFrame(R)

# Reorder columns
colorder = ('project_label','subject_label','session_label','proctype',
            'assessor_id','procstatus','qcstatus')
oldcols = D.columns.tolist()
newcols = list()
for col in colorder :
github VUIIS / dax / dax / XnatUtils.py View on Github external
uri, method, body, headers, force_preemptive_auth,
                timeout=self.xnat_timeout, **kwargs)
        except (requests.Timeout, requests.ConnectionError):
            _err = traceback.format_exc()
            if self.timeout_email:
                LOGGER.warn('XNAT timeout, emailing admin')

                # email the exception
                _msg = '{}\n\n'.format(uri)
                _msg += 'ERROR:{}'.format(_err)
                _from = DAX_SETTINGS.get_smtp_from()
                _host = DAX_SETTINGS.get_smtp_host()
                _pass = DAX_SETTINGS.get_smtp_pass()
                _to = DAX_SETTINGS.get_admin_email().split(',')
                _subj = 'ERROR:XNAT timeout'
                utilities.send_email(_from, _host, _pass, _to, _subj, _msg)
            else:
                LOGGER.warn('XNAT timeout, email disabled', _err)

            # Retries
            for i in range(self.xnat_retries):
                # First we sleep
                LOGGER.debug('retry in {} secs'.format(self.xnat_wait))
                time.sleep(self.xnat_wait)

                # Then we try again
                LOGGER.debug('retry {} of {}'.format(
                    str(i + 1), str(self.xnat_retries)))
                LOGGER.debug('_exec:{}:{}'.format(method, uri))
                try:
                    result = super()._exec(
                        uri, method, body, headers, force_preemptive_auth,
github VUIIS / dax / bin / supplemental_tools / Xnatreport_assessors.py View on Github external
outfile2 = 'status_by_session_{}_{}.csv'.format(args.project,timestamp)

R = list()
for assr in Assrs :

    #print(assr['assessor_label'])

    # Get desired fields
    thisR = {}
    for key in ('project_label','subject_label','session_label','proctype',
            'assessor_id','procstatus','qcstatus','qcnotes','assessor_label') :
        thisR[key] = assr[key]

    # Clean up the inputs field, split on / and keep the last bit
    if assr['inputs']:
        inps = utilities.decode_url_json_string(assr['inputs'])
        for key in inps.keys():
            if isinstance(inps[key],list):
                thisR[key] = '(list)'
            else:
                thisR[key] = inps[key].split('/')[-1]
    
    # We need to explicitly copy here to avoid overwriting R
    R.append(thisR.copy())

D = pandas.DataFrame(R)

# Reorder columns
colorder = ('project_label','subject_label','session_label','proctype',
            'assessor_id','procstatus','qcstatus','qcnotes')
oldcols = D.columns.tolist()
newcols = list()
github VUIIS / dax / dax / XnatUtils.py View on Github external
def parse_assessor_inputs(inputs):
    try:
        if inputs == '':
            return None
        return utilities.decode_url_json_string(inputs)
    except IndexError:
        return None
github VUIIS / dax / dax / XnatUtils.py View on Github external
def get_files_in_folder(folder, label=''):
    """
    Recursively list all of the files in a folder

    :param folder: Full path of the folder to search
    :param label: Prefix to prepend to the file path (not sure why you would do
     this)
    :return: List of files in a folder

    """
    f_list = list()
    for fpath in os.listdir(folder):
        ffpath = os.path.join(folder, fpath)
        if os.path.isfile(ffpath):
            fpath = utilities.check_image_format(fpath)
            if label:
                filename = os.path.join(label, fpath)
            else:
                filename = fpath
            f_list.append(filename)
        else:
            label = os.path.join(label, fpath)
            f_list.extend(get_files_in_folder(ffpath, label))
    return f_list