예제 #1
0
def fbp(proj, geo, angles, filter=None, verbose=False, **kwargs):
    __doc__ = FDK.__doc__
    if geo.mode != 'parallel':
        raise ValueError("Only use FBP for parallel beam. Check geo.mode.")
    geox = copy.deepcopy(geo)
    geox.check_geo(angles)
    proj_filt = filtering(copy.deepcopy(proj), geox, angles, parker=False, verbose=verbose)
    res = Atb(proj_filt, geo, angles) * geo.DSO / geo.DSD

    return res
예제 #2
0
def fbp(proj, geo, angles, **kwargs):
    __doc__ = FDK.__doc__
    if geo.mode != 'parallel':
        raise ValueError("Only use FBP for parallel beam. Check geo.mode.")
    geox = copy.deepcopy(geo)
    geox.check_geo(angles)
    if 'verbose' in kwargs:
        verbose = kwargs['verbose']
    else:
        verbose = False

    proj_filt = filtering(copy.deepcopy(proj),
                          geox,
                          angles,
                          parker=False,
                          verbose=verbose)
    res = Atb(proj_filt, geo, angles) * geo.DSO / geo.DSD

    return res
예제 #3
0
def fbp(proj, geo, angles, **kwargs):  # noqa: D103
    __doc__ = FDK.__doc__  # noqa: F841
    if geo.mode != "parallel":
        raise ValueError("Only use FBP for parallel beam. Check geo.mode.")
    geox = copy.deepcopy(geo)
    geox.check_geo(angles)
    if "verbose" in kwargs:
        verbose = kwargs["verbose"]
    else:
        verbose = False
    if "gpuids" in kwargs:
        gpuids = kwargs["gpuids"]
    else:
        gpuids = None

    proj_filt = filtering(copy.deepcopy(proj),
                          geox,
                          angles,
                          parker=False,
                          verbose=verbose)
    res = Atb(proj_filt, geo, angles, gpuids=gpuids) * geo.DSO / geo.DSD

    return res
예제 #4
0
def FDK(proj, geo, angles, **kwargs):
    """
    solves CT image reconstruction.

    :param proj: np.array(dtype=float32),
    Data input in the form of 3d

    :param geo: tigre.utilities.geometry.Geometry
    Geometry of detector and image (see examples/Demo code)

    :param angles: np.array(dtype=float32)
    Angles of projection, shape = (nangles,3) or (nangles,)

    :param filter: str
    Type of filter used for backprojection
    opts: "shep_logan"
          "cosine"
          "hamming"
          "hann"

    :param verbose: bool
    Feedback print statements for algorithm progress

    :param kwargs: dict
    keyword arguments

    :return: np.array(dtype=float32)

    Usage:
    -------
    >>> import tigre
    >>> import tigre.algorithms as algs
    >>> import numpy
    >>> from tigre.demos.Test_data import data_loader
    >>> geo = tigre.geometry(mode='cone',default_geo=True,
    >>>                         nVoxel=np.array([64,64,64]))
    >>> angles = np.linspace(0,2*np.pi,100)
    >>> src_img = data_loader.load_head_phantom(geo.nVoxel)
    >>> proj = tigre.Ax(src_img,geo,angles)
    >>> output = algs.FDK(proj,geo,angles)

    tigre.demos.run() to launch ipython notebook file with examples.

    --------------------------------------------------------------------
    This file is part of the TIGRE Toolbox

    Copyright (c) 2015, University of Bath and
                        CERN-European Organization for Nuclear Research
                        All rights reserved.

    License:            Open Source under BSD.
                        See the full license at
                        https://github.com/CERN/TIGRE/license.txt

    Contact:            [email protected]
    Codes:              https://github.com/CERN/TIGRE/
    --------------------------------------------------------------------
    Coded by:           MATLAB (original code): Ander Biguri
                        PYTHON : Reuben Lindroos
    """
    if "niter" in kwargs:
        kwargs.pop("niter")
    if "verbose" in kwargs:
        verbose = kwargs["verbose"]
    else:
        verbose = False

    if "gpuids" in kwargs:
        gpuids = kwargs["gpuids"]
    else:
        gpuids = None

    geo = copy.deepcopy(geo)
    geo.check_geo(angles)
    geo.checknans()
    if "filter" in kwargs:
        filter = kwargs["filter"]
    else:
        filter = None
    if filter is not None:
        geo.filter = kwargs["filter"]
    # Weight
    proj_filt = np.zeros(proj.shape, dtype=np.float32)
    for ii in range(angles.shape[0]):
        xv = (np.arange((-geo.nDetector[1] / 2) + 0.5, 1 +
                        (geo.nDetector[1] / 2) - 0.5) * geo.dDetector[1])
        yv = (np.arange((-geo.nDetector[0] / 2) + 0.5, 1 +
                        (geo.nDetector[0] / 2) - 0.5) * geo.dDetector[0])
        (yy, xx) = np.meshgrid(xv, yv)

        w = geo.DSD[0] / np.sqrt((geo.DSD[0]**2 + xx**2 + yy**2))
        proj_filt[ii] = copy.deepcopy(proj[ii]) * w

    proj_filt = filtering(proj_filt,
                          geo,
                          angles,
                          parker=False,
                          verbose=verbose)
    # m = {
    #     'py_projfilt': proj_filt,
    #
    # }
    # scipy.io.savemat('Tests/Filter_data', m)
    res = Atb(proj_filt, geo, geo.angles, "FDK", gpuids=gpuids)
    # res = 0
    # res = Atb(proj,geo,angles,'FDK')
    return res
