Esempio n. 1
0
    def prov(self):
        """
        Extracts provenance information from the study for storage alongside
        generated derivatives. Typically for reference purposes only as only
        the pipeline workflow, inputs and outputs are checked by default when
        determining which sessions require reprocessing.

        Returns
        -------
        prov : dict[str, *]
            A dictionary containing the provenance information to record
            for the study
        """
        # Get list of repositories where inputs to the study are stored
        input_repos = list(set((i.repository for i in self.inputs)))
        inputs = {}
        for input in self.inputs:
            inputs[input.name] = {
                'repository_index': input_repos.index(input.repository)
            }
            if input.frequency == 'per_study':
                inputs[input.name]['names'] = next(input.collection).name
            elif input.frequency == 'per_subject':
                inputs[input.name]['names'] = {
                    i.subject_id: i.name
                    for i in input.collection
                }
            elif input.frequency == 'per_visit':
                inputs[input.name]['names'] = {
                    i.visit_id: i.name
                    for i in input.collection
                }
            elif input.frequency == 'per_session':
                names = defaultdict(dict)
                for item in input.collection:
                    names[item.subject_id][item.visit_id] = item.name
                # Convert from defaultdict to dict
                inputs[input.name]['names'] = dict(names.items())
        return {
            'name': self.name,
            'type': get_class_info(type(self)),
            'parameters': {p.name: p.value
                           for p in self.parameters},
            'inputs': inputs,
            'environment': self.environment.prov,
            'repositories': [r.prov for r in input_repos],
            'processor': self.processor.prov,
            'subject_ids': tuple(self.subject_ids),
            'visit_ids': tuple(self.visit_ids)
        }
Esempio n. 2
0
 def prov(self):
     prov = {
         'interface': get_class_info(type(self.interface)),
         'requirements': {v.name: v.prov for v in self.versions},
         'parameters': {}}
     for trait_name in self.inputs.visible_traits():
         val = getattr(self.inputs, trait_name)
         try:
             val_prov = val.prov
         except AttributeError:
             val_prov = val
         if isdefined(val):
             prov['parameters'][trait_name] = val_prov
     return prov
Esempio n. 3
0
 def prov(self):
     return {'type': get_class_info(type(self)), 'host': HOSTNAME}
Esempio n. 4
0
 def prov(self):
     return {'type': get_class_info(type(self)), 'echo': self._echo}
Esempio n. 5
0
 def prov(self):
     return {'type': get_class_info(type(self))}
Esempio n. 6
0
 def prov(self):
     return {
         'type': get_class_info(type(self)),
         'server': self.server}