DeepFusionBP.py 🚧¶
Source: LION/models/learned_fbp/DeepFusionBP.py
Warning
This file has not yet received a complete narrative and docstring audit. Its public source-level API is listed automatically below.
- class LearnableFilter(init_filter, per_angle=False, num_angles=None)
Implements a learnable frequency-domain filter for sinograms in CT reconstruction.
This module replaces traditional analytic filters (e.g., Ram-Lak) with learnable weights in the frequency domain, optionally per projection angle.
Args: init_filter (torch.Tensor): Initial filter in frequency domain. per_angle (bool): If True, uses one filter per angle. num_angles (int, optional): Required when per_angle=True.
- LearnableFilter.forward(self, x)
Applies learnable frequency-domain filtering to each projection.
Args: x (Tensor): Input sinogram of shape [B, A, D].
Returns: Tensor: Filtered sinogram of shape [B, A, D].
- class IntermediateResidualBlock(channels)
Depthwise 1D convolutional residual block.
Used in the angular interpolation subnetwork. Applies a depthwise Conv1d, followed by BatchNorm1d and PReLU, with a residual connection.
Args: channels (int): Number of input/output channels.
- IntermediateResidualBlock.forward(self, x)
No docstring is available.
- class single_back_projections(angles_sparse, src_orig_dist, num_detectors, vg)
Applies single-angle differentiable backprojections using Tomosipo.
Each angle in the sparse set is used to compute a separate backprojection, forming a stack of angle-specific reconstructions.
Args: angles_sparse (torch.Tensor): Sparse angles to backproject. src_orig_dist (float): Source-to-origin distance. num_detectors (int): Number of detector bins. vg (ts.VolumeGeometry): Volume geometry for tomosipo operator.
- single_back_projections.forward(self, sinogram)
Generates a set of backprojections from sparse-view sinogram.
Each angle is used to generate a single-angle backprojection using tomosipo.
Args: sinogram (torch.Tensor): Noisy sinogram of shape (1, num_angles, num_detectors).
Returns: torch.Tensor: Stack of backprojections of shape (n_single_BP, H, W).
- class DBP_block(channels)
Deep CNN for denoising stacked single-angle backprojections.
Composed of an initial Conv2d+ReLU, 15 intermediate Conv2d+BN+ReLU layers, and a final Conv2d output layer. Adapted from the DBP architecture.
Args: channels (int): Number of input channels (i.e., number of angles).
- DBP_block.initial_layer(self, in_channels, out_channels, kernel_size, stride, padding)
Builds the initial convolutional block of the network.
This block consists of: - Conv2d - ReLU activation
Args: in_channels (int): Number of input channels. out_channels (int): Number of output channels. kernel_size (int): Size of the convolutional kernel. stride (int): Convolution stride. padding (int): Zero-padding to add to each side.
Returns: nn.Sequential: A sequential block with Conv2d and ReLU.
- DBP_block.conv_block(self, in_channels, out_channels, kernel_size, stride, padding)
Builds an intermediate convolutional block for the DBP architecture.
This block includes: - Conv2d - BatchNorm2d - ReLU activation
Args: in_channels (int): Number of input feature channels. out_channels (int): Number of output feature channels. kernel_size (int): Size of the convolutional kernel. stride (int): Convolution stride. padding (int): Zero-padding to apply.
Returns: nn.Sequential: A sequential block with Conv2d, BatchNorm2d, and ReLU.
- DBP_block.final_layer(self, in_channels, out_channels, kernel_size, stride, padding)
Builds the final convolutional layer that produces the output image.
This layer does not include an activation function.
Args: in_channels (int): Number of input channels. out_channels (int): Number of output channels (typically 1). kernel_size (int): Size of the convolutional kernel. stride (int): Convolution stride. padding (int): Zero-padding to apply.
Returns: nn.Conv2d: Final convolutional layer.
- DBP_block.forward(self, x)
Defines the forward pass of the DBP network.
The input is passed sequentially through: - Initial convolutional block - Fifteen intermediate convolutional blocks - Final convolutional layer
Args: x (torch.Tensor): Input tensor of shape (B, C, H, W), where: B = batch size, C = number of backprojection channels (n_single_BP), H, W = spatial dimensions.
Returns: torch.Tensor: Output tensor of shape (B, 1, H, W), representing the reconstructed image.
- class DeepFusionBPNetwork(geometry: ct.Geometry, model_parameters: LIONParameter = None)
Neural architecture for Deep Fusion Backprojection (DeepFusionBP).
This module implements the full reconstruction pipeline including: - A learnable frequency-domain filter (shared or per-angle). - Angular interpolation using a stack of 1D residual convolutions. - Differentiable single-angle backprojections via Tomosipo. - A deep CNN (based on DBP) to fuse and denoise reconstructed views.
Args: angles_sparse (torch.Tensor): Sparse subset of projection angles. src_orig_dist (float): Source-to-origin distance used in CT geometry. num_detectors (int): Number of detector bins per projection. num_angles (int): Number of sparse angles used in this configuration. vg (ts.VolumeGeometry): Tomosipo volume geometry for reconstruction. A (ts.Operator): Tomosipo projection operator (unused here but stored). filter_type (str): Either “Filter I” (shared filter) or “per-angle”. device (torch.device): Device where the model will run (e.g., “cuda”).
Forward Input: x (Tensor): Input sinogram of shape [B, 1, A, D], where: - B: batch size, - A: number of sparse projection angles, - D: number of detector bins.
Returns: Tensor: Reconstructed CT images of shape [B, 1, H, W].
- DeepFusionBPNetwork.compute_projection_size_padded(self)
Computes the padded projection width for frequency-domain filtering.
This ensures the sinogram is padded to the nearest power of two to avoid aliasing artifacts when applying FFT-based filters.
Returns: int: Projection size after zero-padding.
- DeepFusionBPNetwork.ram_lak_filter(self, size)
Generates Ram-Lak filter directly in frequency domain.
- DeepFusionBPNetwork.default_parameters()
No docstring is available.
- DeepFusionBPNetwork.forward(self, x)
Performs forward pass through the DeepFusionBP network.
The input sinogram goes through: 1. Learnable frequency-domain filtering (Ram-Lak initialized). 2. Angular interpolation via 1D depthwise convolutions. 3. Single-angle differentiable backprojections (Tomosipo). 4. A deep CNN that fuses and denoises the backprojections.
Args: x (torch.Tensor): Input sinogram of shape [B, 1, A, D], where: - B: batch size, - A: number of angles (sparse), - D: number of detectors.
Returns: torch.Tensor: Reconstructed image of shape [B, 1, H, W], where H=W=362.