13.07.2015 Views

A copy of original Thesis in full (pdf file) - SERC

A copy of original Thesis in full (pdf file) - SERC

A copy of original Thesis in full (pdf file) - SERC

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

INTERACTIVE NMR MAGNETIC FIELD VISUALIZATIONON GRAPHICS PROCESSORSbyBiswajit MishraA thesis submitted toIndian Institute <strong>of</strong> Science<strong>in</strong> partial fulfillment <strong>of</strong> the requirements for the degree <strong>of</strong>Master <strong>of</strong> Technology (Computational Sciences)Supercomputer Education and Research CentreIndian Institute <strong>of</strong> ScienceBangaloreIndiaJune 2006


ABSTRACTINTERACTIVE NMR MAGNETIC FIELD VISUALIZATIONON GRAPHICS PROCESSORSBiswajit MishraSupercomputer Education and Research CentreMaster <strong>of</strong> Technology (Computational Sciences)NMR magnets need to have better than 10 −8 homogeneity over a 10x10x20mm 3 space which is obta<strong>in</strong>ed by optimally tun<strong>in</strong>g a set <strong>of</strong> Shim coils. Theseshim coil currents are adjusted manually by an operator to achieve a homogeneousmagnetic field. Visualiz<strong>in</strong>g magnetic field will assist operator <strong>in</strong> optimalshimm<strong>in</strong>g.A novel method to visualize NMR Magnetic field is presented. The problemposes challenges that are different from computationally <strong>in</strong>tensive generalmagnetic field computation and visualization.A GPU (Graphics process<strong>in</strong>gUnit)based technique is developed for efficient <strong>in</strong>teractive visualization. Thisapproach exploits the <strong>in</strong>herent parallelism <strong>in</strong> the GPUs thus rel<strong>in</strong>quish<strong>in</strong>g CPUfrom most <strong>of</strong> the heavy computation. The field equations are transformed <strong>in</strong>toa set <strong>of</strong> multi-pass GPU shader programs that encapsulates Shim coil current<strong>in</strong>puts and coil geometry. A geometric deformation based visualization tech-


nique is developed to identify dom<strong>in</strong>ant <strong>in</strong>homogeneity present <strong>in</strong> the fieldto be corrected by adjust<strong>in</strong>g a particular shim current. This implementationdelivers required frame rates for real time user <strong>in</strong>teractions.


ACKNOWLEDGMENTSI would like to express my immense gratitute to my advisor, Dr. P.C. Mathiasfor his guidance and support. My association with him over past one yearhas been a greatly enrich<strong>in</strong>g experience. I wish to express my pround thanksto my labmate Manohar B.S. for his practical support . My special thanksto IISc authorities and, <strong>SERC</strong> <strong>in</strong> particular for provid<strong>in</strong>g an un-<strong>in</strong>terruptedcomput<strong>in</strong>g facility. F<strong>in</strong>ally, I thank all my friends <strong>in</strong> the Department and theInstitute for mak<strong>in</strong>g my stay here a memorable one.


ContentsTable <strong>of</strong> ContentsList <strong>of</strong> Figuresvvi1 Introduction 11.1 NMR Spectrometer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.1.1 What is Shimm<strong>in</strong>g? . . . . . . . . . . . . . . . . . . . . . . . . 21.2 Graphics Process<strong>in</strong>g Unit . . . . . . . . . . . . . . . . . . . . . . . . . 41.2.1 Why on GPU? . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Theory <strong>of</strong> Magnetic Field 62.1 Spherical Harmonic Solution <strong>of</strong> Magnetic Field . . . . . . . . . . . . . 62.2 Computation <strong>of</strong> Harmonic Co-efficient . . . . . . . . . . . . . . . . . 72.2.1 Taylor Series Expansion and Recurrence Relations . . . . . . . 72.2.2 Circular Arc Field . . . . . . . . . . . . . . . . . . . . . . . . 92.2.3 Solenoid Field . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.2.4 Shim Coils Equations . . . . . . . . . . . . . . . . . . . . . . . 132.3 The Shim Coil Functions . . . . . . . . . . . . . . . . . . . . . . . . 133 GPU Architecture and Texture Based Volume Render<strong>in</strong>g 173.1 GPU Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.1.1 3D Texture based volume render<strong>in</strong>g . . . . . . . . . . . . . . . 203.2 Magnetic field computation on GPU . . . . . . . . . . . . . . . . . . 214 Deformation Based Visualization Technique 254.1 Deformation Based Visualization Technique . . . . . . . . . . . . . . 254.1.1 Implementation <strong>of</strong> Deformation Based Visualization . . . . . 265 Conclusion and Future work 385.1 Conclusion and Future Work . . . . . . . . . . . . . . . . . . . . . . 38Bibliography 40Index 41v


List <strong>of</strong> Figures2.1 Coord<strong>in</strong>ate system for field due to solenoid . . . . . . . . . . . . . . . 112.2 Field due to circular arc . . . . . . . . . . . . . . . . . . . . . . . . . 153.1 GeForce 6 Series Architecture . . . . . . . . . . . . . . . . . . . . . . 193.2 Slic<strong>in</strong>g Plane <strong>in</strong> 3D texture based volume render<strong>in</strong>g . . . . . . . . . . 203.3 Flow diagram <strong>of</strong> one render cycle . . . . . . . . . . . . . . . . . . . . 223.4 Volume rendered with slic<strong>in</strong>g plane 3D Textures . . . . . . . . . . . . 233.5 Magnetic field image with no <strong>in</strong>homogeniety . . . . . . . . . . . . . . 234.1 3Dmessh<strong>in</strong>g volume for deformation based visualization . . . . . . . . 274.2 CPU GPU PERFORMANCE STUDY . . . . . . . . . . . . . . . . . 294.3 speed up study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.4 renered image with Z(X 2 − Y 2 ) <strong>in</strong>homogeneity . . . . . . . . . . . . 304.5 renered image with X 3 <strong>in</strong>homogeneity . . . . . . . . . . . . . . . . . 304.6 renered image with Y 3 <strong>in</strong>homogeneity . . . . . . . . . . . . . . . . . . 314.7 renered image with Y <strong>in</strong>homogeneity . . . . . . . . . . . . . . . . . . 314.8 renered image with Z 2 X <strong>in</strong>homogeneity . . . . . . . . . . . . . . . . . 324.9 renered image with Y 2 Z <strong>in</strong>homogeneity . . . . . . . . . . . . . . . . . 324.10 renered image with Z 2 − X 2 <strong>in</strong>homogeneity . . . . . . . . . . . . . . 334.11 renered image with XY Z <strong>in</strong>homogeneity . . . . . . . . . . . . . . . . 334.12 renered image with no <strong>in</strong>homogeneity . . . . . . . . . . . . . . . . . . 344.13 renered image with XY <strong>in</strong>homogeneity . . . . . . . . . . . . . . . . . 344.14 renered image with Z <strong>in</strong>homogeneity . . . . . . . . . . . . . . . . . . 354.15 renered image with no <strong>in</strong>homogeneity . . . . . . . . . . . . . . . . . . 354.16 renered image with ZX <strong>in</strong>homogeneity . . . . . . . . . . . . . . . . . 364.17 renered image with Z 3 <strong>in</strong>homogeneity . . . . . . . . . . . . . . . . . . 364.18 renered image with Z 4 <strong>in</strong>homogeneity . . . . . . . . . . . . . . . . . . 374.19 renered image with Z 5 <strong>in</strong>homogeneity . . . . . . . . . . . . . . . . . . 37vi


