Example #1
0
    def _generate_regist_command(self, item):
        """ generate the registration command(s)

        :param dict item: dictionary with registration params
        :return str|list(str): the execution commands
        """
        path_im_ref, path_im_move, _, _ = self._get_paths(item,
                                                          prefer_pproc=True)
        path_dir = self._get_path_reg_dir(item)
        config = self.DEFAULT_PARAMS
        config = dict_deep_update(config,
                                  load_config_yaml(self.params['path_config']))
        assert config['bUnwarpJ']['mode'] < 2, 'Mono mode does not supports inverse transform' \
                                               ' which is need for landmarks warping.'

        config_sift = [config['SIFT'][k] for k in self.REQUIRED_PARAMS_SIFT] \
            if config.get('SIFT', False) else []
        config_bunwarpj = [
            config['bUnwarpJ'][k] for k in self.REQUIRED_PARAMS_BUNWARPJ
        ]
        path_reg_script = self.PATH_SCRIPT_REGISTRATION_SIFT if config_sift \
            else self.PATH_SCRIPT_REGISTRATION_BASE

        cmd = self.COMMAND_REGISTRATION % {
            'exec_Fiji': self.params['exec_Fiji'],
            'path_bsh': path_reg_script,
            'target': path_im_ref,
            'source': path_im_move,
            'output': path_dir,
            'params': ' '.join(map(str, config_sift + config_bunwarpj)),
        }
        return cmd
Example #2
0
    def _generate_regist_command(self, item):
        """ generate the registration command(s)

        :param dict item: dictionary with registration params
        :return str|list(str): the execution commands
        """
        path_im_ref, path_im_move, _, _ = self._get_paths(item, prefer_pproc=True)
        path_dir = self._get_path_reg_dir(item)

        # creating the internal folders
        path_dir_in = os.path.join(path_dir, self.DIR_INPUTS)
        path_dir_out = os.path.join(path_dir, self.DIR_OUTPUTS)
        for p_dir in (path_dir_in, path_dir_out):
            os.mkdir(p_dir)
        # copy both images
        name_ref = os.path.basename(path_im_ref)
        shutil.copy(path_im_ref, os.path.join(path_dir_in, name_ref))
        shutil.copy(path_im_move, os.path.join(path_dir_in, os.path.basename(path_im_move)))

        config = self.DEFAULT_PARAMS
        config = dict_deep_update(config, load_config_yaml(self.params['path_config']))

        config_rvss = [config['RVSS'][k] for k in self.REQUIRED_PARAMS_RVSS]
        config_sift = [config['SIFT'][k] for k in BmUnwarpJ.REQUIRED_PARAMS_SIFT]

        cmd = self.COMMAND_REGISTRATION % {
            'exec_Fiji': self.params['exec_Fiji'],
            'path_bsh': self.PATH_SCRIPT_REGISTRATION,
            'dir_input': path_dir_in,
            'dir_output': path_dir_out,
            'ref_name': name_ref,
            'params': ' '.join(map(str, config_rvss + config_sift)),
        }
        return cmd