Compartments_TP Manual

J. Anthony Parker, MD PhD
Beth Israel Deaconess Medical Center
Boston, MA
Revised: 26 May 2007


ImageJ is a highly versatile image processing program written by Wayne Rasband in java which will "run anywhere".  It has a particularly outstanding application programming interface (API).

Compartments_TP is an ImageJ plugin which demonstrates a few examples of compartmental analysis.  Users who just want to "get started" should skip down to the section called "ECF Model".

Compartmental analysis is a very general method for visualizing and simulating ordinary differential equations.  Compartmental analysis is a method frequently used in pharmacokinetics, the study of the absorption, distribution, metabolism, and excretion of drugs.  There are much more general programs with graphical user interfaces which allow a user with limited mathematical background to set up compartmental analysis models and to run simulations.  Particularly relevant to the Molecular Imaging community is the Kinetic Imaging System from the UCLA Molecular and Medical Pharmacology Department,

The Compartments_TP plugin is much more limited in scope.  It provides the ImageJ user with the ability to simulate a limited set of compartmental analysis models.  The goal of this plugin is to provide a didactic tool that can be used for a molecular imaging course.  Compartmental analysis as applied to molecular imaging is complicated by the necessity of converting between units of radioactivity, moles, and grams (see Appendix IV).  Compartments_TP attempts to ameliorate this complexity by doing these conversions for the user.  For those who have not yet discovered the value installing ImageJ on their own computers, a version of Compartments_TP that can be run as an applet is also available,

A good, if relatively unavailable, chapter on compartmental analysis was written by Albert Gjedde and Dean Wong, Gedde A, Wong DF:  Modeling neuroreceptor binding of radioligands in vivo. in Frost JJ, Wagner HN: Quantitative imaging:  Neuroreceptors, neurotransmitters, and enzymes.  Raven Press, Ltd, New York, 1990.

Data Entry

Values can be entered using integers (e.g. 5) or rational (e.g. 5.6) values.  Scientific notation is entered using "e" for the exponent.  For example, 5e-3 is interpreted as 5 x 10-3.

User input values are kept in a Java feature called static variables.  That means that on subsequent runs of Compartments_TP, the values in the dialogs will be equal to the prior entries.  This feature is often quite useful; however, it can make it difficult to get back to the initial values.  When running the plugin locally, it is necessary to restart ImageJ to return to the initial values.  When running the applet, it may be necessary to restart the browser to return to the initial values.

A more detailed description of the user dialogs is given in the first appendix.


I follow Gjedde and Wong in calling the quantity transferred between compartments "mass".  The "mass" is not generally a physical mass.  In this plugin, the "mass" may be radioactivity, moles, or atoms.  Using the specific-activity, half-life, and molecular weight, the "mass" can be converted between these different types of "mass" (see the third appendix).  The "Compartmental Analysis" dialog allows the user to select the units which are used for mass, volume, rate constants, and molarity.  Note that since the range of units is often a factor of 1012 or more, it is very easy to enter completely ridiculous values.


The graphing capabilities of this plugin are relatively limited.  However, the output values can be listed in a table.  The table can then be imported into a program with more extensive graphing capabilities, e.g. Excel.

Running Compartments_TP

Compartments_TP can be run as a stand alone ImageJ plugin (Plugins/NucMed/Compartments_TP) or it can be run from an applet in a web browser.  See for the plugin and for the applet version.  The plugin site also provides instructions for installing Compartments_TP.  Running the plugin from an applet can be done from any platform with a Java competent web browser using a reasonably up-to-date Java.  (Reasonably up-to-date Java can be a problem on poorly maintained Windows systems.)

The differential equations defined by the model are simulated with difference equations (using the fourth-order Runge-Kutta method).  It is easy to pick values where the simulation breaks down.  The second appendix discusses simulation failure and methods to avoid these failures.


The next few sections may be of interest to those who already understand compartmental analysis.  Most Compartments_TP users will want to skip to the section called "ECF Model".

All of the models are based on a model with 6 compartments.  Some of the compartments are excluded for some of the models.  A compartment can hold a quantity of "mass".  The units of "mass" can be either radioactivity, moles, or grams.

Compartment Size

