コード例 #1
0
 def analyze_responses(self):
     self.sorted_responses = sort_responses(self.pulse_responses)
     got_fitable_responses = False
     for mode in modes:
         for holding in holdings:
             got_fitable_responses = got_fitable_responses or len(self.sorted_responses[mode, holding]['qc_pass']) > 0
     if not got_fitable_responses:
         print('No fitable responses, bailing out')
     
     self.vc_plot.plot_responses({holding: self.sorted_responses['vc', holding] for holding in holdings})
     self.ic_plot.plot_responses({holding: self.sorted_responses['ic', holding] for holding in holdings})
コード例 #2
0
ファイル: notebook.py プロジェクト: shixnya/aisynphys
def plot_metric_pairs(pair_list, metric, db, ax, align='pulse', norm_amp=None, perc=False, labels=None, max_ind_freq=50):
    pairs = [get_pair(eid, pre, post, db) for eid, pre, post in pair_list]
    _, metric_name, units, scale, _, cmap, cmap_log, clim, _ = get_metric_data(metric, db)
    cmap = matplotlib.cm.get_cmap(cmap)
    if cmap_log:
        norm = matplotlib.colors.LogNorm(vmin=clim[0], vmax=clim[1], clip=False)
    else:
        norm = matplotlib.colors.Normalize(vmin=clim[0], vmax=clim[1], clip=False)
    colors = [map_color_by_metric(pair, metric, cmap, norm, scale) for pair in pairs]
    for i, pair in enumerate(pairs):
        s = db.session()
        q= response_query(s, pair, max_ind_freq=max_ind_freq)
        prs = [q.PulseResponse for q in q.all()]
        sort_prs = sort_responses(prs)
        prs = sort_prs[('ic', -55)]['qc_pass']
        if pair.synapse.synapse_type=='ex':
            prs = prs + sort_prs[('ic', -70)]['qc_pass']
        if perc:
            prs_amp = [abs(pr.pulse_response_fit.fit_amp) for pr in prs if pr.pulse_response_fit is not None]
            amp_85, amp_95 = np.percentile(prs_amp, [85, 95])
            mask = (prs_amp >= amp_85) & (prs_amp <= amp_95)
            prs = np.asarray(prs)[mask]
        prl = PulseResponseList(prs)
        post_ts = prl.post_tseries(align='spike', bsub=True, bsub_win=0.1e-3)
        trace = post_ts.mean()*scale
        if norm_amp=='exc':
            
            trace = post_ts.mean()/pair.synapse.psp_amplitude
        if norm_amp=='inh':
            trace = post_ts.mean()/pair.synapse.psp_amplitude*-1
        latency = pair.synapse.latency
        if align=='pulse':
            trace.t0 = trace.t0 - latency
        label = labels[i] if labels is not None else None
        ax.plot(trace.time_values*scale, trace.data, color=colors[i], linewidth=2, label=label)
    ax.set_xlim(-2, 10)
    ax.spines['right'].set_visible(False)
    ax.spines['top'].set_visible(False)
    if labels is not None:
        ax.legend(loc='upper left', bbox_to_anchor=(1, 1))