Chapter 1Introduction1.1 NMR SpectrometerNuclear Magnetic Resonance (NMR) spectros<strong>copy</strong> is one <strong>of</strong> the pr<strong>in</strong>cipal techniquesused to obta<strong>in</strong> physical, chemical, electronic and structural <strong>in</strong>formation about amolecule. It is the only technique that can provide detailed <strong>in</strong>formation on the exactthree-dimensional structure <strong>of</strong> biological molecules <strong>in</strong> solution. NMR equipment requiresa source <strong>of</strong> magnetic field with m<strong>in</strong>imal <strong>in</strong>homogeneities. No magnet generatesan ideal homogeneous magnetic field and therefore a complicated system <strong>of</strong> coils isrequired. Coils fed by separate current supplies to remove particular magnetic <strong>in</strong>homogeneity(X, Y, Z, XY, Y Z, XZ, X 2 − Y 2 , XZ 2 , Y Z 2 , Z, Z 2 , Z 3 , Z 4 ) is needed. Fora solenoid magnet with a cyl<strong>in</strong>der shaped work space, the <strong>in</strong>dividual active shimsconsists <strong>of</strong> circular and saddle shaped coils symmetrically positioned on the co-axialcyl<strong>in</strong>drical surfaces.The theory <strong>of</strong> magnetic field due to a known coil geometry is well established.Significant research has gone <strong>in</strong>to computational aspect <strong>of</strong> the magnetic field. Thetheory, design and construction <strong>of</strong> a magnetically shielded solenoid is described <strong>in</strong> [1],1


1.1 NMR Spectrometer 2[2], [3]. High resolution magnet for NMR and MRI based on the spherical harmonicsand unique recursion relations for the co-efficient <strong>of</strong> most dom<strong>in</strong>ant components isdescribed <strong>in</strong> [4].1.1.1 What is Shimm<strong>in</strong>g?In the beg<strong>in</strong>n<strong>in</strong>g, the field homogeneity <strong>of</strong> large electromagnets was adjusted by mechanicalalignment <strong>of</strong> the magnet pole faces. The more parallel the pole faces, themore homogeneous the magnetic field. The first step <strong>in</strong> the process <strong>of</strong> adjust<strong>in</strong>g magnetichomogeneity was to adjust the position <strong>of</strong> the magnet’s pole faces by turn<strong>in</strong>gthree large bolts which held the pole faces. Adjust<strong>in</strong>g these bolts tilted the pole facesrelative to each other with the aim <strong>of</strong> mak<strong>in</strong>g the pole faces more parallel. If thebolts ran out <strong>of</strong> range, th<strong>in</strong> pieces <strong>of</strong> brass were placed between the magnet yokeand the pole pieces to move the pole pieces as parallel as possible. These th<strong>in</strong> pieces<strong>of</strong> brass were also placed <strong>in</strong> other strategic locations to make the pole faces parallel<strong>in</strong> a manner not addressed by the three adjustment bolts. The metal pieces werecalled shim stock and the seem<strong>in</strong>gly endless process <strong>of</strong> plac<strong>in</strong>g and remov<strong>in</strong>g pieces<strong>of</strong> shim stock acquired the name ”shimm<strong>in</strong>g”. Because tons <strong>of</strong> magnetic field pressureexisted on the pole faces, the magnet had to be turned <strong>of</strong>f to place and removethe shim stock. When the sample was sp<strong>in</strong>n<strong>in</strong>g, the f<strong>in</strong>al part <strong>of</strong> adjust<strong>in</strong>g magnetichomogeneity with these systems was to adjust a ratchet bolt which pulled togetheror pushed apart the tops <strong>of</strong> the magnet pole pieces to give a f<strong>in</strong>e adjustment <strong>of</strong> the Ygradient. All <strong>of</strong> these processes were mechanical <strong>in</strong> nature. After these adjustments,the NMR <strong>in</strong>struments were typically capable <strong>of</strong> giv<strong>in</strong>g better than 0.2 Hz resolution.This is rather impressive when you consider that 0.2 Hz out <strong>of</strong> 60 MHz represents 3parts per billion field homogeneity over the volume <strong>of</strong> the sample.To <strong>in</strong>crease the performance, reduce the difficulty <strong>of</strong> adjust<strong>in</strong>g magnetic homo-


1.1 NMR Spectrometer 3geneity and reduce the manufactur<strong>in</strong>g difficulty <strong>of</strong> the magnets, an electronic ”shimm<strong>in</strong>g”process was developed which used a series <strong>of</strong> small electromagnets hav<strong>in</strong>g veryspecific magnet field contours. These small electromagnets are placed around thesample area. Each small electromagnet can be used to adjust the field <strong>in</strong> the volume<strong>of</strong> observation to create more <strong>of</strong> or counteract exist<strong>in</strong>g types <strong>of</strong> magnetic gradients.A complete series <strong>of</strong> these electromagnets can be used to adjust the magnetic fieldhomogeneity to a given level <strong>of</strong> purity depend<strong>in</strong>g on how many types <strong>of</strong> adjustmentelectromagnets are used. The process <strong>of</strong> adjust<strong>in</strong>g the magnetic field homogeneity byadjust<strong>in</strong>g the current <strong>in</strong> each <strong>of</strong> the small electromagnets reta<strong>in</strong>ed the name shimm<strong>in</strong>gand the small electromagnets assumed the name ”shims”.At first only a few low order ( X, Y , and Z) electrical shims were used. As thefields became higher, magnet production became more difficult, and more and higherorder electrical shims were added to ma<strong>in</strong>ta<strong>in</strong> the same level <strong>of</strong> performance. Theseelectrical shims are not 100% pure and have <strong>in</strong>teractions with shims <strong>of</strong> a similarnature ( ZX creates some Z gradient and X gradient <strong>in</strong> addition to the <strong>in</strong>tended ZXgradient ). Because <strong>of</strong> these <strong>in</strong>teractions, the number <strong>of</strong> adjustments necessary toshim the magnet <strong>in</strong>creases geometrically with the number <strong>of</strong> shims, not just l<strong>in</strong>early.In addition, the raw field encountered <strong>in</strong> superconduct<strong>in</strong>g magnets is usually worsethan <strong>in</strong> electromagnets, so larger corrections are required. These two facts makethe process <strong>of</strong> shimm<strong>in</strong>g superconduct<strong>in</strong>g magnets more difficult and the shimm<strong>in</strong>gprocess more important to obta<strong>in</strong> useful NMR spectra.To obta<strong>in</strong> 0.2 Hz resolution requires ten times greater magnetic field homogeneityat 600 MHz than at 60 MHz. Therefore, <strong>in</strong> addition to the higher field superconduct<strong>in</strong>gmagnets be<strong>in</strong>g more difficult to shim, shimm<strong>in</strong>g becomes more important toobta<strong>in</strong> the same results as the magnetic fields <strong>in</strong>crease. Other aspects <strong>of</strong> an NMR<strong>in</strong>strument’s performance are also affected by shimm<strong>in</strong>g, such as the NMR signal’s


