Ejemplo n.º 1
0
    def fetch_data(self, key, key_order=None):
        assert len(self
                   & key) == 1, 'Key must refer to exactly one multi dataset'
        ret = OrderedDict()
        log.info('Fetching data for ' + repr(key))
        for mkey in (self.Member() & key).fetch(
                dj.key,
                order_by=
                'animal_id ASC, session ASC, scan_idx ASC, preproc_id ASC'):
            name = (self.Member() & mkey).fetch1('name')
            include_behavior = bool(Eye().proj() * Treadmill().proj() & mkey)
            data_names = ['images', 'responses'] if not include_behavior \
                else ['images',
                      'behavior',
                      'pupil_center',
                      'responses']
            log.info('Data will be ({})'.format(','.join(data_names)))

            h5filename = InputResponse().get_filename(mkey)
            log.info('Loading dataset {} --> {}'.format(name, h5filename))
            ret[name] = datasets.StaticImageSet(h5filename, *data_names)
        if key_order is not None:
            log.info(
                'Reordering datasets according to given key order {}'.format(
                    ', '.join(key_order)))
            ret = OrderedDict([(k, ret[k]) for k in key_order])
        return ret
Ejemplo n.º 2
0
    def fetch_data(self, key, key_order=None):
        ret = OrderedDict()
        log.info("Fetching data for " + repr(key))
        for mkey in (self.Member() * DatasetInputResponse & key).fetch(
                dj.key,
                order_by=
                "animal_id ASC, session ASC, scan_idx ASC, preproc_id ASC"):
            name = (self.Member() & mkey).fetch1("name")
            data_names = DatasetConfig().part_table(mkey).data_names
            log.info("Data will be ({})".format(",".join(data_names)))

            h5filename = DatasetConfig().part_table(mkey).get_filename()
            log.info("Loading dataset {} --> {}".format(name, h5filename))
            ret[name] = datasets.StaticImageSet(h5filename, *data_names)
        if key_order is not None:
            log.info(
                "Reordering datasets according to given key order {}".format(
                    ", ".join(key_order)))
            ret = OrderedDict([(k, ret[k]) for k in key_order])
        return ret