Exemple #1
0
    def _get_slice_metrics(self, img_recons, img_targets, extra_params):
        img_recons = img_recons.detach()  # Just in case.
        img_targets = img_targets.detach()
        max_range = img_targets.max() - img_targets.min()

        slice_ssim = self.ssim_loss(img_recons, img_targets, max_val=max_range)
        slice_psnr = psnr(img_recons, img_targets, data_range=max_range)
        slice_nmse = nmse(img_recons, img_targets)

        slice_metrics = {
            'slice_ssim': slice_ssim,
            'slice_nmse': slice_nmse,
            'slice_psnr': slice_psnr
        }

        # Additional metrics for separating between acceleration factors.
        if 'acceleration' in extra_params:
            slice_metrics[
                f'acc_{extra_params["acceleration"]}_ssim'] = slice_ssim
            slice_metrics[
                f'acc_{extra_params["acceleration"]}_psnr'] = slice_psnr
            slice_metrics[
                f'acc_{extra_params["acceleration"]}_nmse'] = slice_nmse

        return slice_metrics
    def _get_slice_metrics(self, recons, targets, extra_params):
        img_recons = recons['img_recons'].detach()  # Just in case.
        img_targets = targets['img_targets'].detach()
        max_range = img_targets.max() - img_targets.min()

        slice_ssim = self.ssim(img_recons, img_targets)
        slice_psnr = psnr(img_recons, img_targets, data_range=max_range)
        slice_nmse = nmse(img_recons, img_targets)

        slice_metrics = {
            'slice/ssim': slice_ssim,
            'slice/nmse': slice_nmse,
            'slice/psnr': slice_psnr
        }

        if 'rss_recons' in recons:
            rss_recons = recons['rss_recons'].detach()
            rss_targets = targets['rss_targets'].detach()
            max_range = rss_targets.max() - rss_targets.min()

            rss_ssim = self.ssim(rss_recons, rss_targets)
            rss_psnr = psnr(rss_recons, rss_targets, data_range=max_range)
            rss_nmse = nmse(rss_recons, rss_targets)

            slice_metrics['rss/ssim'] = rss_ssim
            slice_metrics['rss/psnr'] = rss_psnr
            slice_metrics['rss/nmse'] = rss_nmse
        else:
            rss_ssim = rss_psnr = rss_nmse = 0

        # Additional metrics for separating between acceleration factors.
        if 'acceleration' in extra_params:
            acc = extra_params["acceleration"]
            slice_metrics[f'slice_acc_{acc}/ssim'] = slice_ssim
            slice_metrics[f'slice_acc_{acc}/psnr'] = slice_psnr
            slice_metrics[f'slice_acc_{acc}/nmse'] = slice_nmse

            if 'rss_recons' in recons:
                slice_metrics[f'rss_acc_{acc}/ssim'] = rss_ssim
                slice_metrics[f'rss_acc_{acc}/psnr'] = rss_psnr
                slice_metrics[f'rss_acc_{acc}/nmse'] = rss_nmse

        return slice_metrics
Exemple #3
0
    def _get_slice_metrics(img_recons, img_targets):

        img_recons = img_recons.detach()  # Just in case.
        img_targets = img_targets.detach()

        max_range = img_targets.max() - img_targets.min()
        slice_ssim = ssim_loss(img_recons, img_targets, max_val=max_range)
        slice_psnr = psnr(img_recons, img_targets, data_range=max_range)
        slice_nmse = nmse(img_recons, img_targets)

        return {'slice_ssim': slice_ssim, 'slice_nmse': slice_nmse, 'slice_psnr': slice_psnr}
    def _get_slice_metrics(self, recons, targets, extra_params):
        rss_metrics = dict()
        rss_recons = recons['rss_recons'].detach()
        rss_targets = targets['rss_targets'].detach()

        rss_ssim = self.ssim(rss_recons, rss_targets)
        rss_psnr = psnr(rss_recons, rss_targets)
        rss_nmse = nmse(rss_recons, rss_targets)

        rss_metrics['rss/ssim'] = rss_ssim
        rss_metrics['rss/psnr'] = rss_psnr
        rss_metrics['rss/nmse'] = rss_nmse

        # Additional metrics for separating between acceleration factors.
        acc = extra_params["acceleration"]
        rss_metrics[f'rss_acc_{acc}/ssim'] = rss_ssim
        rss_metrics[f'rss_acc_{acc}/psnr'] = rss_psnr
        rss_metrics[f'rss_acc_{acc}/nmse'] = rss_nmse

        return rss_metrics
    def _get_slice_metrics(self, recons, targets, extra_params):
        rss_metrics = dict()
        rss_recons = recons['rss_recons'].detach()
        rss_targets = targets['rss_targets'].detach()

        max_val = extra_params['max']
        # Add max_val here for accurate block level SSIM metrics!!
        rss_ssim = self.ssim(rss_recons, rss_targets)
        rss_psnr = psnr(rss_recons, rss_targets)
        rss_nmse = nmse(rss_recons, rss_targets)

        rss_metrics['rss/ssim'] = rss_ssim
        rss_metrics['rss/psnr'] = rss_psnr
        rss_metrics['rss/nmse'] = rss_nmse

        # Additional metrics for separating between acceleration factors.
        acc = extra_params['acceleration']
        rss_metrics[f'rss_acc_{acc}/ssim'] = rss_ssim
        rss_metrics[f'rss_acc_{acc}/psnr'] = rss_psnr
        rss_metrics[f'rss_acc_{acc}/nmse'] = rss_nmse

        return rss_metrics