1.2 Graphics Process<strong>in</strong>g Unit 4l<strong>in</strong>eshape, which is critical for achiev<strong>in</strong>g good solvent suppression. So the necessaryevil <strong>of</strong> adjust<strong>in</strong>g the small electromagnets, called shimm<strong>in</strong>g, rema<strong>in</strong>s very important<strong>in</strong> today’s NMR <strong>in</strong>strumentation.1.2 Graphics Process<strong>in</strong>g UnitGPUs have evolved as a <strong>full</strong>y programmable and immensely parallel workhorse forgraphics computation. Availability <strong>of</strong> high-level languages and tools have led to explosion<strong>of</strong> <strong>in</strong>novation and creativity. Programmability allows for runn<strong>in</strong>g any taskon GPU as long as an algorithm can be found that fits <strong>in</strong>to the stream<strong>in</strong>g model.GPGPU (General Purpose Computation on GPU) applications [5] ranges from numericcomput<strong>in</strong>g operation such as dense and sparse matrix multiplication techniqueor multi-grid conjugate gradient solvers for system <strong>of</strong> l<strong>in</strong>ear equations to computergraphics processes such as ray trac<strong>in</strong>g and photon mapp<strong>in</strong>g usually performed <strong>of</strong>fl<strong>in</strong>e<strong>in</strong> CPU, to physical simulations such as fluid mechanics solvers ,to data base anddata m<strong>in</strong><strong>in</strong>g operations. The physics based simulation on GPU was first seen <strong>in</strong> [5],which also demonstrated the ”Game <strong>of</strong> Life” cellular automata and a 2D physicallybased wave simulation. Several researcher has used GPU to simulate fluid dynamics.Related to fluid simulation is visualizations <strong>of</strong> flow which has been implemented us<strong>in</strong>ggraphics hardware to accelerate l<strong>in</strong>e <strong>in</strong>tegral convolution an Lagrangian-Eulerianadvection.1.2.1 Why on GPU?Shimm<strong>in</strong>g the NMR magnet is a complex task.The most common method <strong>of</strong> adjust<strong>in</strong>gthe homogeneity <strong>of</strong> an NMR magnet is the observation <strong>of</strong> an NMR signal. Theproblem with the shimm<strong>in</strong>g process is that the observed NMR signal results from


1.2 Graphics Process<strong>in</strong>g Unit 5the <strong>in</strong>tegrated signal from the total volume <strong>of</strong> the observed sample, which may havemany different resonant frequencies with different degrees <strong>of</strong> excitation aris<strong>in</strong>g fromdifferent positions <strong>in</strong> the sample. NMR sample can be visualized as a cont<strong>in</strong>uum <strong>of</strong>isolated m<strong>in</strong>i-samples, each <strong>of</strong> which is <strong>in</strong>f<strong>in</strong>itesimally small. Each m<strong>in</strong>i-sample thengenerates a signal whose l<strong>in</strong>ewidth is determ<strong>in</strong>ed by the T2 relaxation time <strong>of</strong> thesample and whose frequency results from the field value at that po<strong>in</strong>t. The <strong>in</strong>tensity<strong>of</strong> the signal generated by each m<strong>in</strong>i-sample would reflect the amount <strong>of</strong> excitationat that po<strong>in</strong>t. What the NMR operator observes is the sum <strong>of</strong> signals from all them<strong>in</strong>i-samples. In other words, the NMR signal is the total <strong>in</strong>tegrated signal over thetotal sample volume times each area’s degree <strong>of</strong> excitation. It is the <strong>in</strong>tegration <strong>of</strong>the NMR signal response which leads to a major difficulty <strong>in</strong> the shimm<strong>in</strong>g process.Any knowledge as to which part <strong>of</strong> the NMR sample is experienc<strong>in</strong>g the magnetic<strong>in</strong>homogeneity is lost <strong>in</strong> this <strong>in</strong>tegration process. Thus, to overcome above difficulty,<strong>in</strong>stead <strong>of</strong> signals the magnetic field <strong>in</strong>side sample volume needed to be visualized.Though, scalar field visualization is solved problem but visualiz<strong>in</strong>g magnetic field <strong>in</strong>the context <strong>of</strong> shimm<strong>in</strong>g poses two challenges:1: It should be <strong>in</strong>teractive. For an <strong>in</strong>teractive application at least 20-30 frame persecond is needed.2: The type <strong>of</strong> <strong>in</strong>homogeneity present should be identified from the renderedimage.Because <strong>of</strong> <strong>in</strong>herent parallelism GPUs are highly efficient for data and compute<strong>in</strong>tensive operations. To achieve required frame rate it is implemented on GPU.


Chapter 2Theory <strong>of</strong> Magnetic Field2.1 Spherical Harmonic Solution <strong>of</strong> Magnetic FieldThe total magnetic <strong>in</strong>duction <strong>in</strong> a homogeneous region conta<strong>in</strong><strong>in</strong>g no field sourcesis described by the Laplace equation. NMR applications employ magnets that areaxially symmetric [2].∇ 2 B z = 0 (2.1)The dom<strong>in</strong>ant component B z , parallel to the symmetry axis is also described bythe Laplace equation <strong>in</strong> the form Eq.(2.1) The solution <strong>of</strong> Eq.(2.1) can be expressed<strong>in</strong> spherical harmonic expansion∞∑B z (x, y, z) = r nm P n (cosθ) × [a m,n cos (mϕ) + b m,n s<strong>in</strong> (mϕ)] (2.2)n=0,m=0where r, θ and φ are spherical coord<strong>in</strong>ates, a m,n and b m,n are coefficients andm P n (cos θ) are associated Legendre polynomials <strong>of</strong> first k<strong>in</strong>d, degree n and order m.The first member <strong>of</strong> Eq.(2.2) is the ideal homogeneous field. Eq.(2.2) can be expanded<strong>in</strong> Cartesian coord<strong>in</strong>ates as <strong>in</strong> Eq.(2.3), shown only up to third degree and order.6


2.2 Computation <strong>of</strong> Harmonic Co-efficient 7B z (x, y, z) =a 0,0 +a 0,1 z+a 0,2(z 2 − 1 2 (x2 + y 2 ) ) +a 0,3 z ( z 2 − 3 2 (x2 + y 2 ) ) + . . .+a 1,1 x+3a 1,2 xz+a 1,3 x ( 6z 2 − 3 2 (x2 + y 2 ) ) + . . .+b 2,1 y+3b 1,2 yz+b 1,3 y ( 6z 2 − 3 2 (x2 + y 2 ) ) + . . .+3a 2,2 (x 2 − y 2 )+15a 2,3 z (x 2 − y 2 )+ . . .(2.3)+6b 2,2 xy+30b 2,3 xyz+ . . .+15a 3,3 x (x 2 − 3y 2 )+ . . .+15b 3,3 y (3x 2 − y 2 )+ . . .2.2 Computation <strong>of</strong> Harmonic Co-efficient2.2.1 Taylor Series Expansion and Recurrence RelationsThe dependence <strong>of</strong> the magnetic field derivatives on the current carry<strong>in</strong>g conductorcan be described by Taylor series <strong>in</strong> cartesian form Eq.(2.4). The expansion is <strong>in</strong> theneighborhood <strong>of</strong> the orig<strong>in</strong>.B z (x, y, z) = ∑ i,j,kτ i,j,k x i y j z k (2.4)τ i,j,k = 1i!j!k!∂ i+j+k ∣B ∣∣∣∣x=0,y=0,z=0 z(2.5)∣∂x i ∂y j ∂z kApply<strong>in</strong>g Laplace’s differential equation Eq.(2.1) <strong>in</strong> the form Eq.(2.6) to Eq.(2.4)∂ 2 B z∂y 2= − ∂2 B z∂z 2− ∂2 B z∂x 2 (2.6)