A compartments can represent a volume, in which case it can hold any amount of mass.  Alternately, a compartment can be a receptor in which case the amount of mass that the compartment can hold is determined by the amount of receptor, Bmax.  The volume for compartments that are receptors is equal to the volume of the parent compartment.  Bmax is given as a concentration, e.g. nM (nmol/L).  Compartments_TP also allows the amount of receptor to be entered as "a mass", Mmax, e.g. nmol.  In some models, a compartment can be either a volume or a receptor.  In that case, the "Unit" entry in the "Compartment Sizes" dialog determine the compartment type.

Plasma or Blood and Urine Compartments

A quantity of "mass" is injected into the plasma or blood (Compartment I) at time zero.  (All the models are "bolus" models.)  The "mass" is distributed to the other compartments during the simulation and it is eliminated via a urine compartment (Compartment VI).  In the typical 70-kg male, the plasma is about 3 L and the blood is about 5 L (hematocrit of 40%).  Plasma flow is about 3 L/min; blood flow is about 5 L/min.  In some models, the plasma is assumed to rapidly mix with the extracellular compartment, 14 L, so that Compartment I is given a volume of 17 L.  (Intracellular water is about 25 L, so total water is about 42 L.)  The urine compartment is set by default to 1 L, although the only effect of the urine compartment size is on the urine concentration.

Clearance from the plasma into the urine is often equal to the glomerular filtration rate (GFR), about 200 mL/min.  Glomerular filtration is usually normalized for the body surface area.  200 mL/min is equal to 200/1.73 = 116 mL/min/m2 for the typical 70-kg male with a body surface area of 1.73.  This value is about equal to the value typically given as the normal GFR, 120 mL/min/m2.  If all of the "mass" is extracted in one pass through the kidneys, the clearance is equal to effective renal plasma flow (ERPF), about 1000 mL/min.  (The filtered fraction, GFR divided by ERPF is about 20%.)  Alternately, clearance into the urine compartment can be conceptualized as metabolism, or a combination of excretion and metabolism.


In the examples below, the compartment volumes are often set to physiologic volumes (see previous section).  In pharmacokinetics, it is typical to use an apparent volume-of-distribution which is obtained experimentally.  In this case, the apparent volume-of-distribution relates the concentration in blood or plasma to the amount of tracer in the body.  An apparent volume-of-distribution is usually much different than any physical volume.  For example, due to the Na+/K+ pump in the cell membrane, the intracellular volume-of-distribution for K+ will be very large while the intracellular volume-of-distribution of Na+ will be very small.


Uniqueness is a major issue when trying to estimate compartmental parameters from measured data such as a plasma time-concentration curve.  Many different models can typically produce the same plasma time-concentration curve.  For example, a model using a single transfer constant for both input and output and a volume-of-distribution is equivalent to a model using the true physical volume and input and output constants with different values.  Models with different numbers of compartments or different compartment layouts can often be made to match the same experimental data within measurement error.

Generally, the compartment model needs to be establish through other sources of information.  Then a particular set of constants can be derived for that model from the experimental data.  However, even if the correct model is known, one or several of the parameters may have little effect on the measured data.  In that case, widely varying values can be used for these parameters.  Compartmental analysis can show if a particular model is possible given the data.  But, showing that a particular model can fit the experimental data does not imply that model is correct.

This plugin only does simulation, it does not fit experimental data.  But, it is still important to remember that making a model that produces reasonable results should not be over interpreted as implying that model is the correct model.

Transfer Between Compartments

The rate of transfer between compartments can be given by different types of constants.
Depending upon the model, different types of constants can be entered.  The type of constant is selected by picking a unit.  For example, in a model allowing either a rate constant or a clearance, selecting "h-1" would indicate a rate constant and selecting "L/h" would indicate a clearance.

Full 6 Compartment Model

Full 6-Compartment Model
The full 6 compartment model allows the greatest choice of inputs.  In fact, all of the models except for the "Receptor plus non-specific binding" model can be simulated using the full 6 compartment model.

