Beispiel #1
0
def phrt(im, plan, method=4, nr_threads=2):
    """Process a tomographic projection image with the selected phase retrieval algorithm.

	Parameters
	----------
	im : array_like
		Flat corrected image data as numpy array.

	plan : structure
		Structure with pre-computed data (see prepare_plan function)

	method : int 
		Phase retrieval filter {1 = TIE (default), 2 = CTF, 3 = CTF first-half sine, 4 = Quasiparticle, 
		5 = Quasiparticle first half sine}.

	nr_threads : int 
		Number of threads to be used in the computation of FFT by PyFFTW

	Credits
	-------
	Julian Moosmann, KIT (Germany) is acknowledged for this code
		
	"""
    # Extract plan values:
    dim0_o = plan['dim0']
    dim1_o = plan['dim1']
    n_pad0 = plan['npad0']
    n_pad1 = plan['npad1']
    marg0 = (n_pad0 - dim0_o) / 2
    marg1 = (n_pad1 - dim1_o) / 2
    filter = plan['filter']

    # Pad image (if required):
    im = padImage(im, n_pad0, n_pad1)

    # (Un)comment the following two lines to use PyFFTW:
    n_byte_align(im, simd_alignment)
    im = fft2(im - 1, threads=nr_threads)

    # (Un)comment the following line to use NumPy:
    #im = fft2(im - 1)

    # Apply phase retrieval filter:
    im = filter * im

    # (Un)comment the following two lines to use PyFFTW:
    n_byte_align(im, simd_alignment)
    im = real(ifft2(im, threads=nr_threads))

    # (Un)comment the following line to use NumPy:
    #im = real(ifft2(im))

    # Return the negative:
    im = -im

    # Return cropped output:
    return im[marg0:dim0_o + marg0, marg1:dim1_o + marg1]
Beispiel #2
0
def phrt(im, plan, method=4, nr_threads=2):
	"""Process a tomographic projection image with the selected phase retrieval algorithm.

	Parameters
	----------
	im : array_like
		Flat corrected image data as numpy array.

	plan : structure
		Structure with pre-computed data (see prepare_plan function)

	method : int 
		Phase retrieval filter {1 = TIE (default), 2 = CTF, 3 = CTF first-half sine, 4 = Quasiparticle, 
		5 = Quasiparticle first half sine}.

	nr_threads : int 
		Number of threads to be used in the computation of FFT by PyFFTW

	Credits
	-------
	Julian Moosmann, KIT (Germany) is acknowledged for this code
		
	"""
	# Extract plan values:
	dim0_o = plan['dim0']
	dim1_o = plan['dim1']
	n_pad0 = plan['npad0']
	n_pad1 = plan['npad1']
	marg0  = (n_pad0 - dim0_o) / 2
	marg1  = (n_pad1 - dim1_o) / 2
	filter = plan['filter']	
	
	# Pad image (if required):	
	im  = padImage(im, n_pad0, n_pad1) 

	# (Un)comment the following two lines to use PyFFTW:
	n_byte_align(im, simd_alignment) 
	im = fft2(im - 1, threads=nr_threads)			

	# (Un)comment the following line to use NumPy:	
	#im = fft2(im - 1)			

	# Apply phase retrieval filter:
	im = filter * im   

	# (Un)comment the following two lines to use PyFFTW:
	n_byte_align(im, simd_alignment)
	im = real(ifft2(im, threads=nr_threads))	

	# (Un)comment the following line to use NumPy:	
	#im = real(ifft2(im))	

	# Return the negative:
	im = - im

	# Return cropped output:
	return im[marg0:dim0_o + marg0, marg1:dim1_o + marg1]   
