def needs_run(self, cscan, xnat):
        """ needs_run function overridden from base-class
                cscan = CacheScan object from XnatUtils
            return True or False
        """
        scan_info = cscan.info()
        if XnatUtils.has_resource(cscan, 'SNAPSHOTS'):
            LOGGER.debug('Has snapshot')
            return False

        if not XnatUtils.has_resource(cscan, self.resourcename):
            LOGGER.warn('Preview NIFTI -- '+scan_info['scan_id']+' -- no '+self.resourcename+' resource')
            return False

        return True
    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()

        nb_acq = 1
        csess = XnatUtils.CachedImageSession(assessor._intf, proj_label,
                                             subj_label, sess_label)
        reg_verdict = ''
        for cassr in csess.assessors():
            if XnatUtils.is_cassessor_good_type(cassr, [self.proctype]):
                reg_verdict = cassr

        if XnatUtils.has_resource(reg_verdict, 'ACQ2'):
            nb_acq = 2

        cmd = SPIDER_FORMAT.format(spider=self.spider_path,
                                   proj=proj_label,
                                   subj=subj_label,
                                   sess=sess_label,
                                   dir=jobdir,
                                   nb_acq=nb_acq,
                                   proctype=self.proctype,
                                   mc=self.mc,
                                   camino=self.camino,
                                   scheme=self.scheme_file,
                                   suffix_proc=self.suffix_proc)

        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 needs_run(self, cscan, xnat):
        """needs_run function overridden from base-class.

        cscan = CacheScan object from XnatUtils
        return True or False
        """
        # Check output
        if XnatUtils.has_resource(cscan, 'NIFTI'):
            LOGGER.debug('Has NIFTI')
            return False
        # Check input
        if not XnatUtils.has_resource(cscan, 'DICOM'):
            LOGGER.debug('no DICOM resource')
            return False

        return True
    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 needs_run(self, cscan, xnat):
        """needs_run function overridden from base-class.

        :param cscan: CacheScan object from XnatUtils
        :return: True if needs to run or False otherwise
        """
        # Unusable
        if XnatUtils.is_cscan_unusable(cscan):
            LOGGER.debug('Scan unusable.')
            return False
        # Check output
        if XnatUtils.has_resource(cscan, 'NIFTI'):
            LOGGER.debug('Has NIFTI')
            return False
        # Check input
        if not XnatUtils.has_resource(cscan, 'DICOM'):
            LOGGER.debug('no DICOM resource')
            return False

        return True
Example #7
0
    def needs_run(self, cscan, xnat):
        """ needs_run function overridden from base-class
                cscan = CacheScan object from XnatUtils
            return True or False
        """

        # Check output
        if XnatUtils.has_resource(cscan, 'NIFTI'):
            LOGGER.debug('Has NIFTI')
            return False

        # Check input
        if not XnatUtils.has_resource(cscan, 'DICOM'):
            LOGGER.debug('No DICOM resource')
            return False

        if XnatUtils.is_cscan_unusable(cscan):
            LOGGER.debug('Unusable scan')
            return False

        return True
    def needs_run(self, cscan, xnat):
        """ needs_run function overridden from base-class
            cscan = CacheScan object from XnatUtils
            return True or False
        """
        _info = cscan.info()
        if _info['type'] not in self.scan_types:
            return False

        # Check for existing EDAT resource
        if XnatUtils.has_resource(cscan, 'EDAT'):
            LOGGER.debug('Has EDAT')
            return False

        return True
    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 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
    def has_inputs(self, cscan):
        """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 cscan: object cscan define in dax.XnatUtils
                      (see XnatUtils in dax for information)
        :return: status, qcstatus
        """
        if XnatUtils.is_cscan_unusable(cscan):
            return -1, 'Scan unusable'

        # Check has_resource PARREC or NIFTI
        if XnatUtils.has_resource(cscan, 'NIFTI'):
            return 1, None

        LOGGER.debug('GIF Parcellation: NIFTI not found.')
        return 0, 'No NIFTI'
Example #12
0
 def has_resource(scan, label):
     return XnatUtils.has_resource(scan, label)
Example #13
0
 def has_resource(scan, label):
     return XnatUtils.has_resource(scan, label)