2.2 Computation <strong>of</strong> Harmonic Co-efficient 8we haveB z (x, y, z) =(τ 0,0,0 +τ 0,0,1 z+τ 0,0,2 z 2 − y 2) +τ 0,0,3 z ( z 2 − 3y 2) + . . .+τ 1,0,0 x+2τ 1,0,1 xz +2τ 1,0,2 x ( z 2 − y 2) + . . .+τ 0,1,0 y+2τ 0,1,1 yz +τ 0,1,2 y ( 3z 2 − y 2) + . . .(+τ 2,0,0 x 2 − y 2) +3τ 2,0,1 z ( x 2 − y 2) + . . .+2τ 1,1,1 xy +6τ 1,1,1 xyz+ . . .+τ 3,0,0 x ( x 2 − 3y 2) + . . .+τ 2,1,0 y ( 3x 2 − y 2) + . . . (2.7)The polynomial <strong>in</strong> the M th row and n th column <strong>of</strong> the expansion Eq.(2.7) can bedenoted by M T n , the follow<strong>in</strong>g recursion formulae can be adopted.0 T n = z 0 T n−1 − y 2 T n−1n = 1, 2, 3, ... (2.8)1 T n = nx 0 T n−12 T n = y 0 T n−1 + z 2 T n−1M T n = 2n ( x M−2 T n−1 − y M−1 T n−1)/(M + 1)(2.9)for odd M = 3, 5, ..., 2n − 1 andM T n = z M T n−1 + x M−2 T n−1 + y M−3 T n−1 (2.10)for even M = 4, 6, ..., 2n. where 0 T 0 = 1 and 2n T n−1 = 0.Eq.(2.3) and Eq.(2.7) describes the same field. Their members with identicalpowers <strong>of</strong> the <strong>in</strong>dividual coord<strong>in</strong>ates can be compared and the relationship between


2.2 Computation <strong>of</strong> Harmonic Co-efficient 9the coefficients can be determ<strong>in</strong>ed. The coefficients a m,n and b m,n are specified as thel<strong>in</strong>ear comb<strong>in</strong>ation <strong>of</strong> the derivatives τ i,j,k , i + j + k = n.2.2.2 Circular Arc FieldB z due to a current carry<strong>in</strong>g circular arc <strong>of</strong> conductor as shown <strong>in</strong> Fig.2.2. at a po<strong>in</strong>t(x, y, z) is given by Biot-Savart law, Eq.(2.11).B z (x, y, z) = µIr4π ×∫ φ(r − x cosξ − y s<strong>in</strong> ξ)dξ−φ[x2 + y 2 + (z − d) 2 − 2r (x cosξ + y s<strong>in</strong> ξ) + r 2 ] 3/2(2.11)where I is the current <strong>in</strong> the circular conductor <strong>of</strong> radius r and arc angle 2φ, dis the z coord<strong>in</strong>ate <strong>of</strong> the plane conta<strong>in</strong><strong>in</strong>g the circular arc. µ is the permeability<strong>of</strong> the medium and the ξ is the <strong>in</strong>tegration variable. By evaluat<strong>in</strong>g the derivatives<strong>of</strong> Eq.(2.11) as specified by Eq.(2.5) at the orig<strong>in</strong>, the τ i,j,k are obta<strong>in</strong>ed and areconsecutively transformed to spherical harmonic coefficients a m,n and b m,n . For thegiven pose <strong>of</strong> circular arc b m,n = 0. By further analysis a m,n can be found out byexploit<strong>in</strong>g the recurrence relation and rotary symmetry. Coefficients for the zonalmembers (rotary symmetry,m=0) are given by formulaa 0,n = C n 0 Z n φ (2.12)Where C n equals µI/2πcc n n!. Us<strong>in</strong>g β = d/c for the relative position <strong>of</strong> thecurrent carry<strong>in</strong>g arc 0 Z n is determ<strong>in</strong>ed by the recursion formulap Z q = − (2q + 1)p Z q−1 + [q 2 − (p − 1) 2 ] p Z q−21 + β 2 (2.13)where p = 0 and q = 1, 2, 3....n successively, the start<strong>in</strong>g functions be<strong>in</strong>g


2.2 Computation <strong>of</strong> Harmonic Co-efficient 100 Z 0 = (1 + β 2 ) −3/2 and 0 Z 0 = 0The Coefficients for the tesseral (n > m > 0) and sectorial terms (<strong>in</strong>dependent <strong>of</strong>z coord<strong>in</strong>ate , n = m) are calculated us<strong>in</strong>g expressiona m,n = C n[ m ∏i=1]|(2i − 3)|× [( 4m 2 − 1 ) m Z n − m−2 Z ] s<strong>in</strong> mφnn + im(2.14)where m Z n and m−2 Z n are auxiliary functions for the degree n = 1, 2, 3, ... and theorder m = 1, 2, 3.....They are given by formula (2.13) with generalized start<strong>in</strong>gfunctionsp Z p=q = (1 + β 2 ) −p−(3/2) and p Z q


2.2 Computation <strong>of</strong> Harmonic Co-efficient 11(a)r(r,θ,φ)(ρ,φ,z)ρoθzsymmetryaxis(b)L/2 L/2r sa sθ sFigure 2.1 (a): Coord<strong>in</strong>ate system used to describe the field <strong>in</strong> axiallysymmetric system.(b): coord<strong>in</strong>ate used to specify the s<strong>in</strong>gle layer <strong>of</strong> the solenoid <strong>of</strong> length Land radius a s .


2.2 Computation <strong>of</strong> Harmonic Co-efficient 12system <strong>of</strong> conductors is axially symmetric, the magnetic field will not be a function <strong>of</strong>the azimuthal angle φ. We write the potential <strong>in</strong>side the system <strong>of</strong> conductors withcyl<strong>in</strong>drical geometry as Eq.(2.16).V (r, θ) =∞∑(n=1− H n−1n)r n P n (cos θ) (2.16)where P n (cosθ) is a Legendre polynomial. The potential function gives the radialand axial components as <strong>in</strong> Eq.(2.17) and Eq.(2.18).H ρ (r, θ) =∞∑H z (r, θ) = H n r n P n (cosθ) (2.17)n=1∞∑n=1( ) 1H n r n d n + 1 dθ P n(cosθ) (2.18)Where the coefficient H n are given by the relationship <strong>in</strong> Eq.(2.19) and Eq.(2.20).H n =( 1n!) [( d n ) ]Hdz n z (z, 0)z=0(2.19)H z (z, 0) = 4π N s I×10 2r s{ [ 1 − (us ) 2 ]∞∑1 −×u sn=1( ) ( ) 1 z 2nP′2n r 2n (u s )}s(2.20)Here N s is the total number <strong>of</strong> turns, u s is for cosθ s , I is the current, and P 2n ′ (u s) =(d/du s ) P 2n (u s )The magnetic field is <strong>in</strong> gauss if I is <strong>in</strong> amperes and r s is <strong>in</strong> centimeters. Due tothe plane <strong>of</strong> symmetry through the orig<strong>in</strong> odd powers <strong>of</strong> z <strong>in</strong> the expression Eq.(2.20)is zero. We can rewrite Eq.(2.20) <strong>in</strong> series form as Eq.(2.21).


