Ejemplo n.º 1
0
def c_sirt(tomo, center, recon, theta, **kwargs):
    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    use_accel = 1 if kwargs['accelerated'] else 0

    LIB_TOMOPY.sirt.restype = dtype.as_c_void_p()
    return LIB_TOMOPY.sirt(
            dtype.as_c_float_p(tomo),
            dtype.as_c_int(dy),
            dtype.as_c_int(dt),
            dtype.as_c_int(dx),
            dtype.as_c_float_p(center),
            dtype.as_c_float_p(theta),
            dtype.as_c_float_p(recon),
            dtype.as_c_int(kwargs['num_gridx']),
            dtype.as_c_int(kwargs['num_gridy']),
            dtype.as_c_int(kwargs['num_iter']),
            dtype.as_c_int(use_accel),
            dtype.as_c_int(kwargs['pool_size']),
            dtype.as_c_char_p(kwargs['interpolation']),
            dtype.as_c_char_p(kwargs['device']),
            dtype.as_c_int_p(kwargs['grid_size']),
            dtype.as_c_int_p(kwargs['block_size']))
Ejemplo n.º 2
0
def c_accel_sirt(tomo, center, recon, theta, **kwargs):

    if LIB_TOMOPY_ACCEL is None:
        return MissingLibrary("SIRT ACCEL")

    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    LIB_TOMOPY_ACCEL.cxx_sirt.restype = dtype.as_c_void_p()
    return LIB_TOMOPY_ACCEL.cxx_sirt(
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(dy),
        dtype.as_c_int(dt),
        dtype.as_c_int(dx),
        dtype.as_c_float_p(center),
        dtype.as_c_float_p(theta),
        dtype.as_c_float_p(recon),
        dtype.as_c_int(kwargs['num_gridx']),
        dtype.as_c_int(kwargs['num_gridy']),
        dtype.as_c_int(kwargs['num_iter']),
        dtype.as_c_int(kwargs['pool_size']),
        dtype.as_c_char_p(kwargs['interpolation']),
        dtype.as_c_char_p(kwargs['device']),
        dtype.as_c_int_p(kwargs['grid_size']),
        dtype.as_c_int_p(kwargs['block_size']))
Ejemplo n.º 3
0
def c_sirt(tomo, center, recon, theta, **kwargs):

    if kwargs['accelerated']:
        return c_accel_sirt(tomo, center, recon, theta, **kwargs)

    else:
        if len(tomo.shape) == 2:
            # no y-axis (only one slice)
            dy = 1
            dt, dx = tomo.shape
        else:
            dy, dt, dx = tomo.shape

        kwargs['ind_block'] = np.arange(1, dtype='int32')
        kwargs['num_block'] = 1

        LIB_TOMOPY_RECON.bart.restype = dtype.as_c_void_p()
        return LIB_TOMOPY_RECON.bart(dtype.as_c_float_p(tomo),
                                     dtype.as_c_int(dy), dtype.as_c_int(dt),
                                     dtype.as_c_int(dx),
                                     dtype.as_c_float_p(center),
                                     dtype.as_c_float_p(theta),
                                     dtype.as_c_float_p(recon),
                                     dtype.as_c_int(kwargs['num_gridx']),
                                     dtype.as_c_int(kwargs['num_gridy']),
                                     dtype.as_c_int(kwargs['num_iter']),
                                     dtype.as_c_int(kwargs['num_block']),
                                     dtype.as_c_int_p(kwargs['ind_block']))
Ejemplo n.º 4
0
def c_pml_quad(tomo, center, recon, theta, **kwargs):
    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    kwargs['ind_block'] = np.arange(1, dtype='int32')
    kwargs['num_block'] = 1

    LIB_TOMOPY_RECON.ospml_quad.restype = dtype.as_c_void_p()
    return LIB_TOMOPY_RECON.ospml_quad(
        dtype.as_c_float_p(tomo),
        dtype.as_c_int(dy),
        dtype.as_c_int(dt),
        dtype.as_c_int(dx),
        dtype.as_c_float_p(center),
        dtype.as_c_float_p(theta),
        dtype.as_c_float_p(recon),
        dtype.as_c_int(kwargs['num_gridx']),
        dtype.as_c_int(kwargs['num_gridy']),
        dtype.as_c_int(kwargs['num_iter']),
        dtype.as_c_float_p(kwargs['reg_par']),
        dtype.as_c_int(kwargs['num_block']),
        dtype.as_c_int_p(kwargs['ind_block']),
    )
Ejemplo n.º 5
0
def c_osem(tomo, center, recon, theta, **kwargs):
    if len(tomo.shape) == 2:
        # no y-axis (only one slice)
        dy = 1
        dt, dx = tomo.shape
    else:
        dy, dt, dx = tomo.shape

    LIB_TOMOPY_RECON.osem.restype = dtype.as_c_void_p()
    return LIB_TOMOPY_RECON.osem(dtype.as_c_float_p(tomo), dtype.as_c_int(dy),
                                 dtype.as_c_int(dt), dtype.as_c_int(dx),
                                 dtype.as_c_float_p(center),
                                 dtype.as_c_float_p(theta),
                                 dtype.as_c_float_p(recon),
                                 dtype.as_c_int(kwargs['num_gridx']),
                                 dtype.as_c_int(kwargs['num_gridy']),
                                 dtype.as_c_int(kwargs['num_iter']),
                                 dtype.as_c_int(kwargs['num_block']),
                                 dtype.as_c_int_p(kwargs['ind_block']))