tritemio / FRETBursts

Burst analysis software for smFRET. **Moved to OpenSMFS organization**
https://github.com/OpenSMFS/FRETBursts
GNU General Public License v2.0
16 stars 17 forks source link

Outdated FRET/S histograms with multiple burst searches #50

Closed tritemio closed 7 years ago

tritemio commented 7 years ago

Summary

A bug in Data may result in FRET or S histograms plots not to change after performing a second burst search on the same object (but no burst selection).

Many thanks to Danielis Rutkauskas for reporting this bug and providing an example notebook to reproduce it.

Steps to reproduce

In FRETBursts (up to version 0.5.9 included) the following steps reproduce the bug:

d.burst_search(F=6)
dplot(d, hist_fret)

[FRET histogram plot]

d.burst_search(F=12)  # change some parameter
dplot(d, hist_fret)

[FRET histogram plot does not change]

Notes:

Workaround

The easiest workaround is to reload the data each time you want to compare FRET or S histograms from different burst searches with no burst selection.

A second workaround that does not require reloading the data is replacing the FRET hist command:

dplot(d, hist_fret)

with:

if hasattr(d, 'E_fitter'): delattr(d, 'E_fitter')
dplot(d, hist_fret)

similarly the S hist command should be:

if hasattr(d, 'S_fitter'): delattr(d, 'S_fitter')
dplot(d, hist_S)

This bug will be fixed in FRETBursts version 0.6 and above.

Internal details

The bug is due to the incorrect handling of E_fitter and S_fitter attributes in Data. The Data object inherits from dict and all its attributes are also dictionary entries. The only exception are the E_fitter and S_fitter attributes that are not part of the dictionary and therefore are not copied when performing burst selection or Data.copy(). The fitter objects compute the FRET and S histograms (as well as computing the fitting and KDE).

When calling hist_fret or hist_S, new E_fitter or S_fitter attributes are created if not present. When the fitter attribute is already present (as in subsequent plots on the same objects) and other histograms parameters are not changes then the old object is used.

When performing a new burst search, the old E_fitter and S_fitter attributes should be deleted but they are not. This results in subsequent calls of the same plot to use the old histogram data.

tritemio commented 7 years ago

Closed by PR #51.