Fluorescence-Tools / tttrlib

File format agnostic low level, high performance API to read and process time-tagged-time resolved (TTTR) data for single-molecule and image spectroscopy (Sample data: https://gitlab.peulen.xyz/skf/tttr-data)
http://tttrlib.rtfd.io/
BSD 3-Clause "New" or "Revised" License
19 stars 0 forks source link

get_phasor_image is not working? #24

Closed Ozcifci closed 7 months ago

Ozcifci commented 3 years ago

Hi tpeulen,

I am trying to create a phasor image but, unfortunately, the example file '../examples/imaging/imaging_phasor.py' is not available in 'auto_examples_python.zip'. Could you please update it?

I have found a former package 'fit2x' which also has been developed by you: https://fit2x.readthedocs.io/en/latest/auto_examples/imaging/plot_imaging_phasor.html#sphx-glr-auto-examples-imaging-plot-imaging-phasor-py

Guessing that you have implemented the get_phasor_image into tttrlib, I have tried the code above and had no success.

phasor = CLSMimage.get_phasor_image(data, frequency=(float(header.loc['TTResult_SyncRate'][0]) * micro_res * 0.000000001), stack_frames = True)

The 4D-array has only zeros, no error message. SyncRate is in Hz, micro_res in ns. Sidenote: get_mean_lifetime_image and get_intensity_image are working without any issue. Data has been aquired with a Leica SP8 - PicoQuant system, files are in PTU format. Thanks in advance for your help.

tpeulen commented 3 years ago

I have only very limited testing data. Can you provide me with a PTU file? Then I can make sure your data is going to work on the next release (ETA 1-2 month).

Ozcifci commented 3 years ago

Here are the PTU file and the short python script I wrote: https://drive.google.com/file/d/1WFfUVMoAuF7sfyKUyhD5y-KtnOhm5iHe/view?usp=sharing Please let me know if you need more data or information about the measurement. Thank you a lot for your help.

tpeulen commented 3 years ago

Thanks, a lot. I will let you know on my progress via this issue.

Ozcifci commented 3 years ago

Since Monday I have used get_fluorescence_decay_image and analyzed the data with fourier transformation and IRF deconvolution with my script. I have realized that my data has per pixel too few photons to perform proper phasor analysis. But I have to work with low concentrations. get_fluorescence_decay_image bins the data in 16384 channels even though the data requires only 3214 channels after the time calibration. After increasing the micro_time_coarsening to 10 or so, I could get reasonable binning of the data. But, the get_phasor_image function does not have micro_time_coarsening, which is probably why the function cannot fourier transform the flat decay curve. I think the problem lies there. It may be good if you can implement micro_time_coarsening to get_phasor_image, too.

However, even binning the photons with lower resolution did not yield a good phasor plot, the data points are still too close to zero lifetime, which is not true. I will now increase the photon count per pixel by decreasing the pixel size of 512x512 to e.g. 50x50. Is there a possibility to do that while creating the tttrlib.CLSMImage Image?

Ozcifci commented 3 years ago

Update: I found the problem and could perform a phasor plot without micro_time_coarsening and the need to reduce the image size.

20p_1st_1_1_1

The problem is that get_fluorescence_decay_image is binning the data in ~20% of the whole bins and filling the rest with zeros. Thus the whole decay curve is squeezed to 20% of the whole macro resolution. I have deleted the unnecessary bins and now everything is working: img_decays = np.delete(img_decays, np.s_[int(642/3276*img_decays.shape[3]):], axis=3)

Anyway it may be good if you could correct it in your next release since my script is quite slow.

Best wishes, Özcifci