Exemplo n.º 1
0
dff = (region_response.to_numpy() - np.mean(region_response.to_numpy(), axis=1)[:, None]) / np.mean(region_response.to_numpy(), axis=1)[:, None]

# trim and filter
resp = functional_connectivity.filterRegionResponse(dff, cutoff=cutoff, fs=fs)
resp = functional_connectivity.trimRegionResponse(file_id, resp)
region_dff = pd.DataFrame(data=resp, index=name_list_ito)

# fig2_1, ax = plt.subplots(4, 1, figsize=(3.5, 4))
fig2_1, ax = plt.subplots(4, 1, figsize=(8, 4))
ax = ax.ravel()
[x.set_axis_off() for x in ax]
[x.set_ylim([-0.2, 0.29]) for x in ax]
[x.set_xlim([-15, timevec[-1]]) for x in ax]
for p_ind, pr in enumerate(pull_regions):
    ax[p_ind].plot(timevec, region_dff.loc[pr, x_start:(x_start+dt-1)], color=colors[p_ind])
    ax[p_ind].annotate(bridge.displayName(pr), (-10, 0), rotation=90, fontsize=10)

plotting.addScaleBars(ax[0], dT=10, dF=0.10, T_value=-2.5, F_value=-0.10)
fig2_1.subplots_adjust(hspace=0.02, wspace=0.02)


fig2_2, ax = plt.subplots(3, 3, figsize=(2.5, 2.5))
[x.set_xticks([]) for x in ax.ravel()]
[x.set_yticks([]) for x in ax.ravel()]
for ind_1, eg1 in enumerate(pull_regions):
    for ind_2, eg2 in enumerate(pull_regions):
        if ind_1 > ind_2:

            r, p = pearsonr(region_dff.loc[eg1, :], region_dff.loc[eg2, :])

            # normed xcorr plot
Exemplo n.º 2
0
                    c='b',
                    s=5 + 40 * G_anat.degree(weight='weight')[key],
                    edgecolors='k',
                    alpha=0.25)
    ax_fxn.scatter(xi,
                   yi,
                   zi,
                   c='b',
                   s=5 + 20 * G_fxn.degree(weight='weight')[key],
                   edgecolors='k',
                   alpha=0.25)
    if name_list_ito[key] not in roilabels_to_skip:
        ax_anat.text(xi,
                     yi,
                     zi + 2,
                     bridge.displayName(name_list_ito[key]),
                     zdir=(0, 0, 0),
                     fontsize=7,
                     fontweight='bold')
        ax_fxn.text(xi,
                    yi,
                    zi + 2,
                    bridge.displayName(name_list_ito[key]),
                    zdir=(0, 0, 0),
                    fontsize=7,
                    fontweight='bold')

# plot connections
for i, j in enumerate(G_anat.edges()):
    x = np.array((anat_position[j[0]][0], anat_position[j[1]][0]))
    y = np.array((anat_position[j[0]][1], anat_position[j[1]][1]))
Exemplo n.º 3
0
def doAlignmentTest(cell_type, neuprint_search):

    # (1) Get TBar count based on atlas aligntment
    tbar = pd.read_csv(os.path.join(data_dir, 'hemi_2_atlas', '{}_ito_tbar.csv'.format(cell_type)), header=0).iloc[:, 1:]
    tbar.index = np.arange(1, 87)
    include_inds_ito, name_list_ito = bridge.getItoNames()
    tbar = tbar.loc[include_inds_ito, :]
    tbar.index = name_list_ito
    tbar = pd.DataFrame(tbar.sum(axis=1), columns=['sum'])

    fh, ax = plt.subplots(2, 1, figsize=(4, 2))

    vmin = 1
    vmax = np.nanmax(tbar.to_numpy())

    sns.heatmap(np.log10(tbar.T).replace(-np.inf, 0), ax=ax[1], cmap='cividis', cbar=False, xticklabels=[bridge.displayName(x) for x in tbar.index], yticklabels=False, vmin=0, vmax=np.log10(vmax))

    # ax[1].set_title('Atlas\nregistration')
    ax[1].tick_params(axis='both', which='major', labelsize=8)

    # (2) Get TBar count according to Neuprint & Janelia region tags
    Neur, _ = fetch_neurons(NeuronCriteria(type=neuprint_search, status='Traced', regex=True))

    neuprint_rois = [bridge.ito_to_neuprint(x) for x in name_list_ito]

    tbar_count = np.zeros((Neur.shape[0], len(neuprint_rois)))
    for roi_ind, nr in enumerate(neuprint_rois):
        for n_ind, roiInfo in enumerate(Neur.roiInfo):
            if len(nr) > 1:
                new_tbars = np.sum([roiInfo.get(x, {'pre': 0}).get('pre', 0) for x in nr])
            else:
                new_tbars = roiInfo.get(nr[0], {'pre': 0}).get('pre', 0)

            tbar_count[n_ind, roi_ind] = new_tbars

    tbar_neuprint = pd.DataFrame(tbar_count.sum(axis=0).T, index=name_list_ito, columns=['ct'])

    sns.heatmap(np.log10(tbar_neuprint.T).replace(-np.inf, 0), ax=ax[0], cmap='cividis', cbar=False, xticklabels=False, yticklabels=False, vmin=0, vmax=np.log10(vmax))
    # ax[0].set_title('Neuprint')
    ax[0].tick_params(axis='both', which='major', labelsize=8)
    cb = fh.colorbar(matplotlib.cm.ScalarMappable(norm=matplotlib.colors.SymLogNorm(vmin=vmin, vmax=vmax, base=10, linthresh=0.1, linscale=1), cmap="cividis"), ax=ax, shrink=1.0, label='T-Bars')

    r, p = pearsonr(tbar.to_numpy().ravel(), tbar_neuprint.to_numpy().ravel())
    print('r = {}'.format(r))

    print(tbar.sum().sum())
    print(tbar_neuprint.sum().sum())

    return fh
