本文整理汇总了Python中dax.XnatUtils.list_sessions方法的典型用法代码示例。如果您正苦于以下问题:Python XnatUtils.list_sessions方法的具体用法?Python XnatUtils.list_sessions怎么用?Python XnatUtils.list_sessions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dax.XnatUtils
的用法示例。
在下文中一共展示了XnatUtils.list_sessions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_upload_demo_csv
# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import list_sessions [as 别名]
def create_upload_demo_csv():
"""
Generate csv file for demographic data
:return: list of string to write in a csv string for XnatDemographic
"""
csv_list = list()
# Read the xlsx file:
info_list = read_excel()
# subject_l = list()
for sess in XnatUtils.list_sessions(XNAT, 'prion'):
found, subject_dict = find_subject_date(info_list, sess['subject_label'], sess['date'].replace('-',''), 'Hospital ID')
if found:
print sess['session_label']
date = get_date(subject_dict['DOB'])
if 'AOS' in subject_dict.keys():
age = subject_dict['AOS']
else:
print subject_dict['Age']
age = subject_dict['Age']
csvstring = CSV_DEMOGRAPHIC.format(project="prion",
subject=sess['subject_label'],
session=sess['label'],
gender=subject_dict['Gender'],
yob=date[:4],
education=subject_dict['Education'],
genetic=subject_dict['Genetics'],
codon129=subject_dict['Codon 129'],
age=int(age),
geneticstate=subject_dict['state'],
MRC=subject_dict['MRC score'])
csv_list.append(csvstring)
"""if 'Date of first symptoms' in subject_dict.keys() and sess['subject_label'] not in subject_l:
print subject_dict['Date of first symptoms']
da = get_date(subject_dict['Date of first symptoms'])
csvstring = CSV_DEMOGRAPHIC2.format(project="prion",
subject=sess['subject_label'],
dos=da[:4]+'-'+da[4:6]+'-'+da[6:])
csv_list.append(csvstring)
subject_l.append(sess['subject_label'])"""
return csv_list
示例2: missing_data
# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import list_sessions [as 别名]
def missing_data():
"""
Check data between XNAT and Excel
:return: None
"""
#Read the xlsx files
info_list = read_excel()
subject_done = list()
for sess in XnatUtils.list_sessions(XNAT, 'prion'):
found, subject_dict = find_subject_date(info_list, sess['subject_label'], sess['date'].replace('-',''), 'Hospital ID')
if found and not sess['subject_label'] in subject_done:
subject_done.append(sess['subject_label'])
print "%s == %s " % (sess['subject_label'], subject_dict['Subject ID'])
for subject_dict in info_list:
subject = subject_dict['Hospital ID']
session = subject +'_'+ get_date(subject_dict['Date of scan'])
sess_obj = XnatUtils.select_obj(XNAT, 'prion', subject, session)
if not sess_obj.exists():
print '%s not found on XNAT. (%s)' % (session, subject_dict['Subject ID'])
示例3: print
# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import list_sessions [as 别名]
date = '{}-{}-{}'.format(date[:4], date[4:6], date[6:])
print("%s - %s" % (session_info['label'], date))
if session_info['date'] == date:
print ' already set up.'
else:
session_obj = XnatUtils.get_full_object(xnat, session_info)
session_obj.attrs.set('date', date)
if __name__ == '__main__':
ARGS = parse_args()
try:
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)
for session in XnatUtils.list_sessions(XNAT, ARGS.project):
edit_session_date(XNAT, session)
finally:
XNAT.disconnect()
示例4:
# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import list_sessions [as 别名]
print 'stop - wrong label'
continue
if labels[1].isdigit():
print 'stop - already good label'
continue
if '_' in labels[2]:
fin = '_'+'_'.join(labels[2].split('_')[1:])
labels[2] = labels[2].split('_')[0]
else:
fin = ''
new_labels = '%s-%s-%s%s' % (labels[0], labels[2],
labels[1], fin)
print subject['label'], new_labels
subj_obj.attrs.set('label', new_labels)
elif session_type:
for session in XnatUtils.list_sessions(xnat, projectid='INNOVATE'):
sess_obj = XnatUtils.get_full_object(xnat, session)
if sess_obj.exists():
labels = session['label'].split('-')
if session['label'] == 'INN-DCO-036':
labels[2] = labels[2] + '_20160615'
if session['label'].startswith('INN_'):
labels[0] = labels[0].replace('_', '-')
labels.append(labels[1])
labels[1] = labels[0].split('-')[1]
labels[0] = labels[0].split('-')[0]
if labels[1].isdigit():
print 'stop - already good label'
continue
if '_' in labels[2]:
fin = '_'+'_'.join(labels[2].split('_')[1:])
示例5: get_sessions_list
# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import list_sessions [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