printing = 0  # (0 is OFF, 1 is ON)
device = 'gpu'  # or cpu

g = FGP_TV(alpha, inner_TV_iter, tolerance, methodTV, nonnegativity_constraint,
           printing, device)

x_init = A3D.volume_geometry.allocate()

# Allocate space for the channel-wise reconstruction
fista_sol_TV_channel_wise = A3D_chan.volume_geometry.allocate()

for i in range(ag.channels):

    # Setup L2NormSquarred fidelity term, for each channel
    f = FunctionOperatorComposition(
        0.5 * L2NormSquared(b=data.subset(channel=i)), A3D)

    # Run FISTA
    fista = FISTA(x_init=x_init, f=f, g=g)
    fista.max_iteration = 100
    fista.update_objective_interval = 50
    fista.run(400, verbose=True, callback=show_data_3D)
    np.copyto(fista_sol_TV_channel_wise.array[i], fista.get_output().array)

#%% show reconstruction

show_4D_channel_slice(fista_sol_TV_channel_wise, 5,
                      'FISTA TV channel-wise reconstruction')
show_4D_channel_slice(fista_sol_TV_channel_wise, 10,
                      'FISTA TV channel-wise reconstruction')
show_4D_channel_slice(fista_sol_TV_channel_wise, 15,
示例#2
0
      np.abs(data.geometry.dist_source_center)) / \
      np.abs(data.geometry.dist_source_center)

# Voxel size is detector pixel size divided by mag
voxel_size_h = data.geometry.pixel_size_h / mag

# Construct the appropriate ImageGeometry
ig = ImageGeometry(voxel_num_x=N,
                   voxel_num_y=N,
                   voxel_num_z=data.geometry.pixel_num_v,
                   voxel_size_x=voxel_size_h, 
                   voxel_size_y=voxel_size_h,
                   voxel_size_z=voxel_size_h)

# Permute array and convert angles to radions for ASTRA; delete old data.
data2 = data.subset(dimensions=['vertical','angle','horizontal'])
data2.geometry = data.geometry
data2.geometry.angles = -data2.geometry.angles/180*numpy.pi
del data

# Extract the Acquisition geometry for setting up projector.
ag = data2.geometry

# Set up the Projector (AcquisitionModel) using ASTRA on GPU
Aop = AstraProjector3DSimple(ig, ag)

# So and show simple backprojection
z = Aop.adjoint(data2)
plt.figure()
plt.imshow(z.subset(horizontal_x=1000).as_array())
plt.show()
data_rel = numpy.transpose(data_rel,(0,2,1))

# Set angles to use
angles = numpy.linspace(-numpy.pi,numpy.pi,num_angles,endpoint=False)

# Create 3D acquisition geometry and acquisition data
ag = AcquisitionGeometry('parallel',
                         '3D',
                         angles,
                         pixel_num_h=imsize,
                         pixel_num_v=imsize)
b = AcquisitionData(data_rel, geometry=ag)

# Reduce to single (noncentral) slice by extracting relevant parameters from data and its
# geometry. Perhaps create function to extract central slice automatically?
b2d = b.subset(vertical=128)
ag2d = AcquisitionGeometry('parallel',
                         '2D',
                         ag.angles,
                         pixel_num_h=ag.pixel_num_h)
b2d.geometry = ag2d

# Create 2D image geometry
ig2d = ImageGeometry(voxel_num_x=ag2d.pixel_num_h, 
                     voxel_num_y=ag2d.pixel_num_h)

# Create GPU projector/backprojector operator with ASTRA.
Aop = AstraProjectorSimple(ig2d,ag2d,'gpu')

# Demonstrate operator is working by applying simple backprojection.
z = Aop.adjoint(b2d)
示例#4
0
# Geometric info is taken from the txt-file in the same dir as the mat-file
ag = AcquisitionGeometry('cone',
                         '3D',
                         angles,
                         pixel_num_h=num_pixels_h,
                         pixel_size_h=0.25,
                         pixel_num_v=num_pixels_v,
                         pixel_size_v=0.25,
                         dist_source_center=233.0,
                         dist_center_detector=245.0,
                         channels=num_channels)
data = AcquisitionData(X, geometry=ag)

# Reduce to central slice by extracting relevant parameters from data and its
# geometry. Perhaps create function to extract central slice automatically?
data2d = data.subset(vertical=40)
ag2d = AcquisitionGeometry('cone',
                           '2D',
                           ag.angles,
                           pixel_num_h=ag.pixel_num_h,
                           pixel_size_h=ag.pixel_size_h,
                           pixel_num_v=1,
                           pixel_size_v=ag.pixel_size_h,
                           dist_source_center=ag.dist_source_center,
                           dist_center_detector=ag.dist_center_detector,
                           channels=ag.channels)
data2d.geometry = ag2d

# Set up 2D Image Geometry.
# First need the geometric magnification to scale the voxel size relative
# to the detector pixel size.