Beispiel #3
0
def tiehom2020(im, plan, nr_threads=2):
	"""Process a tomographic projection image with the Generalized TIE-HOM (Paganin et al 2020) 
    phase retrieval algorithm.

	Parameters
	----------
	im : array_like
		Flat corrected image data as numpy array.

	plan : structure
		Structure with pre-computed data (see tiehom_plan function).

	nr_threads : int 
		Number of threads to be used in the computation of FFT by PyFFTW (default = 2).
		
	"""
	# Extract plan values:
	dim0_o = plan['dim0']
	dim1_o = plan['dim1']
	n_pad0 = plan['npad0']
	n_pad1 = plan['npad1']
	marg0 = (n_pad0 - dim0_o) / 2
	marg1 = (n_pad1 - dim1_o) / 2
	den = plan['den']
	mu = plan['mu']

	# Pad image (if required):	
	im = padImage(im, n_pad0, n_pad1) 

	# (Un)comment the following two lines to use PyFFTW:
	n_byte_align(im, simd_alignment) 
	im = rfft2(im, threads=nr_threads)			

	# (Un)comment the following line to use NumPy:
	#im = rfft2(im)

	# Apply Paganin's (pre-computed) formula:
	im = im / den
		
	# (Un)comment the following two lines to use PyFFTW:
	n_byte_align(im, simd_alignment)
	im = irfft2(im, threads=nr_threads)
		
	# (Un)comment the following line to use NumPy:
	#im = irfft2(im)
				
	im = im.astype(float32)		
	im = -1 / mu * nplog(im)    		

	# Return cropped output:
	return im[marg0:dim0_o + marg0, marg1:dim1_o + marg1] 
Beispiel #4
0
def tiehom(im, plan, nr_threads=2):
	"""Process a tomographic projection image with the TIE-HOM (Paganin's) phase retrieval algorithm.

	Parameters
	----------
	im : array_like
		Flat corrected image data as numpy array.

	plan : structure
		Structure with pre-computed data (see tiehom_plan function).

	nr_threads : int 
		Number of threads to be used in the computation of FFT by PyFFTW (default = 2).
		
	"""
	# Extract plan values:
	dim0_o = plan['dim0']
	dim1_o = plan['dim1']
	n_pad0 = plan['npad0']
	n_pad1 = plan['npad1']
	marg0 = (n_pad0 - dim0_o) / 2
	marg1 = (n_pad1 - dim1_o) / 2
	den = plan['den']
	mu = plan['mu']

	# Pad image (if required):	
	im = padImage(im, n_pad0, n_pad1) 

	# (Un)comment the following two lines to use PyFFTW:
	n_byte_align(im, simd_alignment) 
	im = rfft2(im, threads=nr_threads)			

	# (Un)comment the following line to use NumPy:
	#im = rfft2(im)

	# Apply Paganin's (pre-computed) formula:
	im = im / den
		
	# (Un)comment the following two lines to use PyFFTW:
	n_byte_align(im, simd_alignment)
	im = irfft2(im, threads=nr_threads)
		
	# (Un)comment the following line to use NumPy:
	#im = irfft2(im)
				
	im = im.astype(float32)		
	im = -1 / mu * nplog(im)    		

	# Return cropped output:
	return im[marg0:dim0_o + marg0, marg1:dim1_o + marg1] 
