komodovaran / DeepFRET-GUI

Repository for DeepFRET GUI.
GNU General Public License v3.0
2 stars 1 forks source link

Integrate new HMM features in a visual, windowed overview #12

Open komodovaran opened 4 years ago

komodovaran commented 4 years ago

I was in a hurry, so I cannibalized the transition density plot feature for a global HMM fit, which should be the new key feature.

This needs better integration overall, and I'm thinking a plot of the transition matrix using networkx in a separate TransitionMatrixWindow?

eembees commented 4 years ago

I thought of this during #18 , should we have it all in TransitionDensityPlot but have plots look different based on whether the hmm fit is global? And then make it look like this? 91537731_2564821143738207_8718000956169519104_n

komodovaran commented 4 years ago

Dropping this here. Would be nice to have something like this too.

Screenshot 2020-04-06 at 12 23 59
eembees commented 4 years ago

Right now we predict to the TraceContainer something like this (in the PG branch)

            _X = trace.fret[
                : trace.first_bleach
            ]  # TODO This needs to change to choose DA vs E
            tf = pd.DataFrame()
            tf["e_obs"] = trace.fret[: trace.first_bleach]
            tf["state"] = np.array(self.hmmModel.predict(_X)).astype(int)
            tf["e_pred_global"] = (
                tf["state"]
                .astype(str)
                .replace(
                    {k: v[0] for (k, v) in zip(state_dict.keys(), state_dict.values())},
                    inplace=False,
                )
            )
            tf["e_pred_local"] = tf.groupby(["state"], as_index=False)[
                "e_obs"
            ].transform("mean")

            tf["time"] = tf["e_pred_local"].index + 1

            trace.hmm_state = tf["state"].values
            trace.hmm_local_fret = tf["e_pred_local"].values
            trace.hmm_global_fret = tf["e_pred_global"].values
            trace.hmm_idx = tf["time"].values

            trace.calculate_transitions()
eembees commented 4 years ago

Should we start work on this to include proper TDPs with individualized idealizations as well? I know it goes against the logic of the HMM, but seeing as that is the going standard of the community, I think it might be a discussion worth having, if there is demand...