tools.GradientCoefficients#
- class bartorch.tools.GradientCoefficients#
Bases:
Spherical-harmonic coefficients of a gradient coil’s departure from linearity.
alpha[axis, n, m]andbeta[axis, n, m]are the cosine and sine coefficients of ordernand degreemfor the scanner X, Y and Z gradients, shape(3, order + 1, order + 1). The arrays are read-only and excluded fromrepr, so that a table is not written to a log.- Parameters:
basis ({"unnormalized", "normalized"}) –
"unnormalized": GE.datsolid harmonics of the position in centimetres."normalized": Siemens.gradharmonics, normalized as HCPgradunwarpnormalizes them, of the position relative toreference_radius_mm.alpha (array_like) – Cosine and sine coefficients.
beta (array_like) – Cosine and sine coefficients.
reference_radius_mm (float, default=None) – Radius
R0of a normalized expansion, in millimetres.source_name (str, default=None) – Label of the table’s source, such as a file name.
Examples
>>> table = "0.25 m = R0\n 1 A( 1, 0) 1.0 x\n 2 A( 3, 0) -0.025 x\n" >>> coefficients = GradientCoefficients.from_file(table) >>> coefficients.reference_radius_mm, coefficients.max_order (250.0, 3)
- property max_order#
Largest represented spherical-harmonic order.
- property mapping_sign#
Sign of the evaluated field in the map from corrected to acquired positions.
- classmethod from_file()#
Parse a coefficient table.
- Parameters:
source (str, bytes, pathlib.Path, file object or CoefficientAccessor) – A path, the table’s own text or bytes (a string containing a line break, or naming no file, is taken as text), an open file, or an accessor.
coefficient_format ({"auto", "dat", "grad", "coef"}, default='auto') – GE
.dat(SCALE{X,Y,Z}{n}entries), Siemens.grad(A(n, m)andB(n, m)entries andR0), or a neutralAlpha_x n m valuetable."auto"reads.datwhen aSCALEentry is present and.grador.coefotherwise.reference_radius_mm (float, default=None) –
R0for a normalized table that does not state it.
- Return type:
- Raises:
ValueError – If the table has no entries, a
.dattable has a nonzeroDELTA, an unsupportedGRADWARPTYPEor a nonzero tenth order, or a normalized table has no reference radius.