def reconstruct(im, angles, angles_projfrom, angles_projto, offset,
                logtransform, param1, circle, scale, pad, method, zerone_mode,
                dset_min, dset_max, corr_offset, postprocess_required,
                convert_opt, crop_opt, start, end, outpath, sino_idx,
                downsc_factor, logfilename, lock, slice_prefix):
    """Reconstruct a sinogram with FBP algorithm (from ASTRA toolbox).

	Parameters
	----------
	im1 : array_like
		Sinogram image data as numpy array.
	center : float
		Offset of the center of rotation to use for the tomographic 
		reconstruction with respect to the half of sinogram width 
		(default=0, i.e. half width).
	logtransform : boolean
		Apply logarithmic transformation before reconstruction (default=True).
	filter : string
		Filter to apply before the application of the reconstruction algorithm. Filter 
		types are: ram-lak, shepp-logan, cosine, hamming, hann, tukey, lanczos, triangular, 
		gaussian, barlett-hann, blackman, nuttall, blackman-harris, blackman-nuttall, 
		flat-top, kaiser, parzen.
	circle : boolean
		Create a circle in the reconstructed image and set to zero pixels outside the 
		circle (default=False).	
	
	"""
    # Copy required due to multithreading:
    im_f = im

    # Decimate projections if required:
    #if decim_factor > 1:
    #	im = im[::decim_factor,:]

    # Upscale projections (if required):
    if (abs(scale - 1.0) > finfo(float32).eps):
        siz_orig1 = im_f.shape[1]
        im_f = imresize(im_f,
                        (im_f.shape[0], int(round(scale * im_f.shape[1]))),
                        interp='bicubic',
                        mode='F')
        offset = int(offset * scale)

    # Loop for all the required offsets for the center of rotation:
    for i in range(int(round(start)), int(round(end)) + 1, downsc_factor):

        offset = int(round(i / downsc_factor))

        # Apply transformation for changes in the center of rotation:
        if (offset != 0):
            if (offset >= 0):
                im_f = im_f[:, :-offset]

                tmp = im_f[:, 0]  # Get first column
                tmp = tile(tmp, (
                    offset,
                    1))  # Replicate the first column the right number of times
                im_f = concatenate((tmp.T, im_f),
                                   axis=1)  # Concatenate tmp before the image

            else:
                im_f = im_f[:, abs(offset):]

                tmp = im_f[:, im_f.shape[1] - 1]  # Get last column
                tmp = tile(
                    tmp,
                    (abs(offset),
                     1))  # Replicate the last column the right number of times
                im_f = concatenate((im_f, tmp.T),
                                   axis=1)  # Concatenate tmp after the image

        # Downscale projections (without pixel averaging):
        #if downsc_factor > 1:
        #	im = im[:,::downsc_factor]

        # Scale image to [0,1] range (if required):
        if (zerone_mode):

            #print dset_min
            #print dset_max
            #print numpy.amin(im_f[:])
            #print numpy.amax(im_f[:])
            #im_f = (im_f - dset_min) / (dset_max - dset_min)

            # Cheating the whole process:
            im_f = (im_f - numpy.amin(im_f[:])) / (numpy.amax(im_f[:]) -
                                                   numpy.amin(im_f[:]))

        # Apply log transform:
        if (logtransform == True):
            im_f[im_f <= finfo(float32).eps] = finfo(float32).eps
            im_f = -nplog(im_f + corr_offset)

        # Replicate pad image to double the width:
        if (pad):

            dim_o = im_f.shape[1]
            n_pad = im_f.shape[1] + im_f.shape[1] / 2
            marg = (n_pad - dim_o) / 2

            # Pad image:
            #im_f = padSmoothWidth(im_f, n_pad)
            im_f = padImage(im_f, im_f.shape[0], n_pad)

        # Perform the actual reconstruction:
        if (method.startswith('FBP')):
            im_f = recon_astra_fbp(im_f, angles, method, param1)
        elif (method == 'MR-FBP_CUDA'):
            im_f = recon_mr_fbp(im_f, angles)
        elif (method == 'FISTA-TV_CUDA'):
            im_f = recon_fista_tv(im_f, angles, param1, param1)
        elif (method == 'MLEM'):
            im_f = recon_tomopy_iterative(im_f, angles, method, param1)
        elif (method == 'GRIDREC'):
            [im_f, im_f] = recon_gridrec(im_f, im_f, angles, param1)
        else:
            im_f = recon_astra_iterative(im_f, angles, method, param1,
                                         zerone_mode)

        # Crop:
        if (pad):
            im_f = im_f[marg:dim_o + marg, marg:dim_o + marg]

        # Resize (if necessary):
        if (abs(scale - 1.0) > finfo(float32).eps):
            im_f = imresize(im_f, (siz_orig1, siz_orig1),
                            interp='nearest',
                            mode='F')

        # Apply post-processing (if required):
        if postprocess_required:
            im_f = croprescale(im_f, convert_opt, crop_opt)
        else:
            # Create the circle mask for fancy output:
            if (circle == True):
                siz = im_f.shape[1]
                if siz % 2:
                    rang = arange(-siz / 2 + 1, siz / 2 + 1)
                else:
                    rang = arange(-siz / 2, siz / 2)
                x, y = meshgrid(rang, rang)
                z = x**2 + y**2
                a = (z <
                     (siz / 2 - int(round(abs(offset) / downsc_factor)))**2)
                im_f = im_f * a

        # Write down reconstructed image (file name modified with metadata):
        if (i >= 0):
            fname = outpath + slice_prefix + '_' + str(sino_idx).zfill(
                4) + '_proj=' + str(
                    angles_projto - angles_projfrom) + '_col=' + str(
                        (im_f.shape[1] + offset) *
                        downsc_factor).zfill(4) + '_off=+' + str(
                            abs(offset * downsc_factor)).zfill(4) + '.tif'
        else:
            fname = outpath + slice_prefix + '_' + str(sino_idx).zfill(
                4) + '_proj=' + str(
                    angles_projto - angles_projfrom) + '_col=' + str(
                        (im_f.shape[1] + offset) *
                        downsc_factor).zfill(4) + '_off=-' + str(
                            abs(offset * downsc_factor)).zfill(4) + '.tif'

        imsave(fname, im_f)

        # Restore original image for next step:
        im_f = im

        # Write log (atomic procedure - lock used):
        write_log(lock, fname, logfilename)