The full 6 compartment model is primarily intended to allow the user to entry his/her own model values.  However, the initial values are set using values from Levitt, BMC Clinical Pharmacology 2003;3:3.  The plasma compartment is 2.68 L.  Compartments IV and V correspond to the extracellular, 9.35 L, and intracellular, 18.18 L, water space of three tissues with low blood flow -- muscle tendon, and other.  Compartments II and III correspond to the extracellular, 5.43 L, and intracellular, 4.37 L, water space of the remaining tissues, which have high blood flow.  K5 and K6, and K1 and K2 are set to the respective blood flows, 0.725 L/min and 4.89 L/min -- i.e. the model assumes flow limited input and output.  Transfer between extracellular and intracellular compartments, k7 and k8, and k2 and k4, is arbitrarily set to 0.1 min-1.  Renal clearance is set to 0.2 L/min, approximately equal to GFR.  This flow limited model shows prompt distribution to the highly perfused tissues with slightly slower distribution to the low flow tissues.

ECF Model

The ECF model shows the behavior of an agent which is distributed in the extracellular fluid space and excreted via glomerular filtration.  This behavior is typical for many radioisotopes, e.g. 99mTc-DTPA, for Gd-DTPA, and for radiological contrast materials.  For a 70-kg male, the plasma volume is about 3 L and the extracellular fluid space is about 14 L.  The "mass" is injected into the plasma at time zero.  The clearance from the plasma to the extracellular fluid space is set to 1 L/min.  The "mass" returns to the plasma from the extracellular fluid space at the same clearance, 1 L/min.  It clears from the plasma into the urine at a glomerular filtration rate of 200 mL/min.  (Glomerular filtration is often normalized for the body surface area.  200 mL/min is equal to 200/1.73 = 116 mL/min/m2 for the typical 70-kg male with a body surface area of 1.73.)

Answer "OK" to all the dialogs without changing any of the values.  On the graph, notice that the plasma activity declines rapidly after injection.  Most of this rapid decline is do to equilibration of the plasma with the extracellular fluid space.  The actual elimination into the urine takes place over a longer time scale.  The uptake and excretion of activity in the kidneys (as seen for example on a renogram) appears to occurs in ten to twenty minutes; however, elimination tracer from the body to the urine actually takes hours.  The slower elimination from the body is seen in the plasma curve as a second smaller, slow component.  A common mistake is to see the early disappearance from the blood and not take sufficient note of the second component.  Although the second component is much lower than the first, it persists for much longer and actually accounts for an important part of the excretion.

See what happens when you try different values for K1, the clearance from the plasma to the ECF, and K2, the clearance from the ECF to the plasma.  If all of the tracer is extracted during a single pass, clearance is equal to plasma flow (clearance = flow * fractional-extraction).  Typical plasma flow is about 3 L/min.  Decreasing K9 can be used to simulate renal failure.  Instead of using plasma volume for Compartment I, one could use blood volume, 5 L; for tractional-extraction of 1, clearance would be equal to blood flow, about 5 L/min.

Slow Space Model

Slow Space
The slow space model is similar to the ECF model, but a second slow space has been added.  The slow space could represent something like a pleural effusion where the rate of exchange with the plasma is slower than with the general extracellular fluid space.  The slow space has been given a volume of 1 L, and input and output clearance of 0.005 L/min.  The extracellular fluid compartment, which is in fairly rapid equilibrium with the plasma, has a concentration which is similar to the plasma.  The slow space takes a much longer time to equilibrate with the plasma.

Again reply "OK" to all the dialogs without changing the values.  The concentration in the slow space rises slowly.  When the plasma concentration falls below the slow space concentration, the concentration in the slow space starts to decline.  But, the rate of decline is slower than the extracellular fluid space.  As the plasma concentration falls to a low level, the concentration in the slow space becomes higher than the extracellular fluid space.  This behavior is typically seen on studies like a bone scan, where the pleural effusion has higher activity than the soft tissue at the time of scan when the plasma activity is low.  Note, the activity is not "concentrated" in the effusion by an active process or "trapped" by a receptor, it is just slow in getting out of the effusion.

Try making the clearances for the slow space equal to 0.0005 L/min.  In this case, the rate of equilibration is too just too slow to allow much activity to get into the slow space.  In the case of a bone scan, transudates usually do not show activity on delayed images -- the rate of exchange is just too slow.  Exudates which have slow exchange, but more rapid than transudates, show increased activity on delayed images -- the rate of exchange is slow, but fast enough.

Blood Flow Model

Blood Flow
The blood flow model shows a situation where the distribution to the two tissues is in proportion to blood flow.  The model is similar to previous models in that the activity is injected into the blood, cleared into two tissues, and excreted into the urine.  The key feature is that there is no return from the tissues into the blood, k2 and k6 are zero.  The activities in the tissues is in direct proportion to the clearances to the tissues.