Exemplo n.º 4
0
ax.plot([-3.5, 3.5], [-3.5, 3.5], 'k-')
ax.axhline(color='k', zorder=0, alpha=0.5)
ax.axvline(color='k', zorder=0, alpha=0.5)
ax.set_xticks([-2, 2])
ax.set_yticks([-2, 2])
ax.set_xticklabels(['-2$\sigma$', '+2$\sigma$'])
ax.set_yticklabels(['-2$\sigma$', '+2$\sigma$'])
ax.set_xlabel('SC', fontsize=10)
ax.set_ylabel('FC', fontsize=10)
ax.tick_params(axis='both', which='major', labelsize=8)
ax.set_aspect(1)

fig4_2, ax = plt.subplots(1, 1, figsize=(4, 4))
sns.heatmap(sorted_diff,
            ax=ax,
            yticklabels=[bridge.displayName(x) for x in sorted_diff.columns],
            xticklabels=[bridge.displayName(x) for x in sorted_diff.index],
            cbar_kws={
                'label': 'Difference (FC - SC)',
                'shrink': .65
            },
            cmap="RdBu_r",
            rasterized=True,
            vmin=-lim,
            vmax=lim)
ax.set_aspect('equal')
ax.tick_params(axis='both', which='major', labelsize=6)

fig4_0.savefig(os.path.join(analysis_dir, 'figpanels', 'fig4_0.svg'),
               format='svg',
               transparent=True,
Exemplo n.º 5
0
    for it in range(iterations):
        new_samples = np.sort(lognorm_model.rvs(size=len(ct)))[::-1]
        samples.append(new_samples)
    samples = np.vstack(samples)
    # Note order of operations matters here, get mean and std before going back out of log
    mod_mean = 10**np.mean(samples, axis=0)
    err_down = 10**(np.mean(samples, axis=0) - 2*np.std(samples, axis=0))
    err_up = 10**(np.mean(samples, axis=0) + 2*np.std(samples, axis=0))
    axS1[p_ind].set_axis_on()

    axS1[p_ind].fill_between(list(range(len(mod_mean))), err_up, err_down, color='k', alpha=0.4, rasterized=False)
    axS1[p_ind].plot(mod_mean, 'k--', rasterized=False)
    axS1[p_ind].plot(ct, marker='.', linestyle='none', rasterized=False)

    axS1[p_ind].set_xticks([])
    axS1[p_ind].annotate('{}'.format(bridge.displayName(pr)), (12, 6e3), fontsize=8)
    axS1[p_ind].set_yscale('log')
    axS1[p_ind].set_ylim([0.5, 5e4])
    axS1[p_ind].set_yticks([1e0, 1e2, 1e4])

    if pr == pull_region:
        ax[0].fill_between(list(range(len(mod_mean))), err_up, err_down, color='k', alpha=0.4)
        ax[0].plot(mod_mean, 'k--')
        ax[0].plot(ct, marker='o', linestyle='none')

        ax[0].set_xticks(list(range(len(ct))))
        ax[0].tick_params(axis='both', which='major', labelsize=10)
        ax[0].set_xticklabels([bridge.displayName(x) for x in ct.index])
        ax[0].set_yscale('log')
        ax[0].set_ylim([1, 8e3])
        for tick in ax[0].get_xticklabels():