Top Banner
The ASTRA Tomography Toolbox 16 January 2019 Introduction
34

The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

May 07, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

The ASTRA Tomography Toolbox16 January 2019

Introduction

Page 2: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Today

• Introduction to ASTRA

• Exercises

• More on ASTRA usage

• Exercises

Page 3: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

About me

Willem Jan Palenstijn

Scientific Software Developer

Computational Imaging group

Center for Mathematics & Computer Science (CWI), Amsterdam

Lead developer on ASTRA Toolbox

Page 4: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

What is ASTRA?

ASTRA provides fast and flexible building blocks for 2D/3D tomographic reconstruction, aimed at algorithm developers and researchers.

Flexible algorithms and geometries

PowerfulC++ and CUDA

Easy to useMATLAB and Python interface

FreeOpen source, cross-platform

Page 5: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

History

The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and post-docs

• Work started in October 2007

• Initial goal: reduced implementation work for internal PhD projects

• Later on: interest from external labs and companies

• E.g. ESRF (France) and FEI (The Netherlands, now ThermoFisher)

• First open source release in August 2012

• Active development continues

• Now jointly by Vision Lab and CWI

Page 6: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Features

Geometries:• 2D parallel and fan beam

• 3D parallel and cone beam

• All with fully flexible source/detector positioning

Basic reconstruction algorithms:• FBP, FDK reconstruction

• Iterative SIRT, CGLS reconstruction

Primitives for building your own algorithms:• FP, BP

Page 7: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Non-Features

Data I/O

Data alignment, preprocessing

Matched GPU FP, BP operators.• CPU FP, BP are matched; GPU are not

Modern advanced reconstruction algorithms

Page 8: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Tomography as linear equations

Linear (integral) projection model:

• Projection of background (air or vacuum) is zero

• Projection depends linearly on sample thickness and density

Page 9: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Tomography as linear equations

ASTRA uses a linear line (or strip) integral model, and assumes input projection data has this form.

For HAADF-STEM, raw data satisfies this. For most modalities (TEM, X-ray transmission), input data depends exponentially on material density/thickness (cf. Lambert-Beer’s law).

Raw X-ray data: Linearized (or normalized, flat-fielded, …) data:

Page 10: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Usage

• Directly from Matlab or Python

• Using ``operators’’ (SPOT in Matlab, scipy.LinearOperator in Python)

• Integrated into other software• ODL, TomoPy, Savu, Inspect3D, …

The next part of this talk will go into more detail.

Page 11: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Scope of today

ASTRA can be used for:

• 2D tomography using CPU

• 2D tomography using GPU

• 3D tomography using GPU

• All from Matlab and Python

The exercise sessions today will focus on Matlab+2D/CPU.

Tomorrow we will look at 3D GPU usage.

Page 12: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

volume geometry• volume size

• number of pixels/voxels

volume geometry

options: 2D and 3D

limitation: pixel size should be 1x1, volume centred around origin

Page 13: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

volume geometry (2D)

vol_geom = astra_create_vol_geom(5, 5);

𝑥

𝑦1

number of rows (y)

number of columns (x)

volume geometry

Page 14: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

volume geometry (3D)

vol_geom = astra_create_vol_geom(5, 5, 5);

𝑥

𝑦

𝑧

number of slices (z)number of rows (y)

number of columns (x)

volume geometry

Page 15: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

volume data• place to store data (e.g. reconstruction)

• In C++: float*

• In MATLAB/Python: id

• links to volume geometry

volume geometry

volume data

Page 16: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

volume data (2D)

reconstruction_id = astra_mex_data2d(‘create’, ’-vol’, vol_geom);reconstruction_id = astra_mex_data2d(‘create’, ’-vol’, vol_geom, 0);reconstruction_id = astra_mex_data2d(‘create’, ’-vol’, vol_geom, V);

astra_mex_data2d(‘store’, reconstruction_id , 0);astra_mex_data2d(‘store’, reconstruction_id , V);

reconstruction = astra_mex_data2d(‘get’, reconstruction_id );

𝑥

𝑦

row: x-axis

column: inverse y-axis

pixel (0,0)

volume geometry

volume data

astra_mex_data2d(‘delete’, reconstruction_id);

Page 17: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

volume data (3D)

reconstruction_id = astra_mex_data3d(‘create’, ’-vol’, vol_geom);reconstruction_id = astra_mex_data3d(‘create’, ’-vol’, vol_geom, 0);reconstruction_id = astra_mex_data3d(‘create’, ’-vol’, vol_geom, V);

astra_mex_data3d(‘store’, reconstruction_id , 0);astra_mex_data3d(‘store’, reconstruction_id , V);

reconstruction = astra_mex_data3d(‘get’, reconstruction_id );

row: x-axis

column: inverse y-axis

Slice: inverse z-axis

𝑥

𝑦

𝑧

voxel (0,0,0)

volume geometry

volume data

astra_mex_data3d(‘delete’, reconstruction_id);

Page 18: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

projection geometry• trajectory of source and detector plane

• number of detectors

• detector size

volume geometry

projection geometry

volume data

options: 2D: parallel-beam, fan-beam; 3D: parallel-beam, cone-beam; vector based geometries

limitations: detectors must be square and central detector must cast ray through origin

Page 19: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

projection geometry (2D parallel)

angles = linspace2(0,pi,180);proj_geom = astra_create_proj_geom(‘parallel’, 0.7, 7, angles);

detector widthdetector count (per projection)

projection angle (in radians from the y-axis)

𝑥