def reconstruct(im, angles, offset, logtransform, param1, circle, scale, pad,
                method, rolling, roll_shift, zerone_mode, dset_min, dset_max,
                decim_factor, downsc_factor, corr_offset):
    """Reconstruct a sinogram with FBP algorithm (from ASTRA toolbox).

	Parameters
	----------
	im1 : array_like
		Sinogram image data as numpy array.
	center : float
		Offset of the center of rotation to use for the tomographic 
		reconstruction with respect to the half of sinogram width 
		(default=0, i.e. half width).
	logtransform : boolean
		Apply logarithmic transformation before reconstruction (default=True).
	filter : string
		Filter to apply before the application of the reconstruction algorithm. Filter 
		types are: ram-lak, shepp-logan, cosine, hamming, hann, tukey, lanczos, triangular, 
		gaussian, barlett-hann, blackman, nuttall, blackman-harris, blackman-nuttall, 
		flat-top, kaiser, parzen.
	circle : boolean
		Create a circle in the reconstructed image and set to zero pixels outside the 
		circle (default=False).

	Example (using tiffile.py)
	--------------------------
	>>> # Read input (uncorrected) sinogram
	>>> sino_im1 = imread('sino_0050.tif')
	>>>
	>>> # Get flat and dark correction images:
	>>> im_dark = medianize("\project\tomo", "dark*.tif")
	>>> im_flat = medianize("\project\tomo", "flat*.tif")
	>>>
	>>> # Perform flat fielding and normalization:
	>>> sino_im = normalize(sino_im1, (10,10), (0,0), im_dark, im_flat, 50)    
	>>>  
	>>> # Actual reconstruction: 
	>>> out = reconstruct_fbp(sino_im, -3.0)   
	>>> 
	>>> # Save output slice:
	>>> imsave('slice_0050.tif', out)   	
	
	"""

    # Copy images and ensure they are of type float32:
    #im_f = copy(im.astype(float32))
    im_f = im.astype(float32)

    # Decimate projections if required:
    #if decim_factor > 1:
    #	im_f = im_f[::decim_factor,:]

    # Upscale projections (if required):
    if (abs(scale - 1.0) > finfo(float32).eps):
        siz_orig1 = im_f.shape[1]
        im_f = imresize(im_f,
                        (im_f.shape[0], int(round(scale * im_f.shape[1]))),
                        interp='bicubic',
                        mode='F')
        offset = int(offset * scale)

    # Apply transformation for changes in the center of rotation (only for Pelt's code):
    if ((method == 'MR-FBP_CUDA') or (method == 'FISTA-TV_CUDA')):
        offset = int(round(offset))
        if (offset != 0):
            if (offset >= 0):
                im_f = im_f[:, :-offset]

                tmp = im_f[:, 0]  # Get first column
                tmp = tile(tmp, (
                    offset,
                    1))  # Replicate the first column the right number of times
                im_f = concatenate((tmp.T, im_f),
                                   axis=1)  # Concatenate tmp before the image

            else:
                im_f = im_f[:, abs(offset):]

                tmp = im_f[:, im_f.shape[1] - 1]  # Get last column
                tmp = tile(
                    tmp,
                    (abs(offset),
                     1))  # Replicate the last column the right number of times
                im_f = concatenate((im_f, tmp.T),
                                   axis=1)  # Concatenate tmp after the image

    # Downscale projections (without pixel averaging):
    #if downsc_factor > 1:
    #	im_f = im_f[:,::downsc_factor]

    # Sinogram rolling (if required).  It doesn't make sense in limited angle
    # tomography, so check if 180 or 360:
    if ((rolling == True) and (roll_shift > 0)):
        if ((angles - pi) < finfo(float32).eps):
            # Flip the last rows:
            im_f[-roll_shift:, :] = im_f[-roll_shift:, ::-1]
            # Now roll the sinogram:
            im_f = roll(im_f, roll_shift, axis=0)
        elif ((angles - pi * 2.0) < finfo(float32).eps):
            # Only roll the sinogram:
            im_f = roll(im_f, roll_shift, axis=0)

    # Scale image to [0,1] range (if required):
    if (zerone_mode):
        im_f = (im_f - dset_min) / (dset_max - dset_min)

        # Cheating the whole process:
        #im_f = (im_f - numpy.amin(im_f[:])) / (numpy.amax(im_f[:]) -
        #numpy.amin(im_f[:]))

    # Apply log transform:
    if (logtransform == True):
        im_f[im_f <= finfo(float32).eps] = finfo(float32).eps
        im_f = -nplog(im_f + corr_offset)

    # Replicate pad image to double the width:
    if (pad):

        dim_o = im_f.shape[1]
        n_pad = im_f.shape[1] + im_f.shape[1] / 2
        marg = (n_pad - dim_o) / 2

        # Pad image:
        #im_f = padSmoothWidth(im_f, n_pad)
        im_f = padImage(im_f, im_f.shape[0], n_pad)

    # Perform the actual reconstruction:
    if (method.startswith('FBP')):
        im_f = recon_astra_fbp(im_f, angles, method, param1, offset)
    elif (method == 'MR-FBP_CUDA'):
        im_f = recon_mr_fbp(im_f, angles, offset)
    elif (method == 'FISTA-TV_CUDA'):
        lam, fgpiter, tviter = param1.split(":")
        lam = float32(lam)
        fgpiter = int(fgpiter)
        tviter = int(tviter)
        im_f = recon_fista_tv(im_f, angles, lam, fgpiter, tviter, offset)
    else:
        im_f = recon_astra_iterative(im_f, angles, method, param1, zerone_mode,
                                     offset)

    # Crop:
    if (pad):
        im_f = im_f[marg:dim_o + marg, marg:dim_o + marg]

    # Resize (if necessary):
    if (abs(scale - 1.0) > finfo(float32).eps):
        im_f = imresize(im_f, (siz_orig1, siz_orig1),
                        interp='nearest',
                        mode='F')

    # Return output:
    return im_f.astype(float32)
