Gvirtualxray: Open-Source Library to Simulate Transmission X-Ray Images Presented at IBFEM-4I 2018
Total Page:16
File Type:pdf, Size:1020Kb
gVirtualXRay: Open-source Library to Simulate Transmission X-ray Images Presented at IBFEM-4i 2018 Franck P. Vidal Lecturer in Visualisation School of Computer Science and Electronic Engineering Bangor University Wed 5 Sep 2018 Outline 1 Statement 2 Background 3 Simulation Model 4 Validation 5 Application examples 6 Case study 7 Conclusions 2 / 61 Parts of this work have been funded by: FP7 Career Integration Grant: Fly4PET: Fly Algorithm in PET Reconstruction for Radiotherapy Treatment Planning http://fly4pet.fpvidal.net/ FP7 ICT Collaborative project: RASimAs: Regional Anaesthesia Simulator and Assistant http://www.rasimas.eu/ The Titan Xp used for this research was donated by Thanks to Dr Jean-Michel L´etang,INSA de Lyon, for his support during the data acquisition. 3 / 61 Outline 1 Statement 2 Background 3 Simulation Model 4 Validation 5 Application examples 6 Case study 7 Conclusions 4 / 61 Rational for this Research (in Medical VR) Simulation of X-Ray attenuation extensively studied in physics; Different physically-based simulation code available; Physically-based simulation usually performed using Monte Carlo methods on CPU (often used in dosimetry for radiotherapy); Computing an image requires a very very very long time; Ray-tracing techniques are an alternative, but still relatively slow on CPU; Need for an fast open-source graphics processing unit (GPU) implementation. 5 / 61 Timeline N. Freud, \Modelling and simulation of X- and γ-ray imaging systems", PhD thesis, INSA de Lyon, France, 2003 F. P. Vidal, \Modelling the response of x-ray detectors and removing artefacts in 3D tomography", Master's thesis, INSA de Lyon, France, Sep. 2003 OpenGL Shading Language (GLSL) included into the OpenGL 2.0 core (2004). F. P. Vidal, \Simulation of image guided needle puncture: Contribution to real-time ultrasound and fluoroscopic rendering, and volume haptic rendering", PhD thesis, Bangor University, UK, Jan. 2008 F. P. Vidal, M. Garnier, N. Freud, et al., \Simulation of X-ray attenuation on the GPU", in Proceedings of Theory and Practice of Computer Graphics 2009, Cardiff, UK: Eurographics Association, Jun. 2009, pp. 25{32 F. P. Vidal, M. Garnier, N. Freud, et al., \Accelerated deterministic simulation of x-ray attenuation using graphics hardware", in Eurographics 2010 - Poster, Norrk¨oping,Sweden: Eurographics Association, May 2010, Poster 5011 Restart as an open-source project, Dec 2013. F. P. Vidal and P.-F. Villard, \Development and validation of real-time simulation of x-ray imaging with respiratory motion", Computerized Medical Imaging and Graphics, vol. 49, pp. 1{15, Apr. 2016 6 / 61 Fact sheet Open-source (created on 01 Dec 2013) SVN repository hosted by ; svn checkout http://svn.code.sf.net/p/gvirtualxray/code/trunk/ Implemented in using ; Can also be deployed in applications; Provides real-time performance; Is accurate (quantitative validation); Reproducibility; Supports XCOM: Photon Cross Sections Database from ; Uses polygon meshes to model 3-D geometries from popular file formats (eg. STL, PLY, 3DS, OBJ, DXF, X3D, DAE) 7 / 61 X-photons/matter Interactions X-photons cross matter; During their path into the body, they can interact with matter. X-ray source 1 Directly transmitted photons (no interaction); 2 4 2 Absorbed photons; 3 Scattered photons; 4 Absorbed scattered photons. 1 1 3 X-ray detector For most X-rays imaging modalities, only directly transmitted photons are essential; Scattered photons decrease the image quality; Absorbed photons do not reach the detector. 8 / 61 X-photons/matter Interactions X-photons cross matter; During their path into the body, they can interact with matter. X-ray source 1 Directly transmitted photons (no interaction); 2 4 2 Absorbed photons; 3 Scattered photons; 4 Absorbed scattered photons. 1 1 3 X-ray detector For most X-rays imaging modalities, only directly transmitted photons are essential; Scattered photons decrease the image quality; Absorbed photons do not reach the detector. 8 / 61 Beer-Lambert Law (Attenuation Law) Nin(E) the number of incident photons at energy E; Nout (E) the number of X-ray source N (E) transmitted photons of energy E; in µi the linear attenuation coefficient (in cm 1) of the i th µ1 Lp(1) − µ2 Lp(2) object. It depends on: µ3 Lp(3) E the energy of incident photons; µi 1 Lp(i 1) − − ρ the material density of the µi Lp(i) object; Z the atomic number of the Nout(E) object material. Lp(i) the path length of the ray in the i th object. Nout (E) = Nin(E) exp µi (E; ρ, Z)Lp(i) − i ! X 9 / 61 Path Length: Naive Approach X-ray source 4 1 3 2 1st, 2nd, 3rd, 4th intersections as found by ray-tracing detector Detect every intersection between a ray and the objects; Sort intersection (Can be handled by GPUs using depth-peeling, a multi-pass rendering technique for semi-transparent polygonal objects without sorting polygons); Compute path length. 10 / 61 Path Length: L-Buffer V d4 d1 d3 X-ray source 4 d2 N2 1 3 N4 2 N1 N3 1st, 2nd, 3rd, 4th intersections as found by ray-tracing detector Intersection sorting is not needed! By convention normals are outward; A ray penetrates into an object when the dot product between the view vector (V ) and the normal (Ni ) at the intersection point is positive; It leaves an object when the dot product is negative. 11 / 61 Outline 1 Statement 2 Background 3 Simulation Model 4 Validation 5 Application examples 6 Case study 7 Conclusions 12 / 61 L-Buffer Implementation Lp = sng (V Ni ) di − · × i X i refers to i th intersection in an arbitrary order; di distance from X-ray source to intersection point; sgn (V Ni ) stands for the sign of the dot product between V · and Ni ; In a shader program, compute: sgn (V Ni ); · di the distance between the X-ray source and the intersection; Assign sng (V Ni ) di for the fragment value. − · × For each pixel, compute Lp thanks to high-dynamic range and OpenGL blending function (pixel values may not be between 0 and 1). F. P. Vidal, M. Garnier, N. Freud, et al., \Simulation of X-ray attenuation on the GPU", in Proceedings of Theory and Practice of Computer Graphics 2009, Cardiff, UK: Eurographics Association, Jun. 2009, pp. 25{32 13 / 61 Multipass Rendering Pipeline Initilisation of OpenGL components pixel = E Nout (FBOs, textures, shaders) × For each simulated X-ray image = E Nin(E) exp µi Lp(i) × − i ! X Clear(FBO ( µiLp(i))) P Needs 3 FBOs with high-dynamic For each object(i) range capability for off-line Clear(FBO (Lp(i))) rendering: For each object of the scene: Compute(FBO (Lp(i))) 1 Compute Lp(i); Update(FBO ( µiLp(i))) (make use of FBO (Lp(i))) 2 Update results of µi Lp(i). P For the final image only: Compute(FBO (E N (E) exp( µ L (i)))) P × in ∗ − i p (make use of FBO ( µiLp(i)) 1 Compute Nout; P P 2 (Optional when direct display only is needed). 14 / 61 Adding the Beam Spectrum Virtual detector Water Iron pixel = Ej Nout (Ej ) box cylinder × j X Point source = Ej Nin(Ej ) exp µi (Ej ; ρ, Z)di × − Set up. j i ! X X 4.5 108 max energy (33keV) × Monochromatic beam (33 keV) 4 108 × mean energy (43.9keV) 10.00000000 Monochromatic beam (43.9 keV) Polychromatic beam (using Fig. 3(b)) 3.5 108 × 1.00000000 3 108 0.10000000 × 2.5 108 0.01000000 × 2 108 0.00100000 × 1.5 108 0.00010000 × Total energy (normalised data) Number of photons/keV 1 108 0.00001000 × 5 107 0.00000100 × 0.00000010 0 0 10 20 30 40 50 60 70 80 90 100 0.00000001 Energy (in keV) 0 20 40 60 80 100 120 140 160 180 Pixel number Polychromatic beam spectrum for 90kV Intensity profiles. X-ray tube peak voltage. 15 / 61 Simulation with Different Source Shapes Take into account the focal spot of the X-ray source pixel = Ej Nin(Ej ) exp µi (Ej ; ρ, Z)di (k) × − k j i ! X X X (a) Parallel beam. (b) Infinitely small point source. (c) 13mm source. F. P. Vidal, M. Garnier, N. Freud, et al., \Accelerated deterministic simulation of x-ray attenuation using graphics hardware", in Eurographics 2010 - Poster, Norrk¨oping, Sweden: Eurographics Association, May 2010, Poster 5011 16 / 61 Final Simulation Flowchart Initilisation of OpenGL components (FBOs, textures, shaders) For each simulation loop For each energy channel (E) Clear FBO ( µ(E)Lp) P For each point source Set OpenGL vertex transformations (modelview & projection matrices) For each object (i) Clear FBO (Lp) Compute Lp(i), i.e. FBO (Lp) For each energy channel (E) Update FBO ( µ(E)Lp) (make use of FBO (Lp)) P Clear final framebuffer For each energy channel (E) Update frame buffer: (E N (E) exp( µ(i,E)L (i))) E × in × − i p (make use of FBO ( µ(E)Lp)) P P P Display or save frame buffer (final results) 17 / 61 Outline 1 Statement 2 Background 3 Simulation Model 4 Validation 5 Application examples 6 Case study 7 Conclusions 18 / 61 Are the values used in gVirtualXRay accurate? Compare values computed in gVirtualXRay with those from the literature. Are the Beer-Lambert law implementations accurate? Compare values computed in gVirtualXRay with theoretical ones. Are the simulated images accurate? Compare images computed using gVirtualXRay with those using a state-of-the-art Monte Carlo software from CERN. Validation Method Simulating an image relies on a Beer-Lambert law implementation; Solving the Beer-Lambert law relies on Linear Attenuation Coefficients; (µ) µ is not known for given incident energies; µ µ is computed using Mass Attenuation Coefficients ρ and Density (ρ).