Sapirstein (Am J Physiol 1958; 193:161) defined 3 principles which assure that the distribution of a tracer between tissues will be in proportion to blood flow.  First, the tracer must be mixed in the blood to prevent preferential arterial streaming into one of the tissues (as occurs when tracer is injected into the aorta).  Our assumption of instantaneous mixing in the compartments fulfills this requirement.  Second, the fractional-extraction must be the same in all tissues.  If the fractional-extraction is the same, then the clearance which is blood flow times fractional-extraction, must be in proportion to blood flow.  If all of the tracer is extracted in a single pass (fractional-extraction equal to 1), then a forteriori, tracer distribution will be proportional to blood flow.  Third, the tracer cannot leave the tissue.  Setting k2 and k6 to zero assures that nothing leaves the tissues.

The prototype blood flow tracer is microspheres.  Microspheres larger than the capillary diameter have a fractional-extraction of 1, and they do not leave the tissues.  When trying to measure relative blood flow, it is important to select a tracer that follows the Saperstein principles.  However, blood flow is often a complicating factor in receptor imaging.  If the ligand follows Saperstein's principles, the it will measure blood flow and not receptor concentration.  Often the key factor is the off rate from a receptor.  If there is not an adequate off rate from the receptors, then a tracer designed to measure receptor concentration will end up just measuring blood flow.

The clearance into Tissue 1 (1 mL/min) is twice that in Tissue 2 (0.5 mL/min).  The activity in Tissue 1 is equal to twice the activity in Tissue 2.  Try changing k2 and k6 and see what happens.  (Since both compartments are 1 mL, there is no difference between defining washout in terms of clearance in mL/min and washout in terms of a rate in min-1.)  Often, if the clearance into Tissue 1 is twice the clearance into Tissue 2, then the rate of washout of Tissue 1 will be about twice the washout of Tissue 2.  Try setting k2 to 0.02 min-1 and k6 to 0.01 min-1.  Even at these modest wash out rates, the activities in the tissues no longer reflect blood flow.  Try different values, and see how the activities depend upon the input and output rates.

Single Volume

Single Volume
The dashed box in the diagram represents a single volume.  Within this volume, the tracer can be free in solution or it can be bound in either of two receptor compartments.  The tracer can be eliminated from the model through a process which is called "metab" for metabolism.  This model is a Michaelis-Menten type model, although we will be concerned with the dynamics of the model, not its equilibrium behavior.  The free tracer can is bound to the two receptors with constants, kon1 and kon5.  The tracer leaves the receptors with rates koff2 and koff6; however, koff is equal to KD*kon and KD has a natural interpretation as the dissociation constant at equilibrium in the Michaelis-Menton model, so Compartments_TP uses KD for output.  The dissociation constant is the half-saturation concentration, the concentration at which half of the receptors are occupied at equilibrium.

There is more of receptor 1, 10 nM, than of receptor 2, 5 nM.  The kon rates are the same 0.3 (min-nM)-1, and the dissociation constants, KD, are the same 1 nM.  There is no metabolism of the tracer, k9 = 0.  Since we are injecting 10 pmol into a volume of 1 mL, the initial concentration will be 10 nM.  The 1 nM receptors are quite avid, but the uptake rate 0.3 (min-nM)-1 is slow given the 1 minute simulation.  Over the course of 1 minute, the tracer is taken up onto the receptors in proportion to the concentration of receptor -- twice as much on receptor 1.

Change the KD2 to 10 nM, i.e. making receptor 1 less avid.  Keep the receptor compartment sizes the same with twice as much of receptor 2.  Now, the uptake onto receptor 2 is slower, but greater that the uptake on receptor 1.  Even though there is less of receptor 2, because it is more avid, more of the tracer binds to receptor 2.  Adjust the quantity of receptors and the the transfer rates and see what happens.

Two Tissues

Two Tissues
This model has two tissues with receptors.  Tracer is injected into the plasma which is rapidly equilibrating with the the extracellular fluid compartment.  Both tissues have a volume of 1 mL; the dotted boxes show the two volumes.  Each tissue has a receptor compartment; tissue 1 has 1 uM receptor and tissue 2 has 0.5 uM receptor.

