当前位置: 首页>>代码示例>>Python>>正文


Python XnatUtils.filter_list_dicts_regex方法代码示例

本文整理汇总了Python中dax.XnatUtils.filter_list_dicts_regex方法的典型用法代码示例。如果您正苦于以下问题:Python XnatUtils.filter_list_dicts_regex方法的具体用法?Python XnatUtils.filter_list_dicts_regex怎么用?Python XnatUtils.filter_list_dicts_regex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dax.XnatUtils的用法示例。


在下文中一共展示了XnatUtils.filter_list_dicts_regex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parse_args

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import filter_list_dicts_regex [as 别名]
        print pixel_array2.min()

    ds.PixelData = pixel_array2.tostring()
    # Save the image
    ds.save_as(filename)

if __name__ == '__main__':
    args = parse_args()

    # Scans on XNAT:
    try:
        xnat = XnatUtils.get_interface()
        li_scans = XnatUtils.list_project_scans(xnat, args.project)
        # Filter:
        if args.sessions:
            li_scans = XnatUtils.filter_list_dicts_regex(
                           li_scans, 'session_label', args.sessions.split(','))
        if args.subjects:
            li_scans = XnatUtils.filter_list_dicts_regex(
                           li_scans, 'subject_label', args.subjects.split(','))
        li_scans = sorted(li_scans, key=lambda k: k['session_label'])
        for scan_d in li_scans:
            if scan_d['ID'] == 'n004':
                print (' -> converting session: %s /scan: %s'
                       % (scan_d['session_label'], scan_d['ID']))
                if 'IMG' in scan_d['resources']:
                    if 'NIFTI' not in scan_d['resources'] or args.force:
                        tmp_dir = os.path.join(args.directory,
                                               scan_d['session_label'],
                                               scan_d['ID'])
                        if not os.path.isdir(tmp_dir):
                            os.makedirs(tmp_dir)
开发者ID:byvernault,项目名称:scripts,代码行数:34,代码来源:fdf2dicom.py

示例2: sorted

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import filter_list_dicts_regex [as 别名]
from dax import XnatUtils
import os


if __name__ == "__main__":
    # Variables:
    project = 'DIAN'
    types = {'': 'PhoenixZIPReport'}

    with XnatUtils.get_interface(host=os.environ['DPUK']) as xnat:
        scans = XnatUtils.list_project_scans(xnat, project)
        scans = XnatUtils.filter_list_dicts_regex(scans, 'type', types.keys())
        for scan in sorted(scans, key=lambda k: k['session_label']):
            print "%s - %s - %s - %s" % (scan["session_label"],
                                         scan["ID"],
                                         scan["type"],
                                         scan["series_description"])
            scan_obj = XnatUtils.get_full_object(xnat, scan)
            scan_obj.attrs.set('type', types[scan['type']])
            print('   new type: {}'.format(types[scan['type']]))
开发者ID:byvernault,项目名称:scripts,代码行数:22,代码来源:renaming_type.py

示例3: xnat

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import filter_list_dicts_regex [as 别名]
            HOST = os.environ['XNAT_HOST']
        if ARGS.username:
            MSG = ("Please provide the password for user <%s> on xnat(%s):"
                   % (ARGS.username, HOST))
            PWD = getpass.getpass(prompt=MSG)
        else:
            PWD = None

        if not os.path.isdir(ARGS.tmpdir):
            os.makedirs(ARGS.tmpdir)
        print 'INFO: connection to xnat <%s>:' % (HOST)
        XNAT = XnatUtils.get_interface(host=ARGS.host, user=ARGS.username,
                                       pwd=PWD)
        li_assessors = XnatUtils.list_project_assessors(XNAT, ARGS.project)
        li_assessors = XnatUtils.filter_list_dicts_regex(
                                li_assessors, 'proctype',
                                ['GIF_Parcellation_v2'])
        li_assessors = XnatUtils.filter_list_dicts_regex(
                                li_assessors, 'procstatus',
                                ['COMPLETE'])
        li_assessors = filter(lambda x: 'WHOLEBRAIN' not in x['resources'],
                              li_assessors)
        li_assessors = sorted(li_assessors, key=lambda k: k['session_label'])
        start = False
        for assessor in li_assessors:
            if ARGS.session:
                if assessor['session_label'] == ARGS.session:
                    start = True
            else:
                start = True
            if start:
