Exemplo n.º 1
0
def load_eta_ome_maps(cfg, pd, image_series, hkls=None, clean=False):
    """
    Load the eta-ome maps specified by the config and CLI flags.

    Parameters
    ----------
    cfg : TYPE
        DESCRIPTION.
    pd : TYPE
        DESCRIPTION.
    image_series : TYPE
        DESCRIPTION.
    hkls : TYPE, optional
        DESCRIPTION. The default is None.
    clean : TYPE, optional
        DESCRIPTION. The default is False.

    Returns
    -------
    TYPE
        DESCRIPTION.

    """
    # check maps filename
    if cfg.find_orientations.orientation_maps.file is None:
        maps_fname = '_'.join([cfg.analysis_id, "eta-ome_maps.npz"])
    else:
        maps_fname = cfg.find_orientations.orientation_maps.file

    fn = os.path.join(cfg.working_dir, maps_fname)

    # ???: necessary?
    if fn.split('.')[-1] != 'npz':
        fn = fn + '.npz'

    if not clean:
        try:
            res = EtaOmeMaps(fn)
            pd = res.planeData
            available_hkls = pd.hkls.T
            logger.info('loaded eta/ome orientation maps from %s', fn)
            hkls = [str(i) for i in available_hkls[res.iHKLList]]
            logger.info(
                'hkls used to generate orientation maps: %s',
                hkls
            )
        except (AttributeError, IOError):
            logger.info("specified maps file '%s' not found "
                        + "and clean option specified; "
                        + "recomputing eta/ome orientation maps",
                        fn)
            res = generate_eta_ome_maps(cfg, hkls=hkls)
    else:
        logger.info('clean option specified; '
                    + 'recomputing eta/ome orientation maps')
        res = generate_eta_ome_maps(cfg, hkls=hkls)
    filter_maps_if_requested(res, cfg)
    return res
Exemplo n.º 2
0
    def ome_maps_selected(self):
        dialog = self.ome_maps_select_dialog
        if dialog is None:
            return

        if dialog.method_name == 'load':
            self.ome_maps = EtaOmeMaps(dialog.file_name)
            self.ome_maps_select_dialog = None
            self.view_ome_maps()
        else:
            # Create a full indexing config
            config = create_indexing_config()

            # Setup to generate maps in background
            self.progress_dialog.setWindowTitle('Generating Eta Omega Maps')
            self.progress_dialog.setRange(0, 0)  # no numerical updates

            worker = AsyncWorker(self.run_eta_ome_maps, config)
            self.thread_pool.start(worker)

            worker.signals.result.connect(self.view_ome_maps)
            worker.signals.finished.connect(self.progress_dialog.accept)
            self.progress_dialog.exec_()