本文整理汇总了Python中dax.XnatUtils.select_obj方法的典型用法代码示例。如果您正苦于以下问题:Python XnatUtils.select_obj方法的具体用法?Python XnatUtils.select_obj怎么用?Python XnatUtils.select_obj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dax.XnatUtils
的用法示例。
在下文中一共展示了XnatUtils.select_obj方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pre_run
# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import select_obj [as 别名]
def pre_run(self):
"""Method to download data from XNAT.
:param argument_parse: argument parser object return by parse_args()
"""
# Make directory
input_folder = XnatUtils.makedir(os.path.join(self.jobdir, 'inputs'),
subdir=False)
# Download scans:
self.time_writer('Connection to XNAT')
xnat = XnatUtils.get_interface(host=self.host,
user=self.user,
pwd=self.pwd)
# Download NIFTIs
index = 1
for scan_id in self.scans_id:
scan_info = {}
scan_dir = XnatUtils.makedir(os.path.join(input_folder, scan_id),
subdir=False)
self.time_writer('Downloading scan ID %s ...' % scan_id)
scan = XnatUtils.select_obj(xnat,
self.xnat_project,
self.xnat_subject,
self.xnat_session,
scan_id)
snii_obj = scan.resource('NIFTI')
scan_info['4D'] = XnatUtils.download_file_from_obj(scan_dir,
snii_obj)
# Download DICOMs
sdcm_obj = scan.resource('DICOM')
self.time_writer('Downloading DICOM for scan ID %s ...'
% scan_id)
scan_info['dicom'] = XnatUtils.download_file_from_obj(scan_dir,
sdcm_obj)
scan_info['type'] = scan.attrs.get('type')
scan_info['ID'] = scan_id
if 'b3000' in scan_info['type'].lower() and \
len([o for o in self.acquisitions.get(index, list())
if 'b3000' in o['type'].lower()]) > 0:
index += 1
if index in self.acquisitions:
self.acquisitions[index].append(scan_info)
else:
self.acquisitions[index] = [scan_info]
xnat.disconnect()
self.time_writer('Disconnection of XNAT')
示例2: missing_data
# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import select_obj [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: pre_run
# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import select_obj [as 别名]
def pre_run(self):
"""Method to download data from XNAT.
:param argument_parse: argument parser object return by parse_args()
"""
# Make directory
input_folder = XnatUtils.makedir(os.path.join(self.jobdir, 'inputs'),
subdir=False)
# Target
target_folder = XnatUtils.makedir(os.path.join(input_folder,
ARGS.target_id),
subdir=False)
target_dcm = XnatUtils.makedir(os.path.join(target_folder, 'DICOM'),
subdir=False)
self.time_writer('Connection to XNAT')
xnat = XnatUtils.get_interface(host=self.host,
user=self.user,
pwd=self.pwd)
self.time_writer('Downloading target %s ...' % ARGS.target_id)
target_scan = XnatUtils.select_obj(xnat,
ARGS.proj_label,
ARGS.subj_label,
ARGS.sess_label,
ARGS.target_id)
tnii_obj = target_scan.resource('NIFTI')
self.target['nii'] = XnatUtils.download_file_from_obj(target_folder,
tnii_obj)
tdcm_obj = target_scan.resource('DICOM')
self.target['dcm'] = XnatUtils.download_files_from_obj(target_dcm,
tdcm_obj)
self.target['type'] = target_scan.attrs.get('type')
self.target['ID'] = ARGS.target_id
# Sources
sources_list = XnatUtils.get_input_list(ARGS.sources_id, list())
self.time_writer('Downloading sources %s ...' % sources_list)
for scan_id in sources_list:
# Make directories
spath = os.path.join(input_folder, scan_id)
source_folder = XnatUtils.makedir(spath, subdir=False)
dpath = os.path.join(source_folder, 'DICOM')
source_dcm = XnatUtils.makedir(dpath, subdir=False)
source_scan = XnatUtils.select_obj(xnat,
ARGS.proj_label,
ARGS.subj_label,
ARGS.sess_label,
scan_id)
snii_obj = source_scan.resource('NIFTI')
nii_list = XnatUtils.download_file_from_obj(source_folder,
snii_obj)
sdcm_obj = source_scan.resource('DICOM')
dcm_list = XnatUtils.download_file_from_obj(source_dcm, sdcm_obj)
self.sources[scan_id] = dict()
self.sources[scan_id]['nii'] = nii_list
self.sources[scan_id]['dcm'] = dcm_list
self.sources[scan_id]['type'] = source_scan.attrs.get('type')
self.sources[scan_id]['ID'] = scan_id
xnat.disconnect()
self.time_writer('Disconnection of XNAT')