𝑦

0.7

𝑎𝑛𝑔𝑙𝑒

volume geometry

projection geometry

volume data

Page 20: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

projection geometry (2D fan-beam)

angles = linspace2(0,pi,180);proj_geom = astra_create_proj_geom(‘fanflat’, 0.7, 7, angles, 7, 6);

detector widthdetector count (per projection)

projection angle (in radians from the y-axis)

𝑥

𝑦

0.7

𝑎𝑛𝑔𝑙𝑒

source-origin distance

origin-detector distance

6

7

volume geometry

projection geometry

volume data

Page 21: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

projection geometry (3D cone-beam)

angles = linspace2(0,pi,180);proj_geom = astra_create_proj_geom(‘cone’, 0.7, 0.7, 7, 7, angles, 7, 6);

detector

width

detector row count (per projection)

projection angle (in radians from the y-axis)

source-origin distance

origin-detector distance

detector col count (per projection)

detector

height

volume geometry

projection geometry

volume data

Page 22: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

projection data• place to store projection (e.g. sinogram)

• similar to volume data

• links to projection geometry

volume geometry

projection data

projection geometry

volume data

Page 23: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

projection data (2D)

projection_id = astra_mex_data2d(‘create’, ’-sino’, proj_geom);projection_id = astra_mex_data2d(‘create’, ’-sino’, proj_geom, 0);projection_id = astra_mex_data2d(‘create’, ’-sino’, proj_geom, V);

columns: detectors

rows:

projections

volume geometry

projection data

projection geometry

volume data

Page 24: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

projection data (3D)

projection_id = astra_mex_data3d(‘create’, ’-sino’, proj_geom);projection_id = astra_mex_data3d(‘create’, ’-sino’, proj_geom, 0);projection_id = astra_mex_data3d(‘create’, ’-sino’, proj_geom, V);

columns: detector column

rows:

projections

slices: detector row

volume geometry

projection data

projection geometry

volume data

Page 25: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

Projector• links volume geometry to projection geometry

• only for CPU algorithms

• in matlab/python: stored by id

volume geometry

projection data

projection geometry

volume data

projector

options 2D parallel-beam: line, Joseph’s kernel (‘linear’), strip

2D fan-beam: line, strip

3D cone-beam: Joseph’s kernel (‘linear’)

Page 26: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

Projector

volume geometry

projection data

projection geometry

volume data

projector

projector_id = astra_create_projector(‘strip’, proj_geom, vol_geom);

astra_mex_projector(‘delete’, projector_id );

Page 27: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

Algorithm• Where the computations happen

• Configured with matlab structs / python dicts

• Stored by id

volume geometry

projection data

projection geometry

volume data

projector

algorithm

Options, CPU: FBP, ART, SART, SIRT, CGLS, FP, BP

GPU: FBP, FDK, SIRT, CGLS, FP, BP

Page 28: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

Algorithm (CPU)

volume geometry

projection data

projection geometry

volume data

projector

algorithm

cfg = astra_struct(‘SIRT’);cfg.ProjectionDataId = projection_id;cfg.ReconstructionDataId = reconstruction_id;cfg.ProjectorId = projector_id;alg_id = astra_mex_algorithm(‘create’, cfg);

astra_mex_algorithm(‘iterate’, alg_id, 50);

astra_mex_algorithm(‘delete’, alg_id);

Page 29: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Toolbox concepts

Algorithm (GPU)

volume geometry

projection data

projection geometry

volume data

projector+algorithm

cfg = astra_struct(‘SIRT_CUDA’);cfg.ProjectionDataId = projection_id;cfg.ReconstructionDataId = reconstruction_id;alg_id = astra_mex_algorithm(‘create’, cfg);

astra_mex_algorithm(‘iterate’, alg_id, 50);

astra_mex_algorithm(‘delete’, alg_id);

Page 30: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Intermediate results

With most iterative algorithms, it is possible to continue iterating after a set of iterations.

for i = 1:10

astra_mex_algorithm('iterate', alg_id, 10);

r = astra_mex_data2d('get', rec_id);

% (process or display r)

end

Note: with CGLS the output will be different than doing 100 iterations at once, since that resets with each run. For SART, SIRT the output will be the same.

Page 31: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Tools of the toolbox

• Create a forward projection

• Create a backprojection

• Delete all astra objects

[fp_id, fp] = astra_create_sino(volume, projector_id);

astra_clear;

[bp_id, bp] = astra_create_backprojection(fp, projector_id);

Page 32: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

More information

Where to find information?

• These slides (see workshop webpage for PDF)

• Docs: https://www.astra-toolbox.com/

• Sources:https://www.github.com/astra-toolbox/astra-toolbox

• Samples: <astra_root>/samples/

Page 33: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Today

• Introduction to ASTRA

• Exercises (see workshop webpage for PDF, part 1)

• More on ASTRA usage

• Exercises

Page 34: The ASTRA Tomography Toolboxpcha/HDtomo/SC/Week2Day3Part1.pdf · History The ASTRA toolbox was started at the Vision Lab of the University of Antwerp in Belgium by PhD students and

Practical issues

For the exercises, you need:

• Either, have ASTRA installed in Matlab on your laptop.Later today, you’ll also need SPOT:

http://www.cs.ubc.ca/labs/scl/spot

• Or, use thinlinc to access the DTU server.Start Matlab using Applications->DTU->Mathematics->

Astra… snapshot20190102 with gpu

• Samples are at: https://github.com/astra-toolbox/astra-toolbox-> samples -> matlab