docs: 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:  # @ReservedAssignment
              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': self.subject_ids,
              'visit_ids': self.visit_ids}