def get_cmds(self, assessor, jobdir): """Method to generate the spider command for cluster job. :param assessor: pyxnat assessor object :param jobdir: jobdir where the job's output will be generated :return: command to execute the spider in the job script """ assessor_label = assessor.label() proj_label = assessor.parent().parent().parent().label() subj_label = assessor.parent().parent().label() sess_label = assessor.parent().label() csess = XnatUtils.CachedImageSession(assessor._intf, proj_label, subj_label, sess_label) gad_cscans = XnatUtils.get_good_cscans(csess, self.gad_type) gad = self.get_file_path(gad_cscans[0], SCAN_RESOURCE) vessels_cscans = XnatUtils.get_good_cscans(csess, self.vessels_type) vessels = self.get_file_path(vessels_cscans, SCAN_RESOURCE) vessel_ids = [ves.info()['ID'] for ves in vessels_cscans] cmd = SPIDER_FORMAT.format(spider=self.spider_path, assr=assessor_label, dir=jobdir, exe=self.exe, gad=','.join(gad), vessels=','.join(vessels), vesselsids=','.join(vessel_ids), number_core=self.ppn, working_dir=self.working_dir) return [cmd]
def has_inputs(self, csess): """Method overridden from base class. By definition: status = 0 -> NEED_INPUTS, status = 1 -> NEED_TO_RUN status = -1 -> NO_DATA qcstatus needs a value only when -1 or 0. You need to set qcstatus to a short string that explain why it's no ready to run. e.g: No NIFTI :param csess: object csess define in dax.XnatUtils (see XnatUtils in dax for information) :return: status, qcstatus """ gad_cscans = XnatUtils.get_good_cscans(csess, self.gad_type) if not gad_cscans: LOGGER.debug('Vessel Registration: No GAD scan found.') return -1, 'No GAD found' elif len(gad_cscans) > 1: LOGGER.debug('Vessel Registration: Too many GAD scans found.') return 0, 'Too many GAD found' vessels_cscans = XnatUtils.get_good_cscans(csess, self.vessels_type) if not vessels_cscans: LOGGER.debug('Vessel Registration: No Vessels scans found.') return -1, 'No Vessels found' return 1, None
def get_cmds(self, assessor, jobdir): """Method to generate the spider command for cluster job. :param assessor: pyxnat assessor object :param jobdir: jobdir where the job's output will be generated :return: command to execute the spider in the job script """ proj_label = assessor.parent().parent().parent().label() subj_label = assessor.parent().parent().label() sess_label = assessor.parent().label() csess = XnatUtils.CachedImageSession(assessor._intf, proj_label, subj_label, sess_label) target_cscans = XnatUtils.get_good_cscans(csess, self.target_type) target_id = target_cscans[0].info()['ID'] source_cscans = XnatUtils.get_good_cscans(csess, self.sources_type) sources_id = ','.join([sc.info()['ID'] for sc in source_cscans]) cmd = SPIDER_FORMAT.format(spider=self.spider_path, proj=proj_label, subj=subj_label, sess=sess_label, dir=jobdir, target=target_id, sources=sources_id, regaladin=self.regaladin, number_core=self.ppn, suffix_proc=self.suffix_proc) return [cmd]
def get_cmds(self, assessor, jobdir): """Method to generate the spider command for cluster job. :param assessor: pyxnat assessor object :param jobdir: jobdir where the job's output will be generated :return: command to execute the spider in the job script """ proj_label = assessor.parent().parent().parent().label() subj_label = assessor.parent().parent().label() sess_label = assessor.parent().label() assr_label = assessor.label() csess = XnatUtils.CachedImageSession(assessor._intf, proj_label, subj_label, sess_label) dti_cscans = XnatUtils.get_good_cscans(csess, self.dtitypes) dtis = ','.join([cscan.info()['ID'] for cscan in dti_cscans]) gif_cassrs = XnatUtils.get_good_cassr(csess, self.giftypes) working_dir = os.path.join(self.working_dir, assr_label) cmd = SPIDER_FORMAT.format(spider=self.spider_path, proj=proj_label, subj=subj_label, sess=sess_label, dir=jobdir, suffix_proc=self.suffix_proc, dti=dtis, gif=gif_cassrs[0].info()['label'], exe=self.exe, gif_path=self.exe_args, number_core=self.ppn, working_dir=working_dir) return [cmd]
def has_inputs(self, csess): """Method overridden from base class. By definition: status = 0 -> NEED_INPUTS, status = 1 -> NEED_TO_RUN status = -1 -> NO_DATA qcstatus needs a value only when -1 or 0. You need to set qcstatus to a short string that explain why it's no ready to run. e.g: No NIFTI :param csess: object csess define in dax.XnatUtils (see XnatUtils in dax for information) :return: status, qcstatus """ # Check that there is only one scan usable with the reference type and # that the reference file as a NIFTI verdict_cscans = XnatUtils.get_good_cscans(csess, self.modalities) if not verdict_cscans: LOGGER.debug('Processor_Registration_Verdict: \ cannot run at all, no VERDICT image found') return -1, 'VERDICT not found' for cscan in verdict_cscans: if not XnatUtils.has_resource(cscan, 'NIFTI'): LOGGER.debug('Processor_Registration_Verdict: \ cannot run, no NIFTI found for %s scan', cscan.info()['ID']) return 0, "Missing NIFTI" return 1, None
def has_inputs(self, csess): """Method overridden from base class. By definition: status = 0 -> NEED_INPUTS, status = 1 -> NEED_TO_RUN status = -1 -> NO_DATA qcstatus needs a value only when -1 or 0. You need to set qcstatus to a short string that explain why it's no ready to run. e.g: No NIFTI :param csess: object csess define in dax.XnatUtils (see XnatUtils in dax for information) :return: status, qcstatus """ # DTI: dti_cscans = XnatUtils.get_good_cscans(csess, self.dtitypes) if not dti_cscans: LOGGER.debug('Processor_Diffusion_Model_Fitting: \ cannot run at all, no DTI images found') return -1, 'DTI not found' for dti_cscan in dti_cscans: if not XnatUtils.has_resource(dti_cscan, 'NIFTI'): LOGGER.debug('Processor_Diffusion_Model_Fitting: cannot run, \ no NIFTI found for DTI image %s' % dti_cscan.info()['ID']) return 0, "no NIFTI for %s" % dti_cscan.info()['ID'] # T1: t1_cscans = XnatUtils.get_good_cscans(csess, self.t1types) if not t1_cscans: LOGGER.debug('Processor_Diffusion_Model_Fitting: \ cannot run at all, no T1 images found') return -1, 'T1 not found' # GIF: gif_cassrs = XnatUtils.get_good_cassr(csess, self.giftypes) if not gif_cassrs: LOGGER.debug('Processor_Diffusion_Model_Fitting: \ cannot run, no good GIF Parcellation found') return 0, 'good GIF not found' if len(gif_cassrs) > 1: LOGGER.debug('Processor_Diffusion_Model_Fitting: \ cannot run, no good GIF Parcellation found') return 0, 'too many good GIF' return 1, None
def get_usable_cscans(csess, stype): """ Get only the usable cscans for a csess. """ usable_cscans = list() cscans = XnatUtils.get_good_cscans(csess, stype) for cscan in cscans: if cscan.info()['quality'] == 'usable': usable_cscans.append(cscan) return usable_cscans
def has_inputs(self, csess): """Method overridden from base class. By definition: status = 0 -> NEED_INPUTS, status = 1 -> NEED_TO_RUN status = -1 -> NO_DATA qcstatus needs a value only when -1 or 0. You need to set qcstatus to a short string that explain why it's no ready to run. e.g: No NIFTI :param csess: object csess define in dax.XnatUtils (see XnatUtils in dax for information) :return: status, qcstatus """ # Check that there is only one scan usable with the reference type and # that the reference file as a NIFTI target_cscans = XnatUtils.get_good_cscans(csess, self.target) if not target_cscans: LOGGER.debug('Processor_Registration2Ref: \ cannot run at all, no T2 image found') return -1, 'T2 not found' if len(target_cscans) > 1: LOGGER.debug('Processor_Registration2Ref: \ cannot run at all, too many T2 images found') return 0, 'Too many T2 scans' if not XnatUtils.has_resource(target_cscans[0], 'NIFTI'): LOGGER.debug('Processor_Registration2Ref: \ cannot run, no NIFTI for T2 image') return 0, "no T2's NIFTI" source_cscans = XnatUtils.get_good_cscans(csess, self.sources) if not source_cscans: LOGGER.debug('Processor_Registration2Ref: \ cannot run at all, no ADC/DCE image found') return -1, 'ADC/DCE not found' for cscan in source_cscans: if not XnatUtils.has_resource(cscan, 'NIFTI'): LOGGER.debug('Processor_Registration2Ref: \ cannot run, no NIFTI found for %s scan', cscan.info()['ID']) return 0, "Missing NIFTI" return 1, None
def has_inputs(self, csess): """Method overridden from base class. By definition: status = 0 -> NEED_INPUTS, status = 1 -> NEED_TO_RUN status = -1 -> NO_DATA qcstatus needs a value only when -1 or 0. You need to set qcstatus to a short string that explain why it's no ready to run. e.g: No NIFTI :param csess: object csess define in dax.XnatUtils (see XnatUtils in dax for information) :return: status, qcstatus """ verdict_cscans = XnatUtils.get_good_cscans(csess, self.modalities) if not verdict_cscans: LOGGER.debug('Processor_Registration_Verdict: \ cannot run at all, no VERDICT image found') return -1, 'VERDICT not found' verdict_cassrs = list() for cassr in csess.assessors(): if XnatUtils.is_cassessor_good_type(cassr, [self.proctype]): verdict_cassrs.append(cassr) if not verdict_cassrs: LOGGER.debug('Processor_Compute_ADC_Verdict: \ cannot run, no good QA Registration VERDICT found') return 0, 'Registration missing' cassr = verdict_cassrs[0] LOGGER.debug('Processor_Compute_ADC_Verdict: \ good registration assessor found: %s', cassr.info()['label']) if not XnatUtils.has_resource(cassr, 'ACQ1'): LOGGER.debug('Processor_Compute_ADC_Verdict: \ cannot run, no ACQ resource found for %s assessor', cassr.info()['label']) return 0, "Missing ACQ#" return 1, None