예제 #5
0
def FDK(proj, geo, angles, filter=None,verbose=False):
    ('\n'
     'FDK solves Cone Beam CT image reconstruction'
     '\n'
     'Parameters \n'
     '-------------------------------------------------------------------\n'
     '\n'
     'proj:         Data input in the form of 3d, np.array(dtype=float32)\n'
     '\n'
     'geo:          Geometry of detector and image (see examples/Demo code)\n'
     '\n'
     'alpha:        1d array of angles corresponding to image data, np.array(dtype=float32)\n'
     '\n'
     'filter:       default="ram_lak" \n'
     '              opts: \n'
     '                  "shep_logan"'
     '                  "cosine"   '
     '                  "hamming" '
     '                  "hann" '
     'Examples \n'
     '---------------------------------------------------------------------------\n'
     'See Demos/Example code for further instructions.\n'
     '---------------------------------------------------------------------------'
     '\n'
     """This file is part of the TIGRE Toolbox

        Copyright (c) 2015, University of Bath and
                            CERN-European Organization for Nuclear Research
                            All rights reserved.

        License:            Open Source under BSD.
                            See the full license at
                            https://github.com/CERN/TIGRE/license.txt

        Contact:            [email protected]
        Codes:              https://github.com/CERN/TIGRE/
      --------------------------------------------------------------------------
        Coded by:          MATLAB (original code): Ander Biguri
                           PYTHON : Reuben Lindroos,Sam Loescher, """)
    geo = copy.deepcopy(geo)
    geo.check_geo(angles)
    if filter is not None:
        geo.filter = filter
    # Weight
    proj_filt = np.zeros(proj.shape, dtype=np.float32)
    for ii in range(angles.shape[0]):
        xv = np.arange((-geo.nDetector[1] / 2) + 0.5, 1 + (geo.nDetector[1] / 2) - 0.5) * geo.dDetector[1]
        yv = np.arange((-geo.nDetector[0] / 2) + 0.5, 1 + (geo.nDetector[0] / 2) - 0.5) * geo.dDetector[0]
        (xx, yy) = np.meshgrid(xv, yv)

        w = geo.DSD[0] / np.sqrt((geo.DSD[0] ** 2 + xx ** 2 + yy ** 2))
        proj_filt[ii] = proj[ii] * w

    proj_filt = filtering(proj_filt, geo, angles, parker=False,verbose=verbose)
    # m = {
    #     'py_projfilt': proj_filt,
    #
    # }
    # scipy.io.savemat('Tests/Filter_data', m)
    res = Atb(proj_filt, geo, geo.angles, 'FDK')
    # res = 0
    # res = Atb(proj,geo,angles,'FDK')
    return res
예제 #6
0
def FDK(proj, geo, angles, filter='ram_lak', verbose=False, **kwargs):
    """
    solves CT image reconstruction.

    :param proj: np.array(dtype=float32),
     Data input in the form of 3d

    :param geo: tigre.utilities.geometry.Geometry
     Geometry of detector and image (see examples/Demo code)

    :param angles: np.array(dtype=float32)
     Angles of projection, shape = (nangles,3) or (nangles,)

    :param filter: str
     Type of filter used for backprojection
     opts: "shep_logan"
           "cosine"
           "hamming"
           "hann"

    :param verbose: bool
     Feedback print statements for algorithm progress

    :param kwargs: dict
     keyword arguments

    :return: np.array(dtype=float32)

    Usage:
    -------
    >>> import tigre
    >>> import tigre.algorithms as algs
    >>> import numpy
    >>> from tigre.demos.Test_data import data_loader
    >>> geo = tigre.geometry(mode='cone',default_geo=True,
    >>>                         nVoxel=np.array([64,64,64]))
    >>> angles = np.linspace(0,2*np.pi,100)
    >>> src_img = data_loader.load_head_phantom(geo.nVoxel)
    >>> proj = tigre.Ax(src_img,geo,angles)
    >>> output = algs.FDK(proj,geo,angles)

    tigre.demos.run() to launch ipython notebook file with examples.


    --------------------------------------------------------------------
    This file is part of the TIGRE Toolbox

    Copyright (c) 2015, University of Bath and
                        CERN-European Organization for Nuclear Research
                        All rights reserved.

    License:            Open Source under BSD.
                        See the full license at
                        https://github.com/CERN/TIGRE/license.txt

    Contact:            [email protected]
    Codes:              https://github.com/CERN/TIGRE/
  ----------------------------------------------------------------------
    Coded by:          MATLAB (original code): Ander Biguri
                       PYTHON : Reuben Lindroos


    """

    if 'niter' in kwargs:
        kwargs.pop('niter')

    geo = copy.deepcopy(geo)
    geo.check_geo(angles)
    geo.checknans()
    if filter is not None:
        geo.filter = filter
    # Weight
    proj_filt = np.zeros(proj.shape, dtype=np.float32)
    for ii in range(angles.shape[0]):
        xv = np.arange((-geo.nDetector[1] / 2) + 0.5, 1 + (geo.nDetector[1] / 2) - 0.5) * geo.dDetector[1]
        yv = np.arange((-geo.nDetector[0] / 2) + 0.5, 1 + (geo.nDetector[0] / 2) - 0.5) * geo.dDetector[0]
        (yy, xx) = np.meshgrid(xv, yv)

        w = geo.DSD[0] / np.sqrt((geo.DSD[0] ** 2 + xx ** 2 + yy ** 2))
        proj_filt[ii] = copy.deepcopy(proj[ii]) * w

    proj_filt = filtering(proj_filt, geo, angles, parker=False, verbose=verbose)
    # m = {
    #     'py_projfilt': proj_filt,
    #
    # }
    # scipy.io.savemat('Tests/Filter_data', m)
    res = Atb(proj_filt, geo, geo.angles, 'FDK')
    # res = 0
    # res = Atb(proj,geo,angles,'FDK')
    return res