2.3 The Shim Coil Functions 13H z (z, 0) = 4πNI (cosθ s ) ×{ 101 − 3 ( ) z 25 ( ) (2 s<strong>in</strong>4 θ s − s<strong>in</strong> 6 θ s 7 cos 2 θ s − 3 ) ( )z 4a s 8a s− 7 ( ) (s<strong>in</strong> 8 θ s × 33 cos 4 θ s − 30 cos 2 θ s + 5 ) ( ) }z 6− . . .16a s(2.21)Here N is the number <strong>of</strong> turns per unit length. The successive terms <strong>of</strong> thisexpression will be referred to as the zero-order term, second-order term, the fourthorderterm, etc.2.2.4 Shim Coils EquationsShim coils are designed to produce gradient fields to compensate for the <strong>in</strong>homogeneities<strong>in</strong> the field due to the ma<strong>in</strong> solenoid. The currents <strong>in</strong> the coil are <strong>in</strong>dependentlycontrolled to give maximum freedom for tun<strong>in</strong>g. In order to make thefield as homogeneous as possible, the derivatives <strong>of</strong> the axial field B z at the orig<strong>in</strong>should be m<strong>in</strong>imized or made zero by us<strong>in</strong>g the shim coils. This is one <strong>of</strong> the designconsideration for the shim coils. Detailed geometric design <strong>of</strong> X-shim coils is given<strong>in</strong> table2.1. For the purpose <strong>of</strong> further computation and visualization we considertypical geometric design for ma<strong>in</strong> solenoid and shim coils and derive the coefficients.The spherical harmonic coefficients a m,n and b m,n <strong>of</strong> typical shim coils are listed <strong>in</strong>Table-2.2.2.3 The Shim Coil FunctionsIn previous sections the theory to compute coefficients <strong>of</strong> spherical harmonics for differentgeometry is described. In table 2.2 co-efficients for X shim is described.Ideally


2.3 The Shim Coil Functions 14Table 2.1 The parameters for X shim coil designNom<strong>in</strong>al radius rConductor cross sectionNom<strong>in</strong>al current25mm0.7mm × 0.035mm100.0mALength <strong>of</strong> w<strong>in</strong>d<strong>in</strong>g 12.4mResistance at 20 0 C 8.8ΩTable 2.2 Values <strong>of</strong> the spherical harmonic coefficients for the coils derivedfrom the coil geometry. The coefficients are <strong>in</strong> µtesla.Ma<strong>in</strong> solenoida 0,0 = 7.5 × 10 6 a 0,1 = 4.2 × 10 2 a 0,2 = 4.1 × 10 2 a 0,3 = 3.1 × 10 −1X Shim coila 1,1 = 5.2 × 10 2 a 1,2 = 3.2 × 10 2 a 1,3 = 5.1 × 10 −1b 1,1 = 5.2 × 10 2 b 1,2 = 1.2 × 10 2 b 1,3 = 5.1 × 10 −1a 2,2 = 4.4 × 10 1 a 2,3 = 2.1 × 10 1b 2,2 = 1.2 × 10 1 b 2,3 = 5.2 × 10 1a 3,3 = 9.2 × 10 1b 3,3 = 9.2 × 10 1a 0,0 = 0.1 × 10 −4 a 0,1 = 2.1 × 10 −2 a 0,2 = 4.1 × 10 −2 a 0,3 = 3.1 × 10 −2a 1,1 = 3.4 × 10 2 a 1,2 = −4.4 × 10 −2 a 1,3 = 5.1 × 10 −1b 1,1 = −5.2 × 10 −2 b 1,2 = −1.2 × 10 −2 b 1,3 = 5.1 × 10 −1a 2,2 = 2.4 × 10 −2b 2,2 = 6.2 × 10 −2a 2,3 = 2.1 × 10 −3b 2,3 = 5.2 × 10 −2a 3,3 = 9.2 × 10 −3b 3,3 = 1.2 × 10 −3


2.3 The Shim Coil Functions 15zΒ zθryϕxc−φφ-dIFigure 2.2 Coord<strong>in</strong>ates for the computation <strong>of</strong> the field B z (x, y, z) <strong>of</strong> acurrent filament <strong>in</strong> the form <strong>of</strong> circular arc., X-shim coil should have only a 1,1 coeffiecients other coefficients should be zero.Butit is impossible to design totally pure X-shim coil. The various shim coils and therefunctions are described <strong>in</strong> table 2.3.The design parameter for this coil is not available<strong>in</strong> literature, these are mostly patented. So for our simmulation purpose weconsidered that the shim coils field are completely pure.


2.3 The Shim Coil Functions 16Table 2.3 Equation <strong>of</strong> field generated by shim coilsShimEquation for Field GeneratedZ 0 1Z 1zZ 2 2z 2 − (x 2 + y 2 )Z 3 z[2z 2 − 3(x 2 + y 2 )]Z 4 8z 2 [z 2 − 3(x 2 + y 2 )] + 3(x 2 + y 2 ) 2Z 5 48z 3 [z 2 − 5(x 2 + y 2 )] + 90z(x 2 + y 2 ) 2XYZXZYxyzxzyX 2 − Y 2 x 2 − y 2XYxyZ 2 X x[4z 2 − (x 2 + y 2 )]Z 2 Y y[4z 2 − (x 2 + y 2 )]ZXYzxyZ(X 2 − Y 2 ) [z(x 2 − y 2 )]X 3 x(x 2 − 3y 2 )Y 3 y(3x 2 − y 2 )


Chapter 3GPU Architecture and TextureBased Volume Render<strong>in</strong>g3.1 GPU ArchitectureGeneral purpose computation on GPUs [6] is be<strong>in</strong>g advocated <strong>in</strong> various non graphicsareas. Applications have been found <strong>in</strong> numerical computation, cryptography ,signal process<strong>in</strong>g, and many others [5]. GPUs were designed as efficient coprocessorsfor render<strong>in</strong>g and shad<strong>in</strong>g. The programmability now available <strong>in</strong> GPUs such asthe NVIDIA GeForce series makes them useful coprocessors for more diverse applications.Several programm<strong>in</strong>g languages are made available for creatively exploit<strong>in</strong>g theGPU for non-graphic applications. OpenGL Shad<strong>in</strong>g Language (GLSL) [7], nVidia’sC for Graphics (Cg) [8], and Micros<strong>of</strong>t’s High Level Language (HLSL) [9] are someexamples. S<strong>in</strong>ce the time between new generations <strong>of</strong> GPUs is currently much lessthan for CPUs, faster coprocessors are available more <strong>of</strong>ten than faster central processors.GPU performance tracks rapid improvements <strong>in</strong> semiconductor technologymore closely than CPU performance. This is because CPUs are designed for high17


