def index(self, config):
        """
        Traverse the reports config definition and instantiate reportlets.
        This method also places figures in their final location.
        """
        for subrep_cfg in config:
            # First determine whether we need to split by some ordering
            # (ie. sessions / tasks / runs), which are separated by commas.
            orderings = [s for s in subrep_cfg.get('ordering', '').strip().split(',') if s]
            queries = []
            for key in orderings:
                values = getattr(self.layout, 'get_%s%s' % (key, PLURAL_SUFFIX[key]))()
                if values:
                    queries.append((key, values))

            if not queries:  # E.g. this is an anatomical reportlet
                reportlets = [Reportlet(self.layout, self.out_dir, config=cfg)
                              for cfg in subrep_cfg['reportlets']]
            else:
                # Do not use dictionary for queries, as we need to preserve ordering
                # of ordering columns.
                reportlets = []
                entities, values = zip(*queries)
                combinations = list(product(*values))  # e.g.: [('rest', 1), ('rest', 2)]

                for c in combinations:
                    # Set a common title for this particular combination c
                    title = 'Reports for: %s.' % ', '.join(
                        ['%s <span class="bids-entity">%s</span>' % (entities[i], c[i])
                         for i in range(len(c))])
                    for cfg in subrep_cfg['reportlets']:
                        cfg['bids'].update({entities[i]: c[i] for i in range(len(c))})
                        rlet = Reportlet(self.layout, self.out_dir, config=cfg)
                        if not rlet.is_empty():
                            rlet.title = title
                            title = None
                            reportlets.append(rlet)

            # Filter out empty reportlets
            reportlets = [r for r in reportlets if not r.is_empty()]
            if reportlets:
                sub_report = SubReport(
                    subrep_cfg['name'],
                    isnested=len(queries) > 0,
                    reportlets=reportlets,
                    title=subrep_cfg.get('title'))
                self.sections.append(sub_report)

        # Populate errors sections
        error_dir = self.out_dir / self.packagename / 'sub-{}'.format(self.subject_id) / \
            'log' / self.run_uuid
        if error_dir.is_dir():
            from ..utils.misc import read_crashfile
            self.errors = [read_crashfile(str(f)) for f in error_dir.glob('crash*.*')]
Traverse the reports config definition and instantiate reportlets.
        This method also places figures in their final location.