Beispiel #7
0
def phase_retrieval(im, plan, method=1, nr_threads=2):
	"""Process a tomographic projection image with the selected phase retrieval algorithm.

	Parameters
	----------
	im : array_like
		Flat corrected image data as numpy array.
	plan : structure
		Structure with pre-computed data (see prepare_plan function)
	method : int 
		Phase retrieval algorithm {1 = TIE (default), 2 = Born, 3 = Rytov, 4 = Wu}
	nr_threads : int 
		Number of threads to be used in the computation of FFT by PyFFTW
		
	"""
	# Extract plan values:
	dim0_o = plan['dim0']
	dim1_o = plan['dim1']
	n_pad0 = plan['npad0']
	n_pad1 = plan['npad1']
	marg0 = (n_pad0 - dim0_o) / 2
	marg1 = (n_pad1 - dim1_o) / 2
	den = plan['den']
	mu = plan['mu']
	
	# Pad image (if required):	
	im  = padImage(im, n_pad0, n_pad1) 

	# (Un)comment the following two lines to use PyFFTW:
	n_byte_align(im, simd_alignment) 
	im = fft2(im, threads=nr_threads)			

	# (Un)comment the following line to use NumPy:	
	#im = fft2(im)			

	# Apply formula:
	if method == 1:		
		im = im / den
		
		# (Un)comment the following two lines to use PyFFTW:
		n_byte_align(im, simd_alignment)
		im = ifft2(im, threads=nr_threads)
		
		# (Un)comment the following line to use NumPy:
		#im = ifft2(im)
		im = im.astype(complex64)
		 		
		im = real(im)
		im = im.astype(float32)		
		im = -1 / mu * nplog(im)    		

	#
	# WARNING: The following methods are not tested
	#
	elif method == 2:
		im = real(ifft2((im - 1.0) / 2.0) / den)
	elif method == 3:
		im = real(ifft2(nplog(im) / 2.0) / den)
	elif method == 4:       
		im = real(ifft2(im / den))
		im = -1 / 2 * (delta / beta) * nplog(im)    

	# Return cropped output:
	return im[marg0:dim0_o + marg0, marg1:dim1_o + marg1]   
