Example #1
0
def generate_deformation_field(args, reg_params):
    logging.info("Generating deformation field")
    try:
        safe_execute_command(
            prepare_deformation_field_cmd(args, reg_params),
            args.paths.tmp__deformation_log_file_path,
            args.paths.tmp__deformation_error_path,
        )
    except SafeExecuteCommandError as err:
        raise TransformationError(
            "Generation of deformation field failed ; {}".format(err))
Example #2
0
 def generate_deformation_field(self, deformation_field_path):
     logging.info("Generating deformation field")
     try:
         safe_execute_command(
             self._prepare_deformation_field_cmd(deformation_field_path),
             self.paths.deformation_log_file_path,
             self.paths.deformation_error_file_path,
         )
     except SafeExecuteCommandError as err:
         raise TransformationError(
             "Generation of deformation field failed ; {}".format(err)
         )
Example #3
0
def safe_transform(transformation_command, log_file_path, error_file_path):
    """
    Using a specified niftyreg command, transforms an image, and catches
    any logs or errors.
    :param str transformation_command: Full niftyreg command
    :param log_file_path: Path to save the log file to
    :param error_file_path: Path to save the error file to
    """
    try:
        safe_execute_command(
            transformation_command, log_file_path, error_file_path
        )
    except SafeExecuteCommandError as err:
        raise TransformationError("Transformation failed; {}".format(err))
Example #4
0
    def transform_to_standard_space(self, image_path, destination_path):
        """
        Transform an image in sample space to standard space
        """

        try:
            safe_execute_command(
                self._prepare_inverse_registration_cmd(
                    image_path, destination_path,
                ),
                self.paths.inverse_transform_log_file,
                self.paths.inverse_transform_error_file,
            )
        except SafeExecuteCommandError as err:
            raise TransformationError(
                "Reverse transformation failed; {}".format(err)
            )
Example #5
0
def safely_execute_amap_registration(error_file_path, log_file_path, reg_cmd):
    print("Running registration")
    try:
        safe_execute_command(reg_cmd, log_file_path, error_file_path)
    except SafeExecuteCommandError as err:
        raise TransformationError("ROI registration failed; {}".format(err))