hyri.regulariser.den_hyperairi#
Implement the HyperAIRI denoiser regulariser.
This file provides multi-channel AIRI denoising with neighbour-channel context, distributed boundary exchange, and optional spectral-correction updates.
Class
Apply the HyperAIRI denoiser to a local channel block. |
- class hyri.regulariser.den_hyperairi.DenHyperAIRI(img_size: tuple, ch_freq: Tensor, shelf_path: str, rank_num_ch: int = 1, rank_ch_start: int = 0, rand_trans: bool = True, device: device = device(type='cpu'), dtype: dtype = torch.float32, verbose: bool = True)#
Bases:
RegulariserApply the HyperAIRI denoiser to a local channel block.
This class implements the learned regularisation operator used by HyperAIRI. For each target channel, the denoiser exploits a local three-channel spectral neighbourhood together with the current spectral-index map under a power-law spectral model. In distributed execution, boundary channels are exchanged with adjacent ranks so that the same local spectral context is available at rank boundaries.
For channel \(i\), let
\[\mathbf{z}_i = \begin{bmatrix} \mathbf{x}_{i-1},\ \mathbf{x}_{i},\ \mathbf{x}_{i+1} \end{bmatrix}\]denote the three-channel input centred at the target channel, and let \(\boldsymbol{\alpha}\) denote the current spectral-index map. With local frequency ratios \(\mathbf{r}_i = (\nu_i/\nu_{i-1},\, 1,\, \nu_i/\nu_{i+1})\), the HyperAIRI denoiser is written abstractly as
\[\mathbf{x}_i^{\mathrm{den}} = \rho_i \, \mathcal{D}_{\sigma_i} \bigl( \mathbf{z}_i / \rho_i,\, \boldsymbol{\alpha},\, \mathbf{r}_i \bigr),\]where \(\rho_i\) is the channel-dependent scaling factor and \(\sigma_i\) is the denoiser noise level selected from the shelf.
In this implementation, the denoiser of each channel is selected dynamically according to the heuristic noise level and peak-intensity estimate.
- Shape:
Input –
(1, C, H, W)whereCequalsrank_num_chfor the current rank.Output –
(1, C, H, W)with the same shape as input.
- _list_spec_corr_weight#
Internal frequency-dependent coupling weights derived from the spectral-index map and local frequency ratios.
- Type:
- _ch_freq#
Global channel frequencies.
- Type:
- _rand_trans#
Whether random flips and right-angle rotations are applied as denoiser self-ensembling.
- Type:
Example
>>> den = DenHyperAIRI( ... img_size=(64, 64), ... ch_freq=torch.linspace(1.1e9, 1.4e9, 4), ... shelf_path="airi_denoisers/shelf_hyperairi_mix.csv", ... rank_num_ch=4, ... ) >>> x = torch.zeros(1, 4, 64, 64) >>> den.update(spec_idx=torch.zeros(1, 1, 64, 64)) >>> y = den(x) >>> y.shape torch.Size([1, 4, 64, 64])
References
Tang, C., Dabbech, A., Jackson, A., & Wiaux, Y. (2026). HyperAIRI: a plug-and-play algorithm for precise hyperspectral image reconstruction in radio interferometry. ApJS, 283(1), 9.
Initialise HyperAIRI shelf metadata and runtime state.
- Parameters:
img_size (tuple) – Image spatial shape
(H, W).ch_freq (torch.Tensor) – Global channel frequencies.
shelf_path (str) – Path to the denoiser shelf CSV.
rank_num_ch (int, optional) – Number of channels handled by this rank. Default: 1.
rank_ch_start (int, optional) – Global start index of local channels. Default: 0.
rand_trans (bool, optional) – Apply random flips/rotations before and after denoising. Default: True.
device (torch.device, optional) – Execution device. Default: torch.device(“cpu”).
dtype (torch.dtype, optional) – Tensor dtype for denoising tensors. Default: torch.float.
verbose (bool, optional) – Enable shelf-selection and spectral-update logs. Default: True.
- Raises:
FileNotFoundError – If the denoiser shelf CSV or network files in the shelf cannot be found.
RuntimeError – If the denoiser shelf CSV contains no usable entries.
- __call__(x: Tensor) Tensor#
Denoise local channels using neighbour-channel context.
- Parameters:
x (torch.Tensor) – Input tensor with shape
(1, C, H, W).- Returns:
Denoised and positivity-projected tensor.
- Return type:
Note
The method
update()must be called with valid heuristic noise level and peak-intensity estimates before this method is used, so that the appropriate denoisers are selected and loaded for each channel.
- _den_ch_single(net_input, i) Tensor#
- Denoise one channel with its two immediate neighbouring channels
as contextual input.
- Parameters:
net_input (torch.Tensor) – Tensor containing the previous, current, and next channel slices.
i (int) – Local channel index.
- Returns:
Denoised tensor for channel
iwith shape(1, 1, H, W).- Return type:
- update(ch_heuristic: Tensor = None, ch_peak_est: Tensor = None, spec_idx: Tensor = None) tuple[Tensor | None, Tensor | None]#
Update denoiser shelf selection and spectral correction weights.
- Parameters:
ch_heuristic (torch.Tensor, optional) – Per-channel heuristic noise levels. Default: None.
ch_peak_est (torch.Tensor, optional) – Per-channel peak-intensity estimates. Default: None.
spec_idx (torch.Tensor, optional) – Spectral-index map used to update channel-coupling weights. Default: None.
- Returns:
Lower and upper admissible peak ranges for local channels, or
(None, None)when no shelf update is requested.- Return type:
Tuple[Optional[torch.Tensor], Optional[torch.Tensor]]
Note
Shelf selection and spectral-correction updates are independent; either can be refreshed on its own.