3.1 GPU Architecture 18performance on sequential operations, while GPUs are optimized for the high parallelism<strong>of</strong> vertex and fragment process<strong>in</strong>g . Additional transistors can therefore beused to greater effect <strong>in</strong> GPU architectures. In addition, programmable GPUs are<strong>in</strong>expensive, readily available, easily upgradeable, and compatible with multiple operat<strong>in</strong>gsystems and hardware architectures. More importantly, <strong>in</strong>teractive computergraphics applications have many components vy<strong>in</strong>g for process<strong>in</strong>g time. Often it isdifficult to efficiently perform simulation, render<strong>in</strong>g, and other computational taskssimultaneously without a drop <strong>in</strong> performance. S<strong>in</strong>ce our <strong>in</strong>tent is visual simulation,render<strong>in</strong>g is an essential part <strong>of</strong> any solution. By mov<strong>in</strong>g simulation onto the GPUthat renders the results <strong>of</strong> a simulation, it not only reduce computational load onthe ma<strong>in</strong> CPU, but also avoid the substantial bus traffic required to transmit the results<strong>of</strong> a CPU simulation to the GPU for render<strong>in</strong>g. In this way, methods <strong>of</strong> dynamicsimulation on the GPU provide an additional tool for load balanc<strong>in</strong>g <strong>in</strong> complex <strong>in</strong>teractiveapplications. For the purpose <strong>of</strong> clarity here a brief model <strong>of</strong> GPU is presented(Fig.3.1) . Detailed <strong>in</strong>formation can be found at [10]. It conta<strong>in</strong>s a vertex eng<strong>in</strong>e,fragment eng<strong>in</strong>e, a texture load/filter eng<strong>in</strong>e, and a depth-compare/blend data writeeng<strong>in</strong>e. The vertex and the fragment processors are the user programmable stages<strong>of</strong> the pipel<strong>in</strong>e. Vertex and fragment blocks operate on data serially and they bothsupport float<strong>in</strong>g po<strong>in</strong>t operands. The vertex processor operates on data, pass<strong>in</strong>g itdirectly to the fragment processor, or by us<strong>in</strong>g the rasterizer to expand the data <strong>in</strong>tothe <strong>in</strong>terpolated values. Each triangle (or po<strong>in</strong>t) fed to the vertex processor becomesone or more fragments. The GPU support 16 bit float<strong>in</strong>g po<strong>in</strong>t for four color componentsallow<strong>in</strong>g for high dynamic range. GPUs differ by the shader capabilities andare identified by a particular shader model. nVidia GeForce 6 supports Shader Model3.0.


3.1 GPU Architecture 19Figure 3.1 Block diagram <strong>of</strong> the GeForce 6 Series Architecture.This GPUhas 6 programmable vertex processor and 16 programmable fragment processors.( Reproduced from the book GPU Gems -2, [10])


3.1 GPU Architecture 20Figure 3.2 3D texture and slic<strong>in</strong>g planes orthogonal to the view direction.Higher number <strong>of</strong> planes sample the scalar field more closely but <strong>in</strong>creasesthe GPU passes.3.1.1 3D Texture based volume render<strong>in</strong>gCPU based scalar field visualization is highly compute <strong>in</strong>tensive and is slow for realtime <strong>in</strong>teraction. One particular technique <strong>of</strong> <strong>in</strong>terest is the one that uses hardwareaccelerated texture mapp<strong>in</strong>g [11]. This technique essentially resamples the scalar field(volume data set) that is represented as a series <strong>of</strong> 2D textures. A ghost plane normalto the view<strong>in</strong>g direction slices the scalar field and samples the sectional view, shown<strong>in</strong> Fig.3.2. GPU supports the necessary sampl<strong>in</strong>g techniques <strong>in</strong>clud<strong>in</strong>g the tril<strong>in</strong>ear<strong>in</strong>terpolation. An advanced technique was proposed by [12] that demonstrates both<strong>in</strong>teractive volume reconstruction and <strong>in</strong>teractive volume render<strong>in</strong>g with hardwareprovided 3D texture acceleration. The number <strong>of</strong> slic<strong>in</strong>g planes or ghost planes isdecided by the resolution <strong>of</strong> the 3D texture and the desired quality <strong>of</strong> render<strong>in</strong>g.The order <strong>of</strong> render<strong>in</strong>g <strong>of</strong> the slic<strong>in</strong>g plane decides the alpha blend<strong>in</strong>g function. For


3.2 Magnetic field computation on GPU 21front-to-back order requires Eq.(3.1), where as back-to-front requires Eq.(3.2). WhereC dest , α dest are dest<strong>in</strong>ation color and alpha, C src , α src are source color and alpha respectively.C dest = (1 − α dest ) α src C src + C destα dest = α dest + (1 − α dest )α src(3.1)C dest = (1 − α src ) C dest + α src C src (3.2)Render<strong>in</strong>g each plane requires one pass <strong>of</strong> GPU process. Some GPUs supportmultiple render targets (MRTs) where<strong>in</strong> 4 or more pass can be <strong>in</strong>cluded <strong>in</strong> a s<strong>in</strong>glerender<strong>in</strong>g cycle. This feature particularly helps to speed up <strong>in</strong>termediate computation.3.2 Magnetic field computation on GPUThis section concentrates on the generation <strong>of</strong> magnetic field on GPU as a function<strong>of</strong> ma<strong>in</strong> coil and shim coil currents. Our first approach <strong>in</strong>volves precomput<strong>in</strong>g the3D textures for various shim coil geometries and then l<strong>in</strong>early comb<strong>in</strong><strong>in</strong>g them <strong>in</strong>the GPU. The total magnetic field is described by B TotalzI 2 B Shim 2z= I 0 B Ma<strong>in</strong>z + I 1 B Shim 1z ++ · · · is the magnetic field due to a unit current and I i , i = (0, 1, 2...) is thecurrent factor. User <strong>in</strong>terface provides the slider bars to change the I i , which is thenencoded <strong>in</strong>to an ’Uniform Parameter’ array for the fragment shader program. Thebasic flow diagram is expla<strong>in</strong>ed <strong>in</strong> Fig.3.3. We precompute the magnetic field 3Dtextures us<strong>in</strong>g Eq.(2.7) or Eq.(2.3) and coefficients from Table-2.2. the quad planesare supplied with proper 3D texture coord<strong>in</strong>ates. A vertex shader program is writtenthat transforms the quad plane and its texture coord<strong>in</strong>ates to make it orthogonal tothe view direction. The output <strong>of</strong> the vertex shader is fed to the fragment shaderwhose pseudo code is presented <strong>in</strong> Table-3.1.tex3D(., .) is the function to access the 3D texture given the texture coord<strong>in</strong>ates


3.2 Magnetic field computation on GPU 22Figure 3.3 Flow diagram <strong>of</strong> one render cycle. I i is encoded <strong>in</strong>to an arrayand set as uniform parameter to the fragment shader.texcoord.xyz. GPU generates the texture coord<strong>in</strong>ates by <strong>in</strong>terpolation, <strong>in</strong> our caseit is set to tril<strong>in</strong>ear. GPU allows for simultaneous operations on various data paths.The algorithm that is presented <strong>in</strong> Table-3.1 is parallelized <strong>in</strong> the GPU and henceseveral order <strong>of</strong> speedup is possible.Precomput<strong>in</strong>g 3D textures is compute-<strong>in</strong>tensive task and it is best done <strong>in</strong> theGPU itself. Higher number <strong>of</strong> shim coils demand that many number <strong>of</strong> 3D Textures,which directly <strong>in</strong>creases the memory requirement <strong>in</strong> O(m∗n 3 ), where m is the number<strong>of</strong> 3D textures and n is the size <strong>of</strong> the texture. For n = 256 and m = 16 the memoryrequirement would be roughly 1024 MB, with 32 floats for each voxel. Latest graphicscard doesnot have support for 1024 MB <strong>of</strong> memory. Thus, texture data will bestored <strong>in</strong> disk.Thus transfer<strong>in</strong>g data from disk to GPU will hurt the performance<strong>of</strong> the programme. To this end we propose an alternative algorithm that requiresless memory but takes up more GPU computation. For each slice plane we computethe magnetic field directly from Eq.(2.3) or Eq.(2.7). This method as described <strong>in</strong>Table-3.2 still delivers the required frame rate for <strong>in</strong>teractive render<strong>in</strong>g.


