Ejemplo n.º 1
0
def fan_projection2d(volume, 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_projection2d layer.
    """
    batch = np.shape(volume)[0]
    return pyronn_layers.fan_projection2d(
        volume,
        projection_shape=geometry.sinogram_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.º 2
0
def _backproject_grad(op, grad):
    '''
        Compute the gradient of the backprojector op by invoking the forward projector.
    '''
    proj = pyronn_layers.fan_projection2d(
        volume=grad,
        projection_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 [
        proj,
        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.º 3
0
def fan_projection2d(volume, 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_projection2d layer.
    """
    return pyronn_layers.fan_projection2d(volume,
                                           volume_shape=geometry.volume_shape,
                                           projection_shape=geometry.sinogram_shape,
                                           volume_origin=geometry.tensor_proto_volume_origin,
                                           detector_origin=geometry.tensor_proto_detector_origin,
                                           volume_spacing=geometry.tensor_proto_volume_spacing,
                                           detector_spacing=geometry.tensor_proto_detector_spacing,
                                           source_2_isocenter_distance=geometry.source_isocenter_distance,
                                           source_2_detector_distance=geometry.source_detector_distance,
                                           central_ray_vectors=geometry.tensor_proto_central_ray_vectors)