The clearance is 0.5 mL/min from the ECF into both tissues.  The on rates, 0.05 (min-uM)-1, and the dissociation constants, 0.5 uM, are the same for both receptors.  The clearance to the urine is 200 mL/min.  The on rates are relatively slow so the equilibration with the tissue takes some time.  If you increase the on rates to 0.5 (min-uM)-1 for both, you will see that the equilibration with the tissues is faster.

The dissociation constants, 0.5 uM, are greater than the tissue concentration; if there were no excretion and the system were allowed to come to equilibrium then the concentration would be B = Bmax*{C/(KD+C)}.  Set the urine clearance to 0 mL/min and you will see that C is roughly 0.1 so the receptor concentration in tissue 1 is about 2*{0.1/(0.5+0.1)} = 0.33 and the concentration in tissue 2 is about 1*{0.1/(0.5+0.1)} = 0.17.

Setting the urine clearance back to 200 mL/min and the on rates back to 0.05 (min-uM)-1, try setting the dissociation constants, KD, to 0.05 uM.  The receptor occupancy will be much higher with this dissociation constant.  Because of the relatively slow on rates, it takes a long time to approach equilibrium, but because of receptors avidly bind the tracer, the off rate is slower, koff = KD*kon.  There is relatively little washout of tracer.

Two Tissues: High Affinity

This model is the same as the previous model, "Two Tissues".  It just has different starting values.  The dissociation constants, KD, are equal to 0.05 uM for both receptors.  The receptor concentrations, Bmax, are equal to 50 uM and 25 uM.  Notice that the two compartments no longer accumulate tracer in proportion to the receptor concentration.  To see what is happening, scale the graphs to "ECF".  Notice that the tissue concentration never approaches the ECF concentration.  As soon as tracer comes into the compartment, it is bound to the receptor where it is "trapped".  Under these conditions, the relative tracer concentrations will more closely match the clearance into the tissues.

Leaving the receptor concentrations, Bmax, at 50 uM and 25 uM, change the dissociation constants, KD, to 0.05 uM.  Increase the simulation time to 10 hr; you will also have to increase the simulation steps per graph point to 16 to avoid instability.  Notice that initially the accumulation of tracer is similar in the two tissues (in proportion to clearance).  As time goes on, and some of the tracer washes out of the tissue, the ratio of tracer concentrations reflects the ratio of receptors.  The higher dissociation constant means there is more wash out, koff = KD*kon, which allows a transient equilibrium to be established.  Tracer with high avidity (low KD) allow imaging of receptors which are in low concentration; however, if the off rate, koff, is to low, equilibrium cannot be reached.

Receptor Plus Non-specific Binding Model

Receptor Plus Non-specific Binding
This model has a single tissue compartment with two receptors called "receptor" and "non-spec".  "Non-spec" refers to non-specific binding.  Notice that the specific-activity in this example is 100 MBq/nmol as compared to 0.1 MBq/nmol in the previous example.  (The molarity units are nM and the output "mass" unit is pmol in this model as opposed to uM and nmol in the previous example.)  This model uses a high specific-activity tracer and the last model used a low specific-activity tracer.

The receptor is present in 1 nM concentration and it has a high affinity, 0.2 nM.  The non-specific binding receptor is present at a higher concentration 10 nM, but it has a lower affinity, 2 nM.  This situation occurs frequently.  The tracer has a high affinity for the receptor of interest, but the receptor is in low concentration.  There is low affinity binding other non-specific moieties, but the concentration of the non-specific binding moieties is higher than the receptor of interest.

Run the simulation and look at the graph.  Although the affinity of the non-specific binding is only a tenth of the receptor affinity, initially there is more non-specific uptake than receptor uptake.  It is not uncommon for the non-specific concentration to be even higher, and the non-specific binding will dominate the receptor binding.  The receptor has a slower koff (= KD*kon), so it looses tracer more slowly as the plasma and tissue concentrations fall.


I.  Dialogs

Model Selection
The first dialog allows the user to pick a model to be used for the simulation.  A checkbox, "Show a diagram of the model", determines if a picture of the model is shown.  This plugin tends to create a lot of windows; a second checkbox determines if the old windows are to be closed automatically.

