You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that this can be achieved by changing the geionimage to accept multiple mz values like this:
defgetionimage(p, mz_values, tol=0.1, z=1, reduce_func=sum):
""" Get an image representation of the intensity distribution of the ion with specified m/z values. By default, the intensity values within the tolerance region are summed. :param p: the ImzMLParser (or anything else with similar attributes) for the desired dataset :param mz_values: m/z values for which the ion image shall be returned :param tol: Absolute tolerance for the m/z value, such that all ions with values mz_value-|tol| <= x <= mz_value+|tol| are included. Defaults to 0.1 :param z: z Value if spectrogram is 3-dimensional. :param reduce_func: the bahaviour for reducing the intensities between mz_value-|tol| and mz_value+|tol| to a single value. Must be a function that takes a sequence as input and outputs a number. By default, the values are summed. :return: numpy matrix with each element representing the ion intensity in this pixel. Can be easily plotted with matplotlib """tol=abs(tol)
im=np.zeros((p.imzmldict["max count of pixels y"], p.imzmldict["max count of pixels x"]))
fori, (x, y, z_) inenumerate(p.coordinates):
ifz_==0:
UserWarning("z coordinate = 0 present, if you're getting blank images set getionimage(.., .., z=0)")
ifz_==z:
mzs, ints=map(lambdax: np.asarray(x), p.getspectrum(i))
partial_ints= []
formz_valueinmz_values:
min_i, max_i=_bisect_spectrum(mzs, mz_value, tol)
partial_ints.append(ints[min_i:max_i+1])
im[y-1, x-1] =reduce_func(np.concatenate(partial_ints))
returnim
I want to get ion image for multiple mz value (794.5, 834.5, 888.6) and not one mz value.
Using the existing getionimage method i need to do the following:
This works but the issue is that it takes a lot of time because we go over the imzML file 3 times.
Is there a better solution to get ion image for multiple mz values?
The text was updated successfully, but these errors were encountered: