Spatial
RangedGrid
- class apav.analysis.spatial.RangedGrid(roi, ranges, bin_width=1, first_pass=True, delocalization=array([3.0, 3.0, 1.5]), gauss_trunc=4)[source]
Compute the ionic and elemental composition spatially distributed among a structured grid
- Parameters:
roi (
Roi
) – Parent the RangedGrid is competed onranges (
RangeCollection
) – RangeCollection defining the rangesbin_width (
Number
) – symmetric bin width sizefirst_pass (
bool
) – Whether the first pass delocalization is computed using a gaussian transfer function.delocalization (
Union
[Number
,Sequence
[Number
]]) – The delocalization distances (as 3 standard deviations of a normal distribution)gauss_trunc (
Number
) – Number of standard deviations to truncate the gaussian kernel for second pass delocalization
- property all_elemental_frac: Dict[Element, ndarray]
Get all elemental fraction grids as a dict
- property all_elemental_frac_str: Dict[str, ndarray]
Get all elemental fraction grids as a dictionary (using elemental symbols)
- property all_ionic_counts: Dict[Ion, ndarray]
Get all ionic count grids in a dict
- property bin_width: float
Bin width of the voxels
- property centers: Tuple[ndarray, ndarray, ndarray]
The center positions of the structured grids
For MxNxP voxels this returns 3 arrays of dimensions: Mx1x1, 1xNx1, 1x1xP
- property delocalization: ndarray
Amount of smoothing used during the delocalization process
- property elemental_counts_grid: ndarray
Get an array of the cumulative elemental counts in each bin
- property elemental_counts_total: Number
Get the total (sum) of all elemental counts
- elemental_frac(element)[source]
Get a single elemental fraction grid :type element:
Union
[str
,Element
] :param element: the elemental of the grid to return (Element or str)- Return type:
ndarray
- property extents: Tuple[Tuple[float, float], Tuple[float, float], Tuple[float, float]]
Get the spatial extents (by center positions) of the grids
- property first_pass: bool
Whether to compute first pass delocalization
- property gauss_trunc: Number
Where to truncate the gaussian kernel for second pass delocalization
- ionic_counts(ion)[source]
Get a single ionic counts grid :type ion:
Ion
:param ion: The ion of the grid to return- Return type:
ndarray
- property ranges: RangeCollection
The ranges used for ranging the mass spectrum
DensityHistogram
- class apav.analysis.spatial.DensityHistogram(roi, bin_width=0.3, axis='z', multiplicity='all')[source]
Compute density histograms on an Roi
- Parameters:
roi (
Roi
) – region of interestbin_width – width of the bin size in Daltons
axis – which axis the histogram should be computed on (“x”, “y”, or “z”)
multiplicity – the multiplicity order to compute histogram with
make_coordinate_grids
- apav.analysis.spatial.make_coordinate_grids(extents, bin_width, edges=False)[source]
Generate 3D x/y/z coordinate arrays for indexing into compositional grids
- Parameters:
extents (
Sequence
[Tuple
[Number
,Number
]]) – The x/y/z extent to generate the grids forbin_width (
Union
[Sequence
[Number
],Number
]) – The bin width of each bin, a single number or sequence of numbers for each dimensionedges – Whether the coordinates represent the edges of the bins or centers
- Return type:
Tuple
[ndarray
,ndarray
,ndarray
]
ion_transfer
- apav.analysis.spatial.ion_transfer(X, Y, Z, pos, stddev3)[source]
Transfer an array of ion positions to a binned grid.
- Parameters:
X (
ndarray
) – 3D array of x-coordinates of gridY (
ndarray
) – 3D array of y-coordinates of gridY – 3D array of z-coordinates of grid
pos (
ndarray
) – 2D array of positionsstddev3 (
Number
) – 3sigma standard deviation of gaussian distribution
- Return type:
ndarray
- Returns:
3D array of counts