Compartmental Analysis
Information about the isotope and specific activity is entered into the second dialog.  This information is needed only when both radioactivity and other ''mass" units are used.  Specific activity is discussed in the second appendix, below.

This plugin assumes that a dose is injected into the Compartment I, typically the blood or plasma, at time zero.  The dose and units for the dose are next in this dialog.  The volume of Compartment I (typically blood or plasma) and of Compartment VI (typically the urine) are entered next.  The volume of the urine compartment does not affect the simulation.  It is only used to determine concentration for the urine for output.

The units that will be used in subsequent dialogs is entered next.  Finally, the unit to be used for the output graphs and list of numeric values is selected.  The units used for the other compartments and for the output do not need to be the same as the units used for the dose or volumes of the blood and urine.

Compartment Size
The compartment sizes are entered in the third dialog.  For some models, the unit for the compartments may be selectable.  For other models, the unit is fixed.  If the unit is selectable, the choice of unit determines if the compartment is a volume (physical or volume-of-distribution) or if the compartment is a quantity of receptors.  In the later case the volume of the compartment is equal to the preceding compartment.

Transfer Between Compartments
The transfer constants between compartments is entered in the fourth dialog.  Again depending upon the model, the units may be selectable.  The "Transfer Between Compartments" paragraph in the main part of the manual explains the different types of transfer constants.

Simulation & Output
The fifth dialog defines the simulation parameters and the type of output.  The "Points in graph(s)" determine the number of points in the graphs and the numeric list.  The number of steps in the simulation is the product of the "Points in graph(s)" and "Simulation steps / point".  More "Simulation steps / point" increase accuracy and decreases the likelihood that the simulation will fail, but it increase the run time.  Generally, the run time is not a problem, so this parameter can be increased fairly freely.

The output can be a "mass" or a concentration, where concentration is "mass" per volume in the compartment.  Or, the output can be the rate of change of the "mass" or concentration.

The compartments to be included in the output can be selected using checkboxes.  Generally, the graphs are scaled to the maximum and minimum values.  Alternately, they can be scaled to the maximum and minimum values of one of the compartments.  Separate graphs for each compartment and a combined graph of all the compartments can be selected using checkboxes.

A list of numeric values can be output in a text window.  These values can be imported into a program such as Excel.  Among other capabilities this allows more flexibility in graphical output.

The simulation and output may be repeated.  This feature is useful when experimenting with the output parameters or when more than one type of graph is needed.

II.  Simulation Failure

The range of values for which the simulation varies meaningfully is narrow.  If the rate constants are too low, nothing happens.  If the rate constants are too high, the simulation is unstable.  (Simulation approximating the differential equations with difference equations assumes that the change on a single iteration is small.)  It may be easiest to start from the default values, and only change the values by relatively small factors, e.g. double, half.  If the simulation is unstable, it can sometimes be made to work by increasing the number of simulation steps per graph point, decrease the simulation time, or reduce the offending rate constant.  However, it is not always obvious which rate constant(s) is (are) causing the unstable simulation.

III. Specific Activity

Selecting reasonable factors is complicated by the very wide range of input values, especially for models which use both activity and molarity.  The relation between activity and molarity depends upon a highly variable factor, the specific-activity.  The specific-activity is the amount of radioactivity per mole or gram.  If all the atoms are radioactive, the the table below gives the theoretical maximum specific-activity per mole.  (Please let me know if there are any stupid errors in the table.)  It also shows how many moles correspond to 100 MBq of activity.
100 MBq
181 g/mol
110 m
63 MBq/pmol
1.6 pmol
163 g/mol
6 h
19 MBq/pmol
5.3 pmol
43 g/mol
20.4 m
341 MBq/pmol
0.3 pmol
Often rather than all of the atoms being radioactive only 1 part in a thousand or a million are radioactive.  Then, the specific-activity is given in units of MBq/nmol or MBq/umol, and 100 MBq of activity will correspond to nanomoles or micromoles.

IV. Converting from Activity to Moles or Grams

A frequent task in molecular imaging is converting from activity to moles or to grams.  Doing this conversion it is easy to miss a factor of 106 here or there and come up with a completely nonsensical number.  One of the advantages of Compartments_TP is that these conversions are done automatically. This appendix explains how to do these conversions by hand.

