def parallel_projection2d(volume, geometry): """ Wrapper function for making the layer call. Args: volume: Input volume to project. geometry: Corresponding GeometryParallel2D Object defining parameters. Returns: Initialized lme_custom_ops.parallel_projection2d layer. """ batch = tf.shape(volume)[0] return pyronn_layers.parallel_projection2d( volume, projection_shape=geometry.sinogram_shape, volume_origin=tf.cast(tf.broadcast_to( geometry.volume_origin, tf.concat([[batch], tf.shape(geometry.volume_origin)], axis=0)), dtype=tf.float32), detector_origin=tf.cast(tf.broadcast_to( geometry.detector_origin, tf.concat([[batch], tf.shape(geometry.detector_origin)], axis=0)), dtype=tf.float32), volume_spacing=tf.cast(tf.broadcast_to( geometry.volume_spacing, tf.concat([[batch], tf.shape(geometry.volume_spacing)], axis=0)), dtype=tf.float32), detector_spacing=tf.cast(tf.broadcast_to( geometry.detector_spacing, tf.concat([[batch], tf.shape(geometry.detector_spacing)], axis=0)), dtype=tf.float32), ray_vectors=tf.cast(tf.broadcast_to( geometry.ray_vectors, tf.concat([[batch], tf.shape(geometry.ray_vectors)], axis=0)), dtype=tf.float32))
def parallel_projection2d(volume, geometry): """ Wrapper function for making the layer call. Args: volume: Input volume to project. geometry: Corresponding GeometryParallel2D Object defining parameters. Returns: Initialized lme_custom_ops.parallel_projection2d layer. """ batch = np.shape(volume)[0] return pyronn_layers.parallel_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)]), ray_vectors=np.broadcast_to(geometry.ray_vectors, [batch, *np.shape(geometry.ray_vectors)]))
def parallel_projection2d(volume, geometry): """ Wrapper function for making the layer call. Args: volume: Input volume to project. geometry: Corresponding GeometryParallel2D Object defining parameters. Returns: Initialized lme_custom_ops.parallel_projection2d layer. """ return pyronn_layers.parallel_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, ray_vectors=geometry.tensor_proto_ray_vectors)
def _backproject_grad(op, grad): ''' Compute the gradient of the backprojector op by invoking the forward projector. ''' proj = pyronn_layers.parallel_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], ray_vectors=op.inputs[6], ) 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]) ]