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


Python XnatUtils.get_interface方法代码示例

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


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

示例1: test_setup_old_assessors

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import get_interface [as 别名]
    def test_setup_old_assessors(self):
        intf = XnatUtils.get_interface(host)
        proj_id = 'proj1'
        subj_id = 'subj1'
        sess_ids = ['sess2', 'sess1']

        project = intf.select_project(proj_id)
        if not project.exists():
            self.assertTrue(False, 'proj1 should be pre-created for this test')

        subject = intf.select_subject(proj_id, subj_id)
        if not subject.exists():
            self.assertTrue(False, 'subj1 should be pre-created for this test')

        for s in sess_ids:
            session = intf.select_experiment(proj_id, subj_id, s)
            if not session.exists():
                self.assertTrue(False, 'sess1 should be pre-created for this test')

            # delete and recreate scans
            scan_descriptors = [('1', 't1'), ('2', 't1'), ('11', 'flair')]
            ComponentTestBuild._setup_scans(session, scan_descriptors)

            # delete and recreate old assessors
            ComponentTestBuild._setup_assessors(proj_id, subj_id, session)
开发者ID:VUIIS,项目名称:dax,代码行数:27,代码来源:component_test_build.py

示例2: copy_inputs

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import get_interface [as 别名]
 def copy_inputs(self):
     self.run_inputs = self.src_inputs
 
     for _input in self.copy_list:
         src = self.src_inputs[_input]
         if src.startswith('xnat://'):
             src = src[len('xnat:/'):]
             _res, _file = src.split('/files/')
             dst = os.path.join(self.input_dir, _file)
             print('DEBUG:downloading from XNAT:'+src+' to '+dst)
             try:
                 xnat = XnatUtils.get_interface(self.host, self.user, self.pwd)
                 res = xnat.select(_res)
                 result = res.file(_file).get(dst)
             except:
                 print('ERROR:downloading from XNAT')
                 return
         else:
             dst = os.path.join(self.input_dir, os.path.basename(src))
             print('DEBUG:copying src:'+src+' to '+dst)
             copyfile(src, dst)
         
         self.run_inputs[_input] = dst
         
     return self.run_inputs
开发者ID:VUIIS,项目名称:VUIIS_DAX_SUPPORT,代码行数:27,代码来源:spiders.py

示例3: pre_run

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import get_interface [as 别名]
    def pre_run(self):
        """Method to download data from XNAT.

        :param argument_parse: argument parser object return by parse_args()
        """
        resource = 'ACQ'  # resource to download from the scan on XNAT
        folder = os.path.join(self.jobdir, 'inputs')
        os.makedirs(folder)
        assessor_label = '-x-'.join([self.xnat_project,
                                     self.xnat_subject,
                                     self.xnat_session,
                                     self.proctype])

        xnat = XnatUtils.get_interface()
        a = xnat.select('/projects/%s/subjects/%s/experiments/%s/assessors/%s'
                        % (self.xnat_project, self.xnat_subject,
                           self.xnat_session, assessor_label))

        for nb_acq in range(1, self.nb_acquisition+1):
            res_name = '%s%d' % (resource, nb_acq)
            self.time_writer('Download resource: %s' % res_name)
            file_gzip = XnatUtils.download_file_from_obj(
                                  folder, a.out_resource(res_name))
            self.time_writer('Unzip file: %s' % file_gzip)
            XnatUtils.gunzip_file(file_gzip)
            self.inputs[nb_acq] = file_gzip[:-3]

        sc = XnatUtils.get_good_scans(a.parent(), DICOM_SCAN_TYPE)[0]
        dcm_file = XnatUtils.download_file_from_obj(
                              folder, sc.resource('DICOM'))
        self.inputs['dcm'] = dcm_file
        xnat.disconnect()
开发者ID:byvernault,项目名称:ucl_processing,代码行数:34,代码来源:Spider_Verdict_v1_0_1.py