Beispiel #8
0
def reconstruct(im, angles, offset, logtransform, recpar, circle, scale, pad,
                method, zerone_mode, dset_min, dset_max, corr_offset, rolling,
                roll_shift, tmppath):
    """Reconstruct a sinogram with the specified reconstruction method (or algorithm).

	Parameters
	----------
	im1 : array_like
		Sinogram image data as numpy array.
	center : float
		Offset of the center of rotation to use for the tomographic 
		reconstruction with respect to the half of sinogram width 
		(default=0, i.e. half width).
	logtransform : boolean
		Apply logarithmic transformation before reconstruction (default=True).
	filter : string
		Filter to apply before the application of the reconstruction algorithm. Filter 
		types are: ram-lak, shepp-logan, cosine, hamming, hann, tukey, lanczos, triangular, 
		gaussian, barlett-hann, blackman, nuttall, blackman-harris, blackman-nuttall, 
		flat-top, kaiser, parzen.
	circle : boolean
		Create a circle in the reconstructed image and set to zero pixels outside the 
		circle (default=False).	
	
	"""
    # Upscale projections (if required):
    if (abs(scale - 1.0) > finfo(float32).eps):
        siz_orig1 = im.shape[1]
        im = imresize(im, (im.shape[0], int(round(scale * im.shape[1]))),
                      interp='bicubic',
                      mode='F')
        offset = int(offset * scale)

    # Apply transformation for changes in the center of rotation:
    if ((method == 'GRIDREC') or (method == 'MR-FBP_CUDA')
            or (method == 'FISTA-TV_CUDA')):
        offset = int(round(offset))
        if (offset != 0):
            if (offset >= 0):
                im = im[:, :-offset]

                tmp = im[:, 0]  # Get first column
                tmp = tile(tmp, (
                    offset,
                    1))  # Replicate the first column the right number of times
                im = concatenate((tmp.T, im),
                                 axis=1)  # Concatenate tmp before the image

            else:
                im = im[:, abs(offset):]

                tmp = im[:, im.shape[1] - 1]  # Get last column
                tmp = tile(
                    tmp,
                    (abs(offset),
                     1))  # Replicate the last column the right number of times
                im = concatenate((im, tmp.T),
                                 axis=1)  # Concatenate tmp after the image

    # Sinogram rolling (if required).  It doesn't make sense in limited angle tomography, so check if 180 or 360:
    if ((rolling == True) and (roll_shift > 0)):
        if ((angles - pi) < finfo(float32).eps):
            # Flip the last rows:
            im[-roll_shift:, :] = im[-roll_shift:, ::-1]
            # Now roll the sinogram:
            im = roll(im, roll_shift, axis=0)
        elif ((angles - pi * 2.0) < finfo(float32).eps):
            # Only roll the sinogram:
            im = roll(im, roll_shift, axis=0)

    # Scale image to [0,1] range (if required):
    if (zerone_mode):

        im = (im - dset_min) / (dset_max - dset_min)

        # Cheating the whole process:
        #im = (im - numpy.amin(im[:])) / (numpy.amax(im[:]) - numpy.amin(im[:]))

    # Apply log transform:
    im[im <= finfo(float32).eps] = finfo(float32).eps
    if (logtransform == True):
        im = -nplog(im + corr_offset)

    # Replicate pad image to double the width:
    if (pad):

        dim_o = im.shape[1]
        n_pad = im.shape[1] + im.shape[1] / 2
        marg = (n_pad - dim_o) / 2

        # Pad image:
        if (method == 'GRIDREC'):
            im = padSmoothWidth(im, n_pad)
        else:
            im = padImage(im, im.shape[0], n_pad)

    # Perform the actual reconstruction:
    if (method.startswith('FBP')):
        im = recon_astra_fbp(im, angles, method, recpar, offset)
    elif (method == 'MR-FBP_CUDA'):
        im = recon_mr_fbp(im, angles, offset)
    elif (method == 'FISTA-TV_CUDA'):
        lam, fgpiter, tviter = recpar.split(":")
        lam = float32(lam)
        fgpiter = int(fgpiter)
        tviter = int(tviter)
        im = recon_fista_tv(im, angles, lam, fgpiter, tviter, offset)
    #elif (method == 'SIRT-FBP_CUDA'):
    #	im = recon_sirt_fbp(im, angles, int(recpar), tmppath )
    #	# Clean SIRT-FBP cache:
    #
    elif (method == 'GRIDREC'):
        [im, im] = recon_gridrec(im, im, angles, recpar)
    else:
        im = recon_astra_iterative(im, angles, method, recpar, zerone_mode,
                                   offset)

    # Crop:
    if (pad):
        im = im[marg:dim_o + marg, marg:dim_o + marg]

    # Resize (if necessary):
    if (abs(scale - 1.0) > finfo(float32).eps):
        im = imresize(im, (siz_orig1, siz_orig1), interp='nearest', mode='F')

    # Return output:
    return im.astype(float32)