The hotspot removal function is to identiy pixels in the >0.99 quantile (1% high abundance pixels) and replacing them by the 0.99 value.
Automatic hotspot removal can be applied using a low quantile threshold of 0% and a high quantile threshold of 99%.
The hotspost removal function automatically adjusts the color scale to better visualize changes in abundance for the bottom 99% of pixels.
For example,
from pyimzml.ImzMLParser import ImzMLParser
import matplotlib.pyplot as plt
import numpy as np
# Parse the data into slide
MALDI = ImzMLParser('MALDI.imzML')
# Obtain spectrum coordinates for MALDI
for i, (x,y,z) in enumerate(MALDI.coordinates):
MALDI.getspectrum(i)
# Get the ion image of the slide, import geitionimage class from the parser.
# Choose the 191.0197 +- 0.001 signal
from pyimzml.ImzMLParser import getionimage
peakMZ1 = 191.0197
tolMZ1 = 0.001
from scipy import ndimage
MALDI_image_raw = getionimage(MALDI, peakMZ1, tol=tolMZ1)
plt.imshow(MALDI_image_raw)
# We will calculate the 0.99 quantile range and assign the data points above this value to the 0.99 value.
Quantile_99 = np.quantile(MALDI_image_raw, 0.99)
print('Quantile 0.99 is:', Quantile_99)
MALDI_image_hot = MALDI_image_raw.copy()
MALDI_image_hot[MALDI_image_hot > Quantile_99] = Quantile_99
print('Data points above 99% =', np.count_nonzero([MALDI_image_raw > Quantile_99]))
print('Data points below 99% =', np.count_nonzero([MALDI_image_raw < Quantile_99]))
plt.imshow(MALDI_image_raw)
plt.imshow(MALDI_image_hot)
The hotspot removal function is to identiy pixels in the >0.99 quantile (1% high abundance pixels) and replacing them by the 0.99 value.
Automatic hotspot removal can be applied using a low quantile threshold of 0% and a high quantile threshold of 99%.
The hotspost removal function automatically adjusts the color scale to better visualize changes in abundance for the bottom 99% of pixels.
For example,