esmraldi.imzmlio

Module for the input/output of imzML files Conversion to numpy array

Module Contents

Functions

open_imzml(filename[, only_metadata])

Opens an imzML file

write_imzml(mzs, intensities, coordinates, filename)

Writes a file to imzML

normalize(image)

Normalizes an image : 0 -- 255 scale

sparse_coordinates(spectra, imsize)

get_full_spectra_sparse(spectra, imsize[, sorted])

get_full_spectra_dense(spectra, coordinates, shape)

get_full_spectra(imzml[, spectra])

get_spectra(imzml[, pixel_numbers])

Extracts spectra from imzML

get_spectra_intensities(imzml[, pixel_numbers])

Extracts spectra intensities from imzML

get_spectra_mzs(imzml[, pixel_numbers])

Extracts spectra mzs from imzML

get_spectra_from_images(images[, full])

Extracts spectra intensities and coordinates

get_images_from_spectra(spectra, shape)

Extracts image as a numpy array from

get_image(imzml, mz[, tol])

Extracts an ion image at a given m/z value

to_image_array(image)

Extracts all existing images from imzML.

to_image_array_3D(image)

Extracts all existing images from 3D imzML

to_nifti(image, filename)

Converts to nifti

to_csv(array, filename)

Converts a file to csv

to_tif(array, mzs, filename)

open_tif(filename)

Attributes

MAX_MAGNITUDE_ORDER

MAX_NUMBER

esmraldi.imzmlio.MAX_MAGNITUDE_ORDER = 6
esmraldi.imzmlio.MAX_NUMBER
esmraldi.imzmlio.open_imzml(filename, only_metadata=False)

Opens an imzML file

Parameters
filename: string

input file

Returns
imzmlparser.ImzMLParser

parser of file

esmraldi.imzmlio.write_imzml(mzs, intensities, coordinates, filename)

Writes a file to imzML

Parameters
mzs: list

list of list of m/z ratios

intensities: list

list of list of intensities

coordinates: list

pixel coordinates associated to each spectrum

filename: string

output file

esmraldi.imzmlio.normalize(image)

Normalizes an image : 0 – 255 scale

Parameters
image: np.ndarray

input image

Returns
np.ndarray

normalized image

esmraldi.imzmlio.sparse_coordinates(spectra, imsize)
esmraldi.imzmlio.get_full_spectra_sparse(spectra, imsize, sorted=False)
esmraldi.imzmlio.get_full_spectra_dense(spectra, coordinates, shape)
esmraldi.imzmlio.get_full_spectra(imzml, spectra=None)
esmraldi.imzmlio.get_spectra(imzml, pixel_numbers=[])

Extracts spectra from imzML into numpy format

Parameters
imzml: imzmlparser.ImzMLParser

parser

Returns
np.array

collection of spectra

esmraldi.imzmlio.get_spectra_intensities(imzml, pixel_numbers=[])

Extracts spectra intensities from imzML into numpy format

Parameters
imzml: imzmlparser.ImzMLParser

parser

Returns
np.array

collection of spectra

esmraldi.imzmlio.get_spectra_mzs(imzml, pixel_numbers=[])

Extracts spectra mzs from imzML into numpy format

Parameters
imzml: imzmlparser.ImzMLParser

parser

Returns
np.array

collection of spectra

esmraldi.imzmlio.get_spectra_from_images(images, full=False)

Extracts spectra intensities and coordinates from numpy array

Parameters
images: np.ndarray

images as numpy array

Returns
list

intensities

list

coordinates

esmraldi.imzmlio.get_images_from_spectra(spectra, shape)

Extracts image as a numpy array from spectra intensities and the shape of the image, i.e the tuple (width, height)

Parameters
spectra: np.ndarray

spectra as numpy array [mz*I]

shape: tuple

shape of the image

Returns
np.ndarray

image

esmraldi.imzmlio.get_image(imzml, mz, tol=0.01)

Extracts an ion image at a given m/z value and with a tolerance

Wrapper function for imzmlparser.getionimage

Parameters
imzml: imzmlparser.ImzMLParser

parser

mz: float

m/z ratio of desired image

tol: float

tolerance on accepted m/z

esmraldi.imzmlio.to_image_array(image)

Extracts all existing images from imzML.

Parameters
image: imzmlparser.ImzMLParser

parser

Returns
np.ndarray

image array

esmraldi.imzmlio.to_image_array_3D(image)

Extracts all existing images from 3D imzML

Parameters
image: imzmlparser.ImzMLParser

parser

Returns
np.ndarray

image array

esmraldi.imzmlio.to_nifti(image, filename)

Converts to nifti

Parameters
image: np.ndarray

image

filename: string

output filename

esmraldi.imzmlio.to_csv(array, filename)

Converts a file to csv containing all m/z ratio

Parameters
array: np.ndarray

mz array

filename: str

output filename

esmraldi.imzmlio.to_tif(array, mzs, filename)
esmraldi.imzmlio.open_tif(filename)