3.2 Magnetic field computation on GPU 23Figure 3.4 Volume rendered with slic<strong>in</strong>g plane 3D TexturesFigure 3.5 Image <strong>of</strong> magnetic field when <strong>in</strong>homogeniety is almost removedby shimm<strong>in</strong>g


3.2 Magnetic field computation on GPU 24Table 3.1 Fragment shader for summ<strong>in</strong>g up the fields due to various shimcoils.float Bz0 = tex3D(Bz1Texture, texcoord.xyz);float Bz1 = tex3D(Bz2Texture, texcoord.xyz);// Sum up weighted componentsBzTotal = I0 * Bz0 + I1 * Bz1 + ...// Adjust to fit <strong>in</strong> 0.0 to 1.0ScaleShift(BzTotal);float4 color.rgba = tex1D(colormap, BzTotal);Table 3.2 Algorithm for direct field computation. We embed Eq.(2.3) <strong>in</strong> thefragment shader.The coefficients a m,n are set as uniform parameters to thefragment program.// Evaluate Eq.(2.3)(or Eq.(2.7))float BzTotal = Evaluate( texcoord.xyz ) ;// Adjust to fit <strong>in</strong> 0.0 to 1.0ScaleShift(BzTotal);float4 color.rgba = tex1D(colormap, BzTotal);


Chapter 4Deformation Based VisualizationTechnique4.1 Deformation Based Visualization TechniqueTexture based volume render<strong>in</strong>g produces an image by mapp<strong>in</strong>g color to differenttype <strong>of</strong> <strong>in</strong>homogeneity. Many different k<strong>in</strong>d <strong>of</strong> <strong>in</strong>homogeneity comb<strong>in</strong>e together toproduce a s<strong>in</strong>gle color.Thus,what k<strong>in</strong>d <strong>of</strong> <strong>in</strong>homogeneity has produced the color cannotbe made out from the image .3.4 Subsequently, which shim coil to be adjustedto remove homogeneity cannot be decided from the image. Thus, to overcome thatdifficulty we propose an alternate visualization technique which deforms the geometry<strong>of</strong> visualization volume. The deformation geometry depends on the type <strong>of</strong> <strong>in</strong>homogeneitypresent <strong>in</strong> the field. The cube shaped visualization volume is divided <strong>in</strong>toa uniform 3D grid. All po<strong>in</strong>t on the grid occupied the <strong>orig<strong>in</strong>al</strong> position if there isno <strong>in</strong>homogeneity present <strong>in</strong> the field. The po<strong>in</strong>ts get displaced from their <strong>orig<strong>in</strong>al</strong>position if there is any <strong>in</strong>homogeneity present <strong>in</strong> it. The displaced position <strong>of</strong> the25


4.1 Deformation Based Visualization Technique 26po<strong>in</strong>ts are given by equation (4.1).P ′ = P + c∇B z (4.1)Where P ′ is the position <strong>of</strong> the po<strong>in</strong>t P when a nonuniform magnetic field B z isapplied <strong>in</strong> the volume.c is a constant to be chosen care<strong>full</strong>y to accentuate <strong>in</strong>homogeneity.If small value <strong>of</strong> c is chosen then effect <strong>of</strong> <strong>in</strong>homogeneity cannot be visible whereas larger value <strong>of</strong> it will <strong>in</strong>crease the size <strong>of</strong> image . As homogeneity is approached byoptimally adjust<strong>in</strong>g shim currents the deformation decreases. Thus to make deformationsnoticable the parameter c is <strong>in</strong>creased gradually. If the field is homogeneous then∇B z vanishes and volume rema<strong>in</strong>s undeformed. If a l<strong>in</strong>ear <strong>in</strong>homogeneity is presentthen each po<strong>in</strong>t <strong>in</strong> the volume will be displaced by a constant distance which resulted<strong>in</strong> translation <strong>of</strong> volume without any deformation. From the direction <strong>of</strong> tanslation itis possible to shim either <strong>of</strong> X, Y, Z coil to correct it. Other types <strong>of</strong> <strong>in</strong>homogeneitieswill produce various deformed volume. The deformation <strong>of</strong> volume due to various<strong>in</strong>homogeneity are shown <strong>in</strong> figure(4.4 through 4.19 ). The shim current which needsadjustment can be identified easily just look<strong>in</strong>g at the deformed volume.4.1.1 Implementation <strong>of</strong> Deformation Based VisualizationTo implement it a vertex shader programme is developed to render deformed volumeas given <strong>in</strong> algorithm (3.2). The visualization system be<strong>in</strong>g used is Pentium-4 workstation with n-Vidia GeForce 6600 graphics card, runn<strong>in</strong>g L<strong>in</strong>ux SUSE10. All graphicsprogrammes are written us<strong>in</strong>g OpenGL. The volume is meshed to a m × m × m grid,m be<strong>in</strong>g the number <strong>of</strong> po<strong>in</strong>t <strong>in</strong> each dimension.The grid for is shown <strong>in</strong> figure(m = 84.1).At each grid po<strong>in</strong>t the magnetic field and gradient is computed us<strong>in</strong>gequation 2.3 .From magnetic field gradient the position <strong>of</strong> each grid po<strong>in</strong>t is computed.They are implemented <strong>in</strong> CPU. Then the data is transfered to GPU for visualization.


4.1 Deformation Based Visualization Technique 27Figure 4.1 3Dmessh<strong>in</strong>g volume for deformation based visualization. Thevolume is divided <strong>in</strong>to 8 × 8 × 8 gridp<strong>in</strong>ts.The grid po<strong>in</strong>t changes there positionsdepend<strong>in</strong>g on the <strong>in</strong>homogeneity present <strong>in</strong> the field.However with this implementation when grid size exceeds 64 ×64 ×64 , the render<strong>in</strong>gbecomes slower for user <strong>in</strong>teractions. To over come that difficulty , the magneticfield value and gradient are computed on GPU itself. A vertex shader is written<strong>in</strong> assembly to optimize the performance. The color and alpha value are computedto emphasize the po<strong>in</strong>t hav<strong>in</strong>g high <strong>in</strong>homogeneity .This is done by assign<strong>in</strong>g alphavalue to the modulous <strong>of</strong> gradient. The red, green and blue colors are assigned to theabsolute value <strong>of</strong> each component <strong>of</strong> the field gradient.