It is usually best to set up a spreadsheet so that you can correct the many errors that easily creep in.  The following will lead you through the steps you need to set up a spreadsheet.  The ImageJ plugin, AtoN_TP, is a tool that does some of these types of conversions for you.

Activity is measured in Becquerel, Bq, which is disintegrations per second.  In the United States, the anachronistic unit, Curie, is still used.  A Curie, Ci, is 3.7 x 1010 disintegrations per second exactly.  (Previously, the Curie was defined in terms of 1 g of radium, but now the Ci is defined precisely in terms of disintegrations per second.)  From the definition it is clear that:

1 Ci = 3.7 x 1010 Bq

An equivalent conversion that is in convenient for clinical Nuclear Medicine is:

1 mCi = 37 MBq

One millicurie equals 37 megabecquerel.  The "m" in mCi is 10-3; the "M" in MBq is 106; and 37 is 3.7 x 101.  The 3, 6, and 1 add up to the 1010 in the definition of the Curie.

Bq is a much more logical unit since it is 1 disintegration per second.  In the following, Bq or MBq (megabecquerel) will be used.

Activity to Number of Radioactive-atoms
Given a certain amount of activity, A0, counting the disintegrations over all time will yield the total number of radioactive-atoms, N0*, corresponding to A0. Mathematically, exponential decay of an isotope is described by:

A(t) = A0*e-lambda*t

Counting up the disintegrations over all time amounts to integrating from 0 to infinity:

N0* = int{A0*e-lambda*t} = A0/lambda = A0*Tmean

where Tmean, the mean life, is equal to T1/2/ln(2).  For example, 1 MBq of 99mTc which has a half-life of 6 h corresponds to 1x106(disintigrations/s)*3600(s/h)*6(h)/0.693 = 3.1 x 1010 disintegration.  Since all of the radioactive atoms disintegrate the total number of disintegrations is equal to the number of radioactive-atoms.

Radioactive-atoms to Molecules
The ratio of the number of radioactive-atoms to the total number of molecules (N0*/N0) can be used to convert to the total number of molecules.

N0 = N0* / (N0*/N0)

For example, it all of the Tc atoms are 99mTc, then (N0*/N0) is equal to 1, and 1 MBq of 99mTc corresponds to 3.1 x 1010 (molecules).  More often this ratio will be one per thousand or million for "carrier-free" radiopharmaceuticals.

Number of Molecules to Moles
Avogadro's number, NA, is equal to approximately 6.0221415 x 1023 (molecules/mol).  Avogadro's number is used to convert from the number of molecules to the number of moles:

(mol) = N0 / NA

For example, 1 MBq of 99mTc corresponds to 3.1 x 1010 (molecules) / {6.0221415 x 1023 (molecules/mol)} = 5.2 x 10-14 mol.

Moles to Grams
The molecular weight is used to convert from moles to grams. 

(g) = (mol) * molecular-weight (g/mol)

Since, the molecular weight of 99mTc is 99 (g/mol), 1 MBq of 99mTc corresponds to 5.2 x 10-14 (mol) * 99 (g/mol) = 5.1 x 10-12 g.  In other words, one megabecquerel of Tc-99m corresponds to 5.1 picograms.

N0* = A0*Tmean
N0 = N0* / (N0*/N0)
(moles) = N0 / NA
(g) = (mol) * molecular-weight (g/mol)

For 1 MBq of 99mTc,
1 MBq * 106 (disintigrations/s/MBq) * 3600 (s/h) * 6 (h) / ln(2) / 6.0221415 x 1023 (atoms/mol) * 99 (g/mol) = 5.1 pg.

Specific Activity
The discussion above assumes that we know the ratio of radioactive-atoms to total molecules, N0*/N0.  Usually, what is known is the specific-activity, the activity per mole or gram, MBq/pmol or MBq/ng.  The specfic-activity combines several factors.

specific-activity (MBq/mol) = NA*(N0*/N0)/Tmean
specific-activity (MBq/g) = (1/molecular-weight)*NA*(N0*/N0)/Tmean

The N0*/N0 ratio is informative because it gives the fraction of the atoms which are radioactive.  The maximum specific-activity will be when this ratio is 1 -- all of the atoms are radioactive.  However, the specific-activity in MBq/pmol or MBq/ng is often more useful because it allows you to skip directly from activity to moles or grams without going through the other steps that make up this conversion.