示例4: prerun

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import get_interface [as 别名]
    def prerun(self, settings_filename=''):
        """ prerun function overridden from base-class """
        LOGGER.info('loading XNAT...')
        self.xnat = XnatUtils.get_interface()

        LOGGER.info('loading REDCap...')
        self.load_redcap()

        LOGGER.info('checking Projects of Prearchive Scans..')
        self.load_prearchive()
        self.check_projects()

        LOGGER.info('do archiving...')
        self.load_prearchive()
        self.do_archiving()

        LOGGER.info('crosscheck redcap...')
        self.crosscheck_redcap()

        self.xnat.disconnect()

        if self.send_an_email:
            LOGGER.info('sending email with report of errors')
            self.send_report()

        LOGGER.info('DONE')
开发者ID:byvernault,项目名称:ucl_processing,代码行数:28,代码来源:Module_Auto_Archive.py

示例5: test_xnat_get_full_object

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import get_interface [as 别名]
    def test_xnat_get_full_object(self):
        with XnatUtils.get_interface(host=host) as intf:
            intf.connect()

            print(map(lambda x: x['name'], intf.get_projects()))

            print(map(lambda x: x['label'], intf.get_subjects(proj_id)))

            subj = intf.select(XnatUtils.InterfaceTemp.S_XPATH.format(project=proj_id, subject=subj_id))
            print(subj.label())
            print(subj.parent().label())
开发者ID:VUIIS,项目名称:dax,代码行数:13,代码来源:component_test_xnatutils.py

示例6: test_xnat_parse_session

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import get_interface [as 别名]
    def test_xnat_parse_session(self):
        with XnatUtils.get_interface(host=host) as intf:
            intf.connect()

            SanityChecks.__prep_project(intf)

            yamldoc = YamlDoc().from_string(yamls.proc_a)
            csess = XnatUtils.CachedImageSession(
                intf, proj_id, subj_id, sess_id)

            ap = AutoProcessor(XnatUtils, yamldoc)
            ap.parse_session(ap)
开发者ID:VUIIS,项目名称:dax,代码行数:14,代码来源:component_test_xnatutils.py