4.1 Deformation Based Visualization Technique 28Table 4.1 Algorithm for deformable volume based visualization . A vertexshader programme is developed to compute the position <strong>of</strong> po<strong>in</strong>ts <strong>in</strong>side thedeformable volume// Evaluate Eq.(2.3)(or Eq.(2.7))float BzTotal = Evaluate( vertexpos.xyz ) ;// Compute gradient and save it <strong>in</strong> 3D vectorvector3d grad.xyz =gradient(BzTotal)// Compute positionPosition.xyz =Position.xyz+c*grad.xyz// Compute alpha value and color// alpha value is the magnitude gradientalpha=MagGradient(grad.xyz)// color value is absolute value <strong>of</strong> each component gradientcolor.rgb=ABS(c*grad.xyz)


4.1 Deformation Based Visualization Technique 296CPU timeGPU time54Time <strong>in</strong> second32100 50 100 150 200 250 300Grid SizeFigure 4.2 The execution time <strong>in</strong> ,CPU and GPU, at various grid size isploted65Speed up=cpu time/ gpu time432100 50 100 150 200 250 300Grid SizeFigure 4.3 Speedup = CPUtime/GPUtime.The speed up with respect todifferent grid size is ploted . For lower value <strong>of</strong> grid size speed up is less than1.


4.1 Deformation Based Visualization Technique 30Figure 4.4 Deformation <strong>of</strong> volume when Z(X 2 −Y 2 ) <strong>in</strong>homogeneity <strong>in</strong> magneticfieldFigure 4.5 Deformation <strong>of</strong> volume when X 3 <strong>in</strong>homogeneity <strong>in</strong> magnetic field


4.1 Deformation Based Visualization Technique 31Figure 4.6 Deformation <strong>of</strong> volume when Y 3 <strong>in</strong>homogeneity <strong>in</strong> magnetic fieldFigure 4.7 Deformation <strong>of</strong> volume when Y <strong>in</strong>homogeneity <strong>in</strong> magnetic field


4.1 Deformation Based Visualization Technique 32Figure 4.8 Deformation <strong>of</strong> volume when Z 2 X <strong>in</strong>homogeneity <strong>in</strong> magneticfieldFigure 4.9 Deformation <strong>of</strong> volume when Y 2 Z <strong>in</strong>homogeneity <strong>in</strong> magneticfield


4.1 Deformation Based Visualization Technique 33Figure 4.10 Deformation <strong>of</strong> volume when Z 2 − X 2 <strong>in</strong>homogeneity <strong>in</strong> magneticfieldFigure 4.11 Deformation <strong>of</strong> volume when XY Z <strong>in</strong>homogeneity <strong>in</strong> magneticfield


4.1 Deformation Based Visualization Technique 34Figure 4.12 Deformation <strong>of</strong> volume when no <strong>in</strong>homogeneity <strong>in</strong> magneticfieldFigure 4.13 Deformation <strong>of</strong> volume when XY <strong>in</strong>homogeneity <strong>in</strong> magneticfield


4.1 Deformation Based Visualization Technique 35Figure 4.14 Deformation <strong>of</strong> volume when Z <strong>in</strong>homogeneity <strong>in</strong> magnetic fieldFigure 4.15 Deformation <strong>of</strong> volume when no <strong>in</strong>homogeneity <strong>in</strong> magneticfield


4.1 Deformation Based Visualization Technique 36Figure 4.16 Deformation <strong>of</strong> volume when ZX <strong>in</strong>homogeneity <strong>in</strong> magneticfieldFigure 4.17 Deformation <strong>of</strong> volume when Z 3 <strong>in</strong>homogeneity <strong>in</strong> magneticfield


4.1 Deformation Based Visualization Technique 37Figure 4.18 Deformation <strong>of</strong> volume when Z 4 <strong>in</strong>homogeneity <strong>in</strong> magneticfieldFigure 4.19 Deformation <strong>of</strong> volume when Z 5 <strong>in</strong>homogeneity <strong>in</strong> magneticfield


Chapter 5Conclusion and Future work5.1 Conclusion and Future WorkThe result <strong>of</strong> our texture based volume render<strong>in</strong>g is shown <strong>in</strong> figure [3.4][3.5]. Whenfield is completely homogeneous the rendered image should look like image [3.5].Though, deformable grid based visualiaztion technique <strong>in</strong>volves an over head <strong>of</strong> comput<strong>in</strong>ggradient <strong>of</strong> the field at each grid po<strong>in</strong>ts, but image produced by this techniquecan be used to identify the <strong>in</strong>homogeniety present <strong>in</strong> the field. With the vertex programmegradient <strong>of</strong> magnetic field is computed on GPU itself which provides enoughframe rates for user <strong>in</strong>teraction.A comparative study is given <strong>in</strong> figure [4.3,4.2].Forthe lower grid size the speed up is less than 1.However for better quality image weneed to have greater grid size.For more than 25 × 25 × 25 grid size the speed up ismore than one. The result <strong>of</strong> deformation based visualization is shown <strong>in</strong> figure [4.4through 4.19 ]While comput<strong>in</strong>g the magnetic field the magnetic properties <strong>of</strong> the sample is nottaken <strong>in</strong>to consideration.The magnetic field distortion due to magnetic properties <strong>of</strong>sample is considerable at the edge <strong>of</strong> the sample.There are numerical models available38


5.1 Conclusion and Future Work 39to compute magnetic field distortion due to sample. Thus, <strong>in</strong> future this effect canbe modelled and implemented.


Bibliography[1] R. J. Hanson and F. M. Pipk<strong>in</strong>, “Magnetically Shielded solenoid with field <strong>of</strong>High homogeneity,” The Review <strong>of</strong> scientific Instruments 36 (1965).[2] J. Dadok, “Shim coils for superconduct<strong>in</strong>g solenoids,” Abstracts <strong>of</strong> the 10thExperimental NMR conference (1969).[3] I. Dolezal and K. Sveda, “Shim coil for NMR solenoid,” Elektrotechnicky casopis26 (1975).[4] M. D. Sauzade and S. K. Kan, “High resolution nuclear magnetic resonace spectros<strong>copy</strong><strong>in</strong> magnetic fields,” Electron. Electron Phys. 34 (1973).[5] J. D. Owen, D. Luebke, N. Gov<strong>in</strong>draju, M. Harris, J. Kugger, A. E. Lefohn, andT. J. Purcell, “A Survey <strong>of</strong> General Purpose computation on Graphics hardware,”EUROGRAPHICS (2005).[6] GPGPU:, “General Purpose Computation on GPU,” http://www.gpgpu.org(2006).[7] “OpenGL Shader Language,” http://www.lighthouse3d.com/opengl/glsl/ .[8] R. Fernando and M. J. Kilgard, CG Tutorial: A Def<strong>in</strong>itive Guide (Addision andWesley, 2003).40


BIBLIOGRAPHY 41[9] “HLSL,” http://www.neatware.com/lbstudio/web/hlsl.html .[10] M. Pharr, GPUGems2 :Programm<strong>in</strong>g Techniques for High-Performance Graphicsand General-Purpose Computation (Addison-Wesley, 2005).[11] T. J. Cullip and U. Neumann, “Accelerat<strong>in</strong>g volume reconstruction with 3Dtexture mapp<strong>in</strong>g hardware.,” Technical Report TR93-027 (1993).[12] B. Cabral and L. C. Leedom, “Imag<strong>in</strong>g vector fields us<strong>in</strong>g l<strong>in</strong>e <strong>in</strong>tegral convolution,”International Conference on Computer Graphics and Interactive Techniques(1993).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!