开发者ID:byvernault,项目名称:scripts,代码行数:33,代码来源:run_b_masking_whole.py

示例4: get_sessions_list

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import filter_list_dicts_regex [as 别名]
def get_sessions_list():
    """Extract sessions list from XNAT to be deleted."""
    li_sessions = XnatUtils.list_sessions(XNAT, OPTIONS.project)
    li_sessions = XnatUtils.filter_list_dicts_regex(
                    li_sessions, 'session_label', OPTIONS.sessions.split(','))
    return li_sessions
开发者ID:byvernault,项目名称:scripts,代码行数:8,代码来源:delete_sessions.py

示例5: xnat

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import filter_list_dicts_regex [as 别名]
        if ARGS.host:
            HOST = ARGS.host
        else:
            HOST = os.environ['XNAT_HOST']
        if ARGS.username:
            MSG = ("Please provide the password for user <%s> on xnat(%s):"
                   % (ARGS.username, HOST))
            PWD = getpass.getpass(prompt=MSG)
        else:
            PWD = None

        print 'INFO: connection to xnat <%s>:' % (HOST)
        XNAT = XnatUtils.get_interface(host=ARGS.host, user=ARGS.username,
                                       pwd=PWD)
        li_assessors = XnatUtils.list_project_assessors(XNAT, ARGS.project)
        li_assessors = XnatUtils.filter_list_dicts_regex(
                                li_assessors, 'proctype',
                                ARGS.proctype.split(','))
        li_assessors = XnatUtils.filter_list_dicts_regex(
                                li_assessors, 'procstatus',
                                ['COMPLETE'])
        li_assessors = sorted(li_assessors, key=lambda k: k['session_label'])
        for assessor in li_assessors:
            assessor_obj = XnatUtils.get_full_object(XNAT, assessor)
            if not assessor_obj.resource('PBS').exists():
                assessor_obj.resource('PBS').create()
                print 'Resource PBS added to %s.' % assessor['label']

    finally:
        XNAT.disconnect()
开发者ID:byvernault,项目名称:scripts,代码行数:32,代码来源:add_pbs_res.py

示例6: filter

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import filter_list_dicts_regex [as 别名]
import sys
from dax import XnatUtils


SCAN = 'T2 Axial'
HOST = 'https://prostate-xnat.cs.ucl.ac.uk'
PROJECT = 'PICTURE'
RESOURCE = 'OsiriX'
OLD_FILE = 'mantonelli_Unnamed.rois_series'
NEW_FILE = 'Mrishta_Unnamed.rois_series'
TMP_DIR = '/Users/byvernault/data/temp_roi_upgrade/'

with XnatUtils.get_interface(host=HOST) as xnat:

    li_scans = XnatUtils.list_project_scans(xnat, PROJECT)
    li_scans = XnatUtils.filter_list_dicts_regex(li_scans, 'type', SCAN)
    li_scans = filter(lambda x: RESOURCE in x['resources'], li_scans)
    sys.stdout.write('Renaming file %s to %s for scan type %s\n'
                     % (OLD_FILE, NEW_FILE, SCAN))

    for scan in li_scans:
        sys.stdout.write(' - scan: %s / %s ...\n'
                         % (scan['session_label'], scan['ID']))
        scan_obj = XnatUtils.get_full_object(xnat, scan)
        res_obj = scan_obj.resource(RESOURCE)
        files = None
        if res_obj.exists() and OLD_FILE in res_obj.files().get()[:]:

            # fpath = XnatUtils.download_file_from_obj(TMP_DIR, res_obj,
            #                                          fname=OLD_FILE)
            # if fpath:
开发者ID:byvernault,项目名称:scripts,代码行数:33,代码来源:rename_files.py


注:本文中的dax.XnatUtils.filter_list_dicts_regex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。