Пример #1
0
class BehaviorOphysAnalysis(LazyPropertyMixin):
    def __init__(self, session, api=None):

        self.session = session
        self.api = self if api is None else api
        # self.active_cell_roi_ids = LazyProperty(self.api.get_active_cell_roi_ids, ophys_experiment_id=self.ophys_experiment_id)

    def plot_example_traces_and_behavior(self, N=10):
        dff_traces_df = self.session.dff_traces
        dff_traces_df['mean'] = dff_traces_df['dff'].apply(np.mean)
        dff_traces_df['std'] = dff_traces_df['dff'].apply(np.std)
        dff_traces_df['snr'] = dff_traces_df['mean'] / dff_traces_df['std']
        active_cell_roi_ids = dff_traces_df.sort_values(
            'snr', ascending=False)['cell_roi_id'].values[:N]

        length_mins = 1
        for xmin_seconds in np.arange(0, 5000, length_mins * 60):
            plot_example_traces_and_behavior(self.session,
                                             active_cell_roi_ids,
                                             xmin_seconds,
                                             length_mins,
                                             cell_label=False,
                                             include_running=True)


if __name__ == "__main__":

    session = BehaviorOphysExperiment(789359614)
    analysis = BehaviorOphysAnalysis(session)
    analysis.plot_example_traces_and_behavior()