def get_loader_result(key, table): """ Retrieve the loaded processed imaging results from the loader (e.g. suite2p, caiman, etc.) :param key: the `key` to one entry of ProcessingTask or Curation :param table: the class defining the table to retrieve the loaded results from (e.g. ProcessingTask, Curation) :return: a loader object of the loaded results (e.g. suite2p.Suite2p, caiman.CaImAn, etc.) """ method, output_dir = (ProcessingParamSet * table & key).fetch1( "processing_method", _table_attribute_mapper[table.__name__]) output_path = find_full_path(get_imaging_root_data_dir(), output_dir) if method == "suite2p": from element_interface import suite2p_loader loaded_dataset = suite2p_loader.Suite2p(output_path) elif method == "caiman": from element_interface import caiman_loader loaded_dataset = caiman_loader.CaImAn(output_path) else: raise NotImplementedError( "Unknown/unimplemented method: {}".format(method)) return method, loaded_dataset
def auto_generate_entries(cls, scan_key, task_mode): """ Method to auto-generate ProcessingTask entries for a particular Scan using a default paramater set. """ default_paramset_idx = os.environ.get("DEFAULT_PARAMSET_IDX", 0) output_dir = cls.infer_output_dir(scan_key, relative=False, mkdir=True) method = (ProcessingParamSet & {"paramset_idx": default_paramset_idx}).fetch1( "processing_method" ) try: if method == "suite2p": from element_interface import suite2p_loader loaded_dataset = suite2p_loader.Suite2p(output_dir) elif method == "caiman": from element_interface import caiman_loader loaded_dataset = caiman_loader.CaImAn(output_dir) else: raise NotImplementedError( "Unknown/unimplemented method: {}".format(method) ) except FileNotFoundError: task_mode = "trigger" else: task_mode = "load" cls.insert1( { **scan_key, "paramset_idx": default_paramset_idx, "processing_output_dir": output_dir, "task_mode": task_mode, } )