Ejemplo n.º 1
0
def _project_grad(op, grad):
    '''
        Compute the gradient of the projection op by invoking the backprojector.
    '''
    reco = pyronn_layers.fan_backprojection2d(
        sinogram=grad,
        volume_shape=op.inputs[0].shape[1:],
        volume_origin=op.inputs[2],
        detector_origin=op.inputs[3],
        volume_spacing=op.inputs[4],
        detector_spacing=op.inputs[5],
        source_2_isocenter_distance=op.inputs[6],
        source_2_detector_distance=op.inputs[7],
        central_ray_vectors=op.inputs[8],
    )
    return [
        reco,
        tf.stop_gradient(op.inputs[1]),
        tf.stop_gradient(op.inputs[2]),
        tf.stop_gradient(op.inputs[3]),
        tf.stop_gradient(op.inputs[4]),
        tf.stop_gradient(op.inputs[5]),
        tf.stop_gradient(op.inputs[6]),
        tf.stop_gradient(op.inputs[7]),
        tf.stop_gradient(op.inputs[8])
    ]
Ejemplo n.º 2
0
def fan_backprojection2d(sinogram, geometry):
    """
    Wrapper function for making the layer call.
    Args:
        volume:     Input volume to project.
        geometry:   Corresponding GeometryFan2D Object defining parameters.
    Returns:
            Initialized lme_custom_ops.fan_backprojection2d layer.
    """
    batch = np.shape(sinogram)[0]
    return pyronn_layers.fan_backprojection2d(
        sinogram,
        volume_shape=geometry.volume_shape,
        volume_origin=np.broadcast_to(
            geometry.volume_origin,
            [batch, *np.shape(geometry.volume_origin)]),
        detector_origin=np.broadcast_to(
            geometry.detector_origin,
            [batch, *np.shape(geometry.detector_origin)]),
        volume_spacing=np.broadcast_to(
            geometry.volume_spacing,
            [batch, *np.shape(geometry.volume_spacing)]),
        detector_spacing=np.broadcast_to(
            geometry.detector_spacing,
            [batch, *np.shape(geometry.detector_spacing)]),
        source_2_isocenter_distance=np.broadcast_to(
            geometry.source_isocenter_distance,
            [batch, *np.shape(geometry.source_isocenter_distance)]),
        source_2_detector_distance=np.broadcast_to(
            geometry.source_detector_distance,
            [batch, *np.shape(geometry.source_detector_distance)]),
        central_ray_vectors=np.broadcast_to(
            geometry.central_ray_vectors,
            [batch, *np.shape(geometry.central_ray_vectors)]))
Ejemplo n.º 3
0
def _project_grad(op, grad):
    '''
        Compute the gradient of the projection op by invoking the backprojector.
    '''
    reco = pyronn_layers.fan_backprojection2d(
        sinogram=grad,
        sinogram_shape=op.get_attr("projection_shape"),
        volume_shape=op.get_attr("volume_shape"),
        volume_origin=op.get_attr("volume_origin"),
        detector_origin=op.get_attr("detector_origin"),
        volume_spacing=op.get_attr("volume_spacing"),
        detector_spacing=op.get_attr("detector_spacing"),
        source_2_isocenter_distance=op.get_attr("source_2_isocenter_distance"),
        source_2_detector_distance=op.get_attr("source_2_detector_distance"),
        central_ray_vectors=op.get_attr("central_ray_vectors"),
    )
    return [reco]