1 DEVELOPMENT OF SOFTWARE FOR CREATION OF GEOMETRIC MEAN IMAGES AND INVESTIGATION OF APPLICATIONS IN RENOGRAPHY THESIS FOR MASTER OF SCIENCE IN MEDICAL RADIATION PHYSICS, 20 P AUTHOR: ALBERT OLSSON SUPERVISOR: PER-OLOF SCHNELL, SENIOR HOSPITAL PHYSICIST DEPARTMENT FOR NUCLEAR MEDICINE AT THE KAROLINSKA HOSPITAL, SOLNA
2 2 STOCKHOLM 2005
3 3 CONTENTS 1. INTRODUCTION Clinical background Conventional methods Geometric mean method Related studies MATERIALS AND METHODS Gamma camera Evaluation station and programming environment RESULTS Properties of the program Program code in words Phantom measurements Simulations Clinical examinations DISCUSSION Disadvantages Possible areas of use Method for determination of accuracy Absolute activity CONCLUSION REFERENCES ABSTRACT APPENDIX 1, Program code for Geo_Mean_Fusion 22 APPENDIX 2, Clinical example... 30
4 4 INTRODUCTION 1.1. Clinical background The main purpose of this work is to create a computer program for creation of geometric mean images. The second purpose is to investigate possible advantages in using two gamma camera heads, one posterior and one anterior, when determining the relative kidney function compared to the traditional method with only a posterior gamma camera head. Renography means description of the kidney function. In the Department for Nuclear Medicine at the Karolinska Hospital, Solna, renographic studies are performed using a double head gamma camera (Hawk-Eye manufactured by General Electrics, GE). The purpose of renography can be to determine the difference in function between the left and the right kidney, as a confirmation or exclusion of renovascular hypertension as well as a control of unilateral kidney disease. For example one can study a suspected obstruction in the urine flow from the kidneys or in an early stage be able to point out the function of a damaged kidney or some other effect on the parenchyma due to repeated urethra infections. For these kinds of examinations it is crucial to know the distribution of activity and function between the kidneys. Before getting into the scope of this paper it is necessary to explain the present method for determination of activity distribution between the kidneys. Hawk-Eye has two camera heads but at present only one of the heads is used during the examination. This head is placed as close as possible to the patient s back as possible. The patient is lying on the back so the camera head is thus positioned beneath the patient, with the carbon fibre bunk between the patient and the camera head. MAG3 (Mercapto-acetyltriglycin) labelled with Tc 99m is used as the tracer. MAG3 is bolus injected intravenously while the patient is lying on the bunk. The camera will record the subsequent uptake in intervals of 10 seconds during 20 to 40 minutes. The resultant image set is sent in DICOM format to an evaluation station. Here regions of interest, ROIs, are drawn around the kidneys. To correct for background radiation there are different methods available. Often one divides the background into two parts. Firstly the intra renal background, i.e. the background originating from the kidney itself, can be represented by the activity over the heart. Secondly the extra renal background, which is originating in the volumes in front
5 5 and behind the kidney, can be represented by a thin ROI around the kidney. The quality of the background correction affects the result, particularly in case of a poor kidney function. However, this is not relevant in this paper. This work intends to minimise the deterioration of the result due to differences in kidney depths. When the background corrected activities are created for all time intervals there are two different methods to determine the relative kidney function. The first one is called the integral-method. Clearance is defined as the volume of blood cleared of the radiotracer per unit time. While the clearance is proportional to the activity we get Cldx Adx( t) = ( Cldx + Clsin ) ( Adx( t) + Asin ( t)) and while the activity is proportional to the count rate, R (if the kidneys are at the same depth) we get Cldx Rdx( t) = ( Cldx + Clsin ) ( Rdx( t) + Rsin ( t)) To increase the statistics, R can be the integral of the count rate for all time intervals during the uptake phase in respectively kidney. Thus, the integral of the curve over the uptake phase represent the relative clearance. The other method is called the slope method. The activity change is proportional to the clearance times the mean concentration of all blood plasma at the same time (C p ), which is represented by the heart activity. da Bq dt s ~ Cl [ l ] C t Bq s p ( ) l This means that the clearance is proportional to the slope of the curve over the kidney activity, k divided by the heart activity.
6 6 Cldx kdx( t) = ( Cldx + Clsin ) ( kdx( t) + ksin ( t)) No matter what method is used, any difference in coronal position between the right and the left kidney will cause an inaccurate result. Inaccurate means throughout this paper that the result does not reflect the true distribution of kidney function in terms of clearance. Any deviation, larger than what would be the case if the kidneys were located at the exact same depth, will be referred to as an inaccuracy. The attenuation factor is given by f attenuatio = e n μ d where µ is the attenuation coefficient and d is the measured depth, i.e. the distance from the back to the centre of the kidney. e The relative loss of counts for a certain depth difference d1-d 2 is μ d1 e μ e d1 μ d2. Assuming equal attenuation coefficients on both sides a depth difference of only one centimetre will result in 11% less number of counts from one side which gives the distribution 47%/53% versus the true distribution 50%/50%. A depth difference of 2 cm will result in a deviation of 21%, based on the assumption that µ= cm Conventional methods One way to handle the deviation problem is to determine the depths of the kidneys using ultrasound. The attenuation in the intermediate tissue is then compensated for by using a correction factor, f correction e d = μ. The ultrasound method requires that the patient is in a sitting position in which the kidneys often slide down resulting in another difference in depths. One can then not guarantee that the location of the kidneys will not change even more during the examination which makes the method unreliable. This method is not only time-consuming but it also contains a certain measurement error. The method used at the Karolinska Hospital in Solna intends to minimize the difference in depth by letting the patient perform a gymnastic move prior to the exam. The patient lifts the bottom from the bed a few times while lying on the bunk. This forces, in most cases, the kidneys to fall back into their cavities and they will therefore be located at similar depths. Sometimes though, this move does not help due to earlier surgery, inflammation or kidney anomalies.
7 7 An alternative method is possible with the Hawk-Eye system. While it has an integrated CT it is possible to determine the depth. However, this increases the radiation dose to the patient and the question has to be addressed whether the advantage of the procedure overcomes the risk associated with an increased radiation dose. This particular CT gives such a low radiation dose so that the advantage overcomes the risk. However the extra time required for performing the x-ray and making the calculations is a disadvantage. A simpler method would be preferable Geometric mean method The purpose of this work is both to minimise uncertainties and to simplify the procedure in clinical examinations that require a comparison of activity content in different regions of the body. The method is based on the creation of a geometric mean image from two opposite images. One posterior and one anterior image set are fused together to form the geometric mean image set. The initial idea was to apply the method on kidneys prior to kidney transplants to determine which kidney to remove from the donator. It is important to have relative values on the function and uptake of each kidney because the one with the poorest function will be removed for donation. The main difference between the old method and the new one, which is labelled the geometric mean method, is that both camera heads are used during the acquisition. One head is positioned, as before, beneath the patient while the other head is placed opposite to the first head, i.e. in the front of the patient close to the abdomen. Both image sets are sent to the evaluation station where they are processed by the developed program, called Geo_Mean_Fusion. This program calculates the geometric mean values between each pixel pair that corresponds to the same position in the image set. When this has been done the resultant image set is saved and can then be opened at any evaluation station for further analysis as previously described. When the comparison of the uptakes is performed with the new method the result will, in most cases, be less inaccurate if there is a difference in coronal positions of the kidneys. Why does then a geometric mean value give a better comparison? The geometric mean value answers the question: If both quantities had the same value, what would that value have to be in order to achieve the same product? This is what we
8 8 want to know because it gives the same result independent of the coronal position of the activity. Another way to describe it is that the geometric mean is independent of the depth. Let us call the activity in the object A, the distance from the back to the centre of the object d [cm], and the attenuation coefficient µ [cm -1 ]. The thickness of the body, i.e. the distance from the surface of the back to the surface of the abdomen, is set to unity. The attenuation factor will then be e μ d μ in one direction and ( 1 e d ) in the opposite direction. The number of counts detected in each detector will therefore be proportional to A e to G. M. = and A e μ d μ ( 1 d ) A e μ d A e. The geometric mean of the number of counts is then proportional μ (1 d ) This expression can easily be simplified to G. M. = A μ e. From this it is clear that the geometric mean has no dependence of the depth d. It would be sufficient to just calculate the product of the corresponding pixel values, without calculating the square root, while this also gives a depth independent value proportional to the activity. However, I choose to calculate the geometric mean because I want the pixel values to have the same order of magnitude as the original images. Observe that the arithmetic mean, μ d μ ( 1 d ) A e + A e A. M =, 2 is not independent of depth and consequently can not be used for this purpose Related studies Several studies have been done investigating the relevance in using the geometric mean method. H. Benito I et al (2001), has investigated this with the age of the patient and the diagnosis taken into account. The conclusion was that patients older than nine years and patient with genitourinary malformations show a statistical significant difference between the posterior and the geometric mean method. Similar conclusions were made by Yapar AF et al (2005). A large investigation of the impact of gas in the intestines, on the geometric mean method, seems not to have been done. This is briefly investigated in this paper.
9 9 2. MATERIALS AND METHODS 2.1. Gamma camera The gamma camera (Hawk-Eye, manufactured by GE) is a Single Photon Emission Computed X-ray Tomograph, SPECT, with an integrated Computed Tomograph, CT, which is called a SPECT-CT. It has two flexible heads which can be adjusted to most desirable positions Evaluation station and programming environment The code is written in the language Aladdin. Aladdin is a language developed by GE and it is based on Basic Script which is similar to Visual Basic. Aladdin contains functions that are convenient to use when dealing with images and series of images. For example it is possible to create matrixes with pixel values from images and perform operations directly on images by using predefined functions. The programming environment is included in the Entegra package which is a full image evaluation system, also developed by GE. Entegra includes several applications written in Aladdin, suitable for evaluation of many different kinds of patient examinations. Due to the fact that Aladdin is a script language, which implies that it doesn t need to be compiled, it is not possible to run applications without having the Entegra package installed on the computer. The term script refers to a set of instructions (a program) that is executed by another program rather than the computer s processor. In our case the other program is Entegra. It is obvious that Aladdin is constructed a bit sloppy. Some notations are not consistent and bugs appear more often than in languages having had time to develop during several years. Another problem, originating in the performance of the computer, is that errors appear when big datasets are processed. When the computer can t hold more data in the memory the system gets instable and has to be restarted in stead of giving a warning, which would be preferable. The method to get around this will be explained later on. 3. RESULTS 3.1. Properties of the program The new program is named Geo_Mean_Fusion as it creates a fusion image from two images by calculating the geometrical mean value for each pixel in the image. The program is described in detail later on.
10 10 Normally each image in the series of images is acquired during 10 seconds. In the case of a 40 minutes measurement we get 480 images in total for both heads. Each image has 128 x 128 pixels which end up in approximately four million calculations to create the geometric mean images. Due to the relatively complicated operation N1 N 2, which is the formula for the geometrical mean, quite some time is required to complete the set of images. The square root is a time consuming operation for the computer while it requires an iterative algorithm. Under some circumstances up to one minute can be necessary to produce the whole set of images. An initial problem was that the computer, despite its one gigabytes ram-memory, could not hold sufficiently much data to be stable throughout the calculations. The algorithm is therefore designed to carry out a limited number of operations before the results are saved on the hard drive. The lack of flexibility is often a problem with applications constructed by big companies. They often limit the possibilities for the user because they want to be sure that mistakes should not be possible to make and to increase the need for future purchases. Geo_Mean_Fusion was created with the intention to be very flexible. The reason for this is that it is difficult to predict future needs of the application. A flexible application is more likely to be useful for other purposes than what it is constructed for. In the Department for Nuclear Medicine at the Karolinska Hospital, physicians often use different evaluation stations to evaluate images. This is the reason why I have constructed a separate application and thus have not integrated it in existing applications for renal analysis. In Geo_Mean_Fusion you can either choose to watch the images directly in the program or save them so that you can export them to whatever evaluation station you prefer to use Program code in words The program code can be viewed in appendix 1. To facilitate the understanding of the code the program is in the following explained in words. Figure 1 visualizes the program design. The ellipses with fat borders represent functions that will be executed by the user while the other ellipses represent functions and sub functions executed by the program itself. The arrows explain the flow between the routines.
11 11 Fn DataValidate Sub Geometrisk Sub handlecb1 & 2 Sub displayimage Sub Main Sub FelGeo Sub SkapaScreen Fn GeoMean Sub ZoomaIn Sub SaveGeoMean Sub SaveAll Sub ZoomaUt Fn SaveAndExito Sub displayimageall Sub Helpo Figure 1. Flow scheme over Geo_Mean_Fusion. Ellipses with fat borders illustrate functions which are executed directly by the user while ellipses with thin borders illustrate functions executed by the program itself. 1. To be sure that the selected data set is appropriate to apply on Geo_Mean_Fusion the set is checked by a data validation routine named Function DataValidate in the code. This is by default the first code to be executed. The set must consist of two images or image sets unless the third set is a result from earlier work with Geo_Mean_Fusion. If the data set does not fit into the criteria warning texts will notify and specify the problem for the user. If the user accepts the problem Geo_Mean_Fusion will start despite the warnings. The reason for this is to maximize the flexibility of the system. Of course this assumes that the user knows what he is doing. DataValidate also loads the images so that they are accessible later on. 2. When the chosen study has been validated the script goes on to Sub Main. Sub Main first clears the memory from eventual error messages and clipboard objects. Then it redirects to the sub function skapascreen where so called view ports are created. A view port is an area where images and texts can be plotted. The images are plotted in the view ports and the viewing direction is printed beneath the images and checked to agree with the images header files. A toolbox for image viewing, which is included in the Aladdin package, is put on the left side of the screen. This gives the user the possibility to:
12 12 Create Regions of Interest, ROIs. Run the frames as a movie. Reframe the series, i.e. pick out the most relevant frames for inspection. Make annotations and distance and angle measurements. Panorate and zoom the images. Adjust colours for improved visibility. Get statistical information about images or ROIs. The tools for handling the image processing, i.e. create geometrical mean images, are put on the left side of the screen. The user has the following possibilities: Create geometrical mean images Chose whether the created image should be viewed from behind or from the front. Geo_Mean_Fusion is now standing by for further orders. Figure 2 shows the screen when a geometric mean image and a ROI have been created. Figure 2. Main window with ROI around the geometric mean image
13 13 3. If the user presses the button Skapa geometrisk medelvärdesbild the subroutine Geometrisk starts. First a text that says that the procedure might take a while is printed on the screen. Buttons for further operations are enabled and disabled to prevent the user from making illegal operations. The choice of viewing angle is controlled before the calculation starts. Due to limited memory space the number of frames in the images is controlled. If the number of frames exceeds 100 a subroutine called FelGeo is called. This routine divides the image sets into four equally large image sets and sends them one by one to the subroutine GeoMean to be processed. The program is prepared for additional image fusion routines why a variable called Aktuell is filled with the string Geometrisk to be able to distinguish the created image set from other image sets. 4. The actual calculations are made in the function GeoMean. This routine can be seen as the heart of the program and is quite short. The process in GeoMean is explained in a few steps below: The number of images in the sets are controlled. The pixel dimensions are controlled. The pixel values are read from the images and put in three dimensional matrixes. A double for loop runs and calculates the geometrical mean values for each pixel and puts them into a three dimensional matrix. Before each operation the pixel values are converted from integer to long which means that they use 4 bytes instead of 2 bytes. If this is not done there is a big risk for errors to occur due to lack of bits during the calculations. While each byte consist of 8 bits the maximum integer value is ± 2 (2 8 1) = ± The reason for subtracting 1 in the exponent is that one bit is needed to represent the sign of the value. When the multiplication of the pixel values is carried out the product will often exceed In the case of 4 bytes the largest (4 8 1) 9 value to be represented is ± 2 ± 2 10, which is more than enough to represent the products. When the matrix is created it only remains to create the geometrical mean image out of the pixel values.
14 14 GeoMean is as a function which means that it demands input values and returns an output value, i.e. an image. This approach facilitates the programming while it makes it unnecessary to rewrite the code when you want to do the same calculations in some other context. 5. The script now returns to Geometrisk where the recently created image is sent to the sub function displayimage to be plotted in a separate view port. 6. The ellipses in the flow scheme with dashed borders represent further options available to the user. ZoomaUt makes it possible for the user to view the geometrical mean image in full screen which makes it easier to draw ROIs and evaluate the image for a correct diagnosis of the patient. ZoomaIn simply returns to the default view where all images are viewed. SaveGeoMean saves the image. SaveAll saves the image including eventual ROIs and notations. SaveAndExito Saves the image, ROIs and notations and terminates the program. Helpo opens a help file where the user can read an explanation of the program Phantom measurements Geo_Mean_Fusion has been tested on images originating from phantom measurements. The phantom was a water filled PMMA container shaped like the abdomen region where the kidneys are located. The kidney phantom was a plastic container with size and shape like a real kidney. Both kidneys were represented by the same phantom to guarantee that the activity content was the same. Acquisitions were made with the kidney phantom at different depths in the body and decay corrections were made for each acquisition to allow the simulation of two kidneys with only one phantom. The kidney phantom was filled with approximately 50 MBq 99m Tc which is slightly more activity than is normally accumulated in one kidney. The reason for this was to get better statistics. Data acquisitions were made during 3 minutes with the kidney phantom at different depths. The result is presented in Figure 3.
15 normalized number of counts y = e x posterior head geometric mean attenuation correction anterior head fit distance phantom surface-centre of kidney phantom [mm] Figure 3. Comparison between methods with kidney phantom. The measurements were made using a water phantom in which a 99m Tc source were moved in 10 mm steps from one side to the other. The correction factor f, used to create the attenuation corrected curve, is given by f d = e μ where µ is the linear attenuation coefficient and d is the depth of the kidney. The depth is defined as the distance from the phantom surface to the surface of the kidney phantom. The attenuation coefficient is effective which means that scattering is compensated for in the coefficient. The value of µ is acquired from the exponential fit in Figure 3. The increase in count rate of about 4% in the centre of the phantom, is due to a larger fraction of scattered radiation. This is though not a problem because the kidneys are located on similar depths and therefore undergo the same effect on both sides. The distribution of activity between the kidneys will therefore not be much effected. The human body is far from symmetric with respect to attenuation coefficients. The kidneys are more or less shadowed by the liver and intestines. The liver has a higher attenuation coefficient than intraperitoneal adipose tissue from which follows that the radiation will be more attenuated on the liver side. Intestines are often more present at the left side. A worst case scenario, which is not probable in reality, was simulated using a phantom. The effects of different attenuation coefficients in gas, adipose tissue and water are illustrated in Figure 4. The values originate from phantom measurements. The air
16 16 cavity was 4.5 cm thick and covered approximately 80 % of the kidney while the adipose was 5 cm thick and covered the whole kidney post post post # counts geo geo geo ant ant ant water only water + 5 cm fat water + 5 cm fat cm gas Figure 4. Effects on the number of detected counts with different materials in front of the kidney. The effects on the geometric mean values are also visualized. A large difference in the amount of adipose tissue does not affect the result more than approximately 2% which gives a side difference 50.5%/49.5% in stead of the true 50%/50%. However, gas in the intestines affect the value of the activity distribution much more. The darkest piles in Figure 4 illustrate this effect. The side distribution of activity is calculated according to: left D = 100% ( left + right) right 100% ( left + right) where left and right are the number of counts detected on respectively side. If the calculation is done with the geometric mean values for the measurement with fat and air present the value D = 55.1%/44.9%. In this case the geometric mean method gives a misleading result Simulations To find out about the usefulness of the geometric mean method on real patients, simulations based on 37 CT images were carried out. By inspection of the CT images it
17 17 was found that 4.5 cm of homogenous gas distribution, as used in the phantom measurement, is highly unlikely to appear. Figure 5 shows an example of a CT image where a large air cavity is present. However, the cavity only covers a small part of the kidney. The other slices thus do not show this big air cavity. Figure 5. CT image where air cavity is visible Every slice, which contained a part of any kidney, was investigated with respect to distance from the surface of the kidney to the front and the back of the patient. The slices represented 5.0 mm each. Mean attenuation values were achieved from five patients by drawing ROIs over the intermediate tissue. Supposed that each kidney had the same activity content the activity distributions were calculated simulating the use of only a posterior head as well as the use of both a posterior and an anterior head to form geometric mean images. Figure 6 shows the obtained activity distributions for the five patients. In four cases the geometric mean method gave a better result than the posterior method. In Figure 6 four simulated patients are included to clarify the impact of depth differences and attenuation differences. The data are listed in Table 1.
18 18 % appearing to originate in right kidney Patient 1 Patient 2 Patient 3 Patient 4 Patient 5 Fake 1 Fake 2 Fake 3 Fake 4 posterior geo mean Figure 6. Simulation of clinical examinations using CT-images. Each pile pair represents a patient. Red piles represent the posterior method and green piles represent the geometric mean method. The Y-axis represents the proportion of the total number of counts appearing to originate from the right kidney. In case of a true representation the piles should be at 50 %, i.e. not visible. Patient 1, male Patient 2, female Patient 3, mail Patient 4, female Patient 5, male Fake 1 Fake 2 Fake 3 Fake 4 DISTRIBUTION [%] DISTANCE DIFFERENCE [CM] ATTENUATION DIFFERENCE [%] POSTERIOR GEOMETRIC ANTERIOR POSTERIOR ANTERIOR POSTERIOR dx sin dx sin Table 1. Effect on values of activity distribution for different attenuation values and distances from kidney surfaces to abdomen and back. Five real patients and four simulated patients are listed. The simulated patients clarify the impact of the variables. A difference in posterior distance has greater impact on the geometric mean value than a difference in the anterior distance because the attenuation factor in general is lower on the anterior side. Patient number 3, where the posterior method is better, has a posterior depth difference close to zero which causes the posterior method to give a perfect result. The anterior distance is large which causes the geometric mean method to fail in its prediction. The CT images are acquired with mean photon energy 73 kev. The simulations therefore depend on a similar relation between the attenuation in the tissues for kev which is the emission energy from 99m Tc, and for 73 kev. If the side distribution is 57.7%/42.3%
19 19 for a two centimetre air cavity calculated with the attenuation factors for kev, the corresponding value calculated with the attenuation factors for 73 kev is 59.5%/40.5%. The simulations thus give larger errors than actual examination would give. The effects on the number of detected counts from a homogenous air cavity and adipose tissue with different thicknesses are illustrated in Figure 7. The graph comes from theoretical modelling of a 20 cm thick body. The attenuation values are taken from the web site which is a collection of values brought from the photon interaction database at the National Institute of Standards and Technology. 1,4 1,35 1,3 relative number of counts 1,25 1,2 1,15 1,1 air cavity adipose tissue 1, distance [cm] Figure 7. Effect of air cavity and adipose tissue. To get an idea of how many examinations that will gain accuracy by using the geometric mean method the 37 adult patients were examined re difference in posterior kidney depth. The mean depth difference was 0.64 cm and one standard deviation was 0.54 cm. From this follows that 4.5 % of the patients are expected to have a posterior depth difference larger than 1.18 cm. This difference causes the measured distribution to appear to be around 46.6%/53.4% in stead of an actual distribution of 50%/50% if only a posterior head is used. This error can result in donation of the kidney with best function in stead of, as desired, the one with poorest function. The geometric mean method does not alone solve the problem because there is a possibility, in case of large air cavities, that another error will be added to the first one. In the discussion at the end of this paper a method for determination of the accuracy of the geometric mean method is presented. With this method it is possible to determine if the result is reliable or not.