def test_assessor_full_object(self): with SanityChecks.__get_connection() as intf: assrobj1 = intf.select_assessor(proj_id, subj_id, sess_id, assr_id) csess = XnatUtils.CachedImageSession(intf, proj_id, subj_id, sess_id) cassr = filter(lambda x: x.label() == assr_id, csess.assessors())[0] assrobj2 = cassr.full_object() self.assertEqual(assrobj1.label(), assrobj2.label())
def test_scan_full_object(self): with SanityChecks.__get_connection() as intf: scanobj1 = intf.select_scan(proj_id, subj_id, sess_id, scan_id) csess = XnatUtils.CachedImageSession(intf, proj_id, subj_id, sess_id) cscan = filter(lambda x: x.label() == scan_id, csess.scans())[0] scanobj2 = cscan.full_object() self.assertEqual(scanobj1.label(), scanobj2.label())
def test_assessor_out_resources(self): with XnatUtils.get_interface(host=host) as intf: cisess = XnatUtils.CachedImageSession(intf, proj_id, subj_id, sess_id) for asr in cisess.assessors(): asrobj = intf.select_assessor(proj_id, subj_id, sess_id, asr.label()) print((asrobj.out_resources()))
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)
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)
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)
def get_cmds(self, assessor, job_dir_path): """ This function generates the spider command for the cluster job """ project = assessor.parent().parent().parent().label() subject = assessor.parent().parent().label() session = assessor.parent().label() csess = XnatUtils.CachedImageSession(assessor._intf, project, subject, session) xnat = XnatUtils.get_interface() scan = csess.scans()[0].label() scan_data = get_scan_resource_uri(xnat, project, subject, session, scan) cmd = csai_CMD.format(spider_path=self.spider_path, job_dir_path=job_dir_path, assessor_label=assessor.label(), project=project, subject=subject, session=session, scan_data=scan_data, suffix_proc=self.suffix_proc, matlab_utils=self.matlab_utils, matlab_bin=self.matlab_path) return [cmd]
def test_session_full_object(self): with SanityChecks.__get_connection() as intf: sessobj1 = intf.select_experiment(proj_id, subj_id, sess_id) sessobj2 = XnatUtils.CachedImageSession(intf, proj_id, subj_id, sess_id).full_object() self.assertEqual(sessobj1.label(), sessobj2.label())
""" Remove the flagfile to unlock the process :param lock_file: flag file use to lock the process :return: None """ if os.path.exists(lock_file): os.remove(lock_file) def check_dir(dir_path): try: os.makedirs(dir_path) except OSError: if not os.path.isdir(dir_path): raise if __name__ == '__main__': d = Module_baxter_redcap_sync(directory='/Users/yuqian', mod_name=DEFAULT_MODULE_NAME, text_report=DEFAULT_TEXT_REPORT, resources='STATS', proctypes='naleg-roi_v1') xnat = XnatUtils.get_interface("http://xnat.vanderbilt.edu:8080/xnat", "masispider", "xnatisawesome!!") csess = XnatUtils.CachedImageSession(xnat, 'IKIZLER', '133511', '133511') d.prerun() d.needs_run(csess, xnat) d.run(csess.info(), csess.full_object())