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


Python XnatUtils.select_obj方法代码示例

本文整理汇总了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')
开发者ID:byvernault,项目名称:ucl_processing,代码行数:53,代码来源:Spider_Registration_Verdict_v1_0_0.py

示例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'])
开发者ID:byvernault,项目名称:scripts,代码行数:24,代码来源:generate_csv_prion.py

示例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')
开发者ID:byvernault,项目名称:ucl_processing,代码行数:63,代码来源:Spider_Registration_Prostate_v1_0_0.py


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