tttrlib icon indicating copy to clipboard operation
tttrlib copied to clipboard

tttr.intensity_trace() crashes kernel

Open NicolaasvanderVoort opened this issue 3 years ago • 2 comments

Dear Thomas,

ffile = r'path\to\some\file.ptu trace = tttrlib.TTTR(ffile) trace.intensity_trace() causes a kernel crash (python 3.7).

Giving an argument to intensity_trace resolves this issue. trace.intensity_trace(1) According to the docs, the time_window_length argument is a keyword argument, so I was not expecting this issue.

It is mostly a problem because you can crash the kernel when you don't expect it. I can send you the .ptu file that goes with this.

NicolaasvanderVoort avatar Feb 01 '22 12:02 NicolaasvanderVoort

Addendum:

I learned that for any non-legal function input the kernel crashed. E.g. when I try to write a .ptu file to disk but not giving the correct inputs. It would be great if an error gets thrown rather than the kernel crashing.

NicolaasvanderVoort avatar Feb 01 '22 14:02 NicolaasvanderVoort

I'm having a similar issue where creating a TTTR object with a photon-hdf5 file as argument crashes the kernel. ~I didnt expect this to work, but~ as @NicolaasvanderVoort points out it would be nice if there would be an error.

For picoquant tttr files, I know you can check like this, not sure for other formats:

def is_pqtttr(fpath: PathLike) -> bool:
    with open(fpath, "rb") as f:
        magic = f.read(8).rstrip(b"\0")
    return magic == b"PQTTTR"

Jhsmit avatar Jul 31 '24 16:07 Jhsmit

I improved the checks for the supported data types. Not all file formats have "magic" identifiers. Hence, I try to infer the types by:

i) the file extension ii) the header information

(see: https://github.com/Fluorescence-Tools/tttrlib/pull/43)

tpeulen avatar Sep 17 '24 14:09 tpeulen