Radiotracer quantity inference
PET2BIDS uses the same physical relationships in MATLAB and Python to infer a missing radiotracer quantity from two supplied quantities. Values are converted to canonical units before calculation, then converted to the requested output unit. Supplied values and units are preserved.
Quantities and units
Index |
Internal name |
Output name |
Symbol |
Default unit |
Canonical unit |
|---|---|---|---|---|---|
1 |
|
|
\(A\) |
|
|
2 |
|
|
\(m\) or \(n\) |
|
|
3 |
|
|
\(S\) |
|
|
4 |
|
|
\(R\) |
|
|
5 |
|
|
\(W\) |
|
|
InjectedMassUnits selects one of two relation groups. Mass units such as
ug and mg select the physical-mass relations. Amount units such as
nmol and umol select the amount-of-substance relations. If the unit is
omitted, InjectedMass defaults to ug and therefore selects the
physical-mass relations.
Supported unit strings are:
activity:
Bq,kBq,MBq,GBq,TBq,Ci,mCi, anduCi;physical mass:
kg,g,mg,ug, andng; andamount of substance:
mol,mmol,umol,nmol, andpmol.
Ratio units must combine a supported activity numerator with the appropriate mass or amount denominator. Unsupported or dimensionally incompatible units produce a warning and are not used in a calculation.
Calculation sequence
Normalize micro signs to
uinternally for unit matching, then convert supplied values to canonical units. The supplied spelling is preserved in output metadata.Use
InjectedMassUnitsto select the mass or amount relation group.Evaluate a relation only when both source quantities were supplied. An inferred value is not reused as source evidence for another relation.
Convert the canonical result to the supported requested output unit, or to the default unit when no output unit was supplied.
Preserve supplied measurements. If an independently inferred result does not agree with a supplied value, emit a warning rather than overwriting it.
Physical-mass relations
These relations apply when InjectedMassUnits is a physical-mass unit:
Their units cancel as follows:
For example, the default units MBq and ug give:
The numerical result therefore depends on the output unit: the same physical
quantity is 1e12 Bq/g or 1 MBq/ug.
Amount-of-substance relations
These relations apply when InjectedMassUnits is an amount unit:
Their units cancel as follows:
For example:
Molecular-weight relations
These relations apply independently of the InjectedMass dimension:
The first relation demonstrates the unit cancellation:
TracerMolecularWeight and TracerMolecularWeightUnits are the standard
output field names. The legacy MolecularWeight and MolecularWeightUnits
names remain accepted as input aliases. If both value names are supplied,
TracerMolecularWeight takes precedence. Its matching standard unit, or the
g/mol default when that unit is absent, takes precedence over a conflicting
legacy unit.
MATLAB relation rows
The MATLAB implementation represents each formula as:
[target_index, first_input_index, second_input_index, divide]
divide equal to 1 means target = first / second. A value of 0
means target = first * second. For example, [3 1 2 1] means
\(S = A/m\), while [1 2 3 0] means \(A = mS\).
Mass units: [3 1 2 1] [2 1 3 1] [1 2 3 0]
Amount units: [4 1 2 1] [2 1 4 1] [1 2 4 0]
Always: [3 4 5 1] [5 4 3 1] [4 5 3 0]
The positional definitions are distributed across check_metaradioinputs.m:
namesdefines the five index positions.defaultsdefines the unit at each matching position.outputnamesmaps the internal fifth name,MolecularWeight, to the standard output name,TracerMolecularWeight.kindsanddenominatorsdefine the dimensions for indexes 1 and 3–5. Index 2 is special-cased to try physical mass first, then amount of substance.base_factordefines supported unit labels and their canonical scales.
Changing the order of names therefore requires corresponding changes to
all positional tables, relation rows, and index-specific branches. The Python
implementation uses named relation tuples instead of numeric indexes, but its
quantity names still appear in the defaults, aliases, unit-factor mapping,
dimension helper, and relation tuples; those definitions must remain aligned.
Test coverage
The MATLAB and Python regression tests use the consistent reference values
100 MBq, 2 ug, 5e13 Bq/g, 15 GBq/umol, and 300 g/mol.
Each test supplies two quantities and verifies the third for all six
physical-mass and molecular-weight relations. Separate tests use 2 nmol and
50 GBq/umol to verify all three amount-of-substance relations.
The three-column table in matlab/unit_tests/check_metaradioinputs_test.m is
only [target, first_input, second_input]. It selects the two inputs to pass
to the production helper and the output to assert; it does not perform or encode
the calculation. Python expresses the same cases as named parameter tuples in
pypet2bids/tests/test_radioactivity.py.
Additional tests cover equivalent unit representations, explicit output units, micro-sign spellings, zero denominators, invalid values, inconsistent supplied measurements, legacy molecular-weight aliases, and the JSON-writing paths.