readlif
readlif copied to clipboard
Accessing wavenumbers in multiwavenumber measurements
Hi, i have a .lif file with 10 different measurements, which consists off 33 images (each one referring to one different wavenumber). Now I would like to gather all these data information. I suspect the number of timestamps beeing the relevant parameter after inspecting the header and the github code. Also, I've found the NumberofTimeStamps beeing equal 132, which would fit to 4 channels with 33 wavenumbers.
However - after loading the file - the number of timestamps is equal one for all measurments. Now my question is, if it is even possible to load these multi-wavelength images and if so, how I should do it.
Example code:
from readlif.utilities import get_xml from readlif.reader import LifFile
new = LifFile(file_path) img_0 = new.get_image(0) # first image in the file consting of 10 images
frame_list = [i for i in img_0.get_iter_t(c=0, z=0)]
print(img_0)
LifImage object with dimensions: Dims(x=1024, y=1024, z=1, t=1, m=1) print(get_xml(file_path)[1]) .... /ImageDescription TimeStampList NumberOfTimeStamps="132"> .....
Thank you in advance.
Hello, currently multi-wavelength images aren't supported - although the functionality is almost done! If you need this right now, look at #14 and the development branch. The dev branch is unstable and the functions / variables might be renamed at any time - but I hope to find time soon to clean up the code and write the documentation to get this into the main branch!
The other issue here is getting the wave number from the metadata. Besides parsing the XML yourself, adding some better metadata tools is part of my to-do list and is mentioned in #18.
I was able to implement a get_iter_l (lambda) function, inspired by the functions for t,z and m. However, the problem of getting the corresponding wavenumber stays like you described above. I do not know, if the information of the wavenumber range is available in the .lif-files of the newest software for multi-wavelength measurement systems, but in older files I was not able to find something except the distance between the different wavelenghts.
Hi, I have found the wavenumber information in XML header. Here is the code which is working for my files:
import numpy as np from readlif.reader import LifFile from xml.etree import ElementTree as ETree
files = LifFile(filename + '.lif') mdroot = ETree.fromstring(files.xml_header) for list in mdroot[0][3]: for listLDM in list[2]: if 'Spectra' in listLDM.attrib['Name']: for listIter in listLDM.iter('LambdaDefinition'): DetectionWavelengths = np.arange(int(listIter.attrib['LambdaDetectionBegin']) + int(listIter.attrib['LambdaDetectionStepSize'])/2, int(listIter.attrib['LambdaDetectionEnd']), int(listIter.attrib['LambdaDetectionStepSize']))
My spectrofluorometric images include the name Spectra
so I am finding those images with if 'Spectra' in listLDM.attrib['Name']:
. Change it to your case. Be aware that all the spectrofluorometric images have to include this string.
Thanks @nimne for adding get_plane()
to your project. It works very well for me.