示例7: pre_run

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import get_interface [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

示例8: test_clean_scans_from_test_session

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import get_interface [as 别名]
    def test_clean_scans_from_test_session(self):
        proj_id = 'proj1'
        subj_id = 'subj1'
        sess_ids = ['sess1', 'sess2']
        # subj_id = 'subj2'
        # sess_ids = ['sess3', 'sess4']
        intf = XnatUtils.get_interface(host=host)
        for sess_id in sess_ids:
            session = intf.select_experiment(proj_id, subj_id, sess_id)
            if not session.exists():
                self.assertTrue(False, "no such session")

            for scn in session.scans():
                scn.delete()
开发者ID:VUIIS,项目名称:dax,代码行数:16,代码来源:component_test_build.py

示例9: get_voxel_size

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import get_interface [as 别名]
    def get_voxel_size(self):
        """Method to get the voxel size from XNAT if define using default value if not.

        :return: voxel size [x, y, z]
        """
        xnat = XnatUtils.get_interface(host=self.host,
                                       user=self.user,
                                       pwd=self.pwd)
        scan_obj = self.select_obj(xnat, self.xnat_scan, None)
        vsize = scan_obj.attrs.mget(['xnat:mrScanData/parameters/voxelRes/x',
                                     'xnat:mrScanData/parameters/voxelRes/y',
                                     'xnat:mrScanData/parameters/voxelRes/z'])
        xnat.disconnect()
        return vsize
开发者ID:byvernault,项目名称:ucl_processing,代码行数:16,代码来源:Spider_Vessel_Extraction_v1_0_0.py

示例10: test_setup_session

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import get_interface [as 别名]
    def test_setup_session(self):
        proj_id = 'proj1'
        subj_id = 'subj1'
        sess_ids = ['sess1', 'sess2']
        intf = XnatUtils.get_interface(host=host)
        scan_descriptors = [('1', 't1'), ('2', 't1'),
                 ('11', 'flair'), ('12', 'flair'),
                 ('21', 't2')]
        for sess_id in sess_ids:
            session = intf.select_experiment(proj_id, subj_id, sess_id)
            if not session.exists():
                self.assertTrue(False, "no such session")

            ComponentTestBuild._setup_scans(session, scan_descriptors)
开发者ID:VUIIS,项目名称:dax,代码行数:16,代码来源:component_test_build.py

示例11: test_clean_assessors_from_test_session

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import get_interface [as 别名]
    def test_clean_assessors_from_test_session(self):
        proj_id = 'proj1'
        subj_id = 'subj1'
        sess_ids = ['sess1', 'sess2']
        # subj_id = 'subj2'
        # sess_ids = ['sess3', 'sess4']
        intf = XnatUtils.get_interface(host=host)
        for sess_id in sess_ids:
            session = intf.select_experiment(proj_id, subj_id, sess_id)
            if not session.exists():
                self.assertTrue(False, "no such session")

            for asr in session.assessors():
                print assessor_utils.full_label_from_assessor(asr)
                asr.delete()
开发者ID:VUIIS,项目名称:dax,代码行数:17,代码来源:component_test_build.py

示例12: test_xnat_has_inputs

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import get_interface [as 别名]
    def test_xnat_has_inputs(self):
        with XnatUtils.get_interface(host=host) as intf:
            intf.connect()

            print yamls.proc_a
            SanityChecks.__prep_project(intf)

            yamldoc = YamlDoc().from_string(yamls.proc_a)
            ap = AutoProcessor(XnatUtils, yamldoc)
            csess = XnatUtils.CachedImageSession(
                intf, proj_id, subj_id, sess_id)

            results = []
            for cassr in csess.assessors():
                has, errors = ap.has_inputs(cassr)
                results.append((has, errors))

            print results
开发者ID:VUIIS,项目名称:dax,代码行数:20,代码来源:component_test_xnatutils.py

示例13: upload_data

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import get_interface [as 别名]
def upload_data(args):
    """
    Main function to upload data.

    :param args: arguments from argparser
    """
    biomarkers_info = XnatUtils.read_csv(args.csv_file)

    if args.host:
        host = args.host
    else:
        host = os.environ['XNAT_HOST']

    with XnatUtils.get_interface(host=host, user=args.username) as xnat:
        print('INFO: connection to xnat <%s>:' % (host))
        print('INFO: setting information to XNAT')

        for biomarker_dict in biomarkers_info:
            # Create
            create_biomarker(xnat, biomarker_dict)
开发者ID:byvernault,项目名称:scripts,代码行数:22,代码来源:upload_wet_biomarkers.py

示例14: test_create_assessor_with_no_input

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import get_interface [as 别名]
    def test_create_assessor_with_no_input(self):
        with XnatUtils.get_interface(host=host) as intf:
            intf.connect()

            e = intf.select_experiment(proj_id, subj_id, sess_id)
            if not e.exists():
                self.assertTrue(
                    False,
                    "Unexpected: {}//{}//{} does not exist".format(
                        proj_id, subj_id, sess_id
                    ))

            proc_a_params = {
                'xsitype': asrxsitype,
                'proctype': 'Proc_A_v1',
                'files': [
                    ('SEG', ['seg.gz'])
                ]
            }
            SessionTools.add_assessor(e,
                                      'proc1-x-subj1-x-sess1-x-2-Proc_A_v1',
                                      proc_a_params,
                                      'no_inputs')
开发者ID:VUIIS,项目名称:dax,代码行数:25,代码来源:component_test_xnatutils.py

示例15: test_xnat_get_cached_image_session

# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import get_interface [as 别名]
    def test_xnat_get_cached_image_session(self):
        with XnatUtils.get_interface(host=host) as intf:

            cisess = XnatUtils.CachedImageSession(intf, proj_id, subj_id, sess_id)
            print(cisess)
            print(cisess.info())
            for ciscan in cisess.scans():
                print(ciscan.info())
                scanobj = ciscan.full_object()
                print(scanobj)
            for ciassr in cisess.assessors():
                print(ciassr.info())
                for cirsrc in ciassr.out_resources():
                    print(cirsrc.info())
                    asrinfo = ciassr.info()
                    rsrcobj = intf.select_assessor_resource(asrinfo['project_id'],
                                                            asrinfo['subject_id'],
                                                            asrinfo['session_id'],
                                                            asrinfo['assessor_label'],
                                                            cirsrc.info()['label'])
                    print(rsrcobj)
            sessobj = cisess.full_object()
            print(sessobj)
开发者ID:VUIIS,项目名称:dax,代码行数:25,代码来源:component_test_xnatutils.py


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