m2aia.utils package

Submodules

m2aia.utils.binning module

m2aia.utils.binning.bin_peaks(image: ImzMLReader, mask: array | None = None)[source]
m2aia.utils.binning.group_binning(xs, ys, ss, grouper, tolerance=0.002)[source]

xs: sorted list of m/z values of peaks ys: sorted list of intensities according to xs sorting ss: sorted list of source indices according to xs sorting grouper: binning method tolerance: TODO

Returns

bin_assignments:

assigns each entry in sorted list to the corresponding bin, so that xs[bin_assignments==k] returns all xs values corresponding to the k’th bin

bin_xs:

new xs center values of the bins

counts:

the count of pixels associated with each peak

m2aia.utils.binning.grouper_strict(xs, ys, sources, tolerance)[source]

m2aia.utils.peaks module

m2aia.utils.peaks.noise_mad(xs, ys)[source]
m2aia.utils.peaks.pick_peaks(I: ~m2aia.ImageIO.ImzMLReader, SNR: float = 8, sort_by_xs: bool = True, noise_estimator=<function noise_mad>)[source]

Pick peaks for a given ImzMLReader object.

This function is iterating over all spectra in an image and picks peaks. sort_by_xs: if True all values of the return arrays are sorted according to ascending peaks_xs values.

returns: peak_xs: list of m/z positions

e.g.: peak_xs=[x1 x1 x1 x2 x2 x2 x2 x3 x3 x3 x3 x3 x3]

3 peaks found in spectrum with id 1 4 peaks found in spectrum with id 2 6 peaks found in spectrum with id 3

peak_ys: list of intensities corresponding to peak_xs

e.g.: peak_ys=[y1 y1 y1 y2 y2 y2 y2 y3 y3 y3 y3 y3 y3]

peak_idx = list of array indices corresponding to a spectrum array

e.g.: peak_idx=[idx1 idx1 idx1 idx2 idx2 idx2 idx2 idx3 idx3 idx3 idx3 idx3 idx3]

peaks_source = indicators for each corresponding peak_xs, from which spectrum id it was picked

e.g.: peaks_source=[1 1 1 2 2 2 2 3 3 3 3 3 3]

m2aia.utils.volcano module

m2aia.utils.volcano.volcano_data(image: ImzMLReader, mask: array, x)[source]
m2aia.utils.volcano.volcano_plot_data(image: ImzMLReader, mask: array, xs, pThreshold=0.05, fcThreshold=1)[source]

Module contents