Пример #1
0
             join(poke_folder, 'ti_decreasing_neurons_on_non_trial_pokes.df'))

# -------------------------------------------------
# <editor-fold desc="LOOK AT ALL THE NEURONS AROUND THE POKE EVENT">

smooth_time = 0.5
smooth_frames = smooth_time * 120

t = binning.rolling_window_with_step(avg_firing_rate_around_suc_trials,
                                     np.mean, smooth_frames,
                                     int(smooth_frames / 3))
tn = preproc.normalize(t, norm='l1', axis=0)

tn = np.asarray(t)
for i in np.arange(len(t)):
    tn[i, :] = binning.scale(t[i], 0, 1)

y_positions = template_info['position Y'].values
position_sorted_indices = np.argsort(y_positions)

regions_pos = list(const.BRAIN_REGIONS.values())
region_lines = []
for rp in regions_pos:
    region_lines.append(
        sync_funcs.find_nearest(
            y_positions[position_sorted_indices] * const.POSITION_MULT, rp)[0])
region_lines = np.array(region_lines)

tns = tn[position_sorted_indices]

plt.imshow(np.flipud(tns), aspect='auto')
trial_type = 'r'

events = {
    's': 'Successful',
    'ns': 'Not successful',
    'tb': 'Ball Touch',
    'r': 'Random'
}
avg_muae_around_event = np.load(
    join(results_folder, 'Lfp', 'Averages',
         'Muaes_around_{}.npy'.format(trial_type)))

regions_pos = np.array(list(const.BRAIN_REGIONS.values()))
pos_to_elect_factor = const_comm.NUMBER_OF_AP_CHANNELS_IN_BINARY_FILE / 8100
region_lines = binning.scale(regions_pos,
                             np.min(regions_pos) * pos_to_elect_factor,
                             np.max(regions_pos) * pos_to_elect_factor)

muae_smooth = binning.rolling_window_with_step(avg_muae_around_event, np.mean,
                                               40, 40)
muae_smooth = (muae_smooth - muae_smooth.min()) / (muae_smooth.max() -
                                                   muae_smooth.min())
_ = plt.figure(1)
plt.imshow(np.flipud(muae_smooth),
           aspect='auto',
           extent=[-8, 8, len(muae_smooth), 0])
plt.vlines(x=0, ymin=0, ymax=muae_smooth.shape[0] - 1)
plt.hlines(y=muae_smooth.shape[0] - region_lines,
           xmin=-8,
           xmax=8,
           linewidth=3,
# -------------------------------------------------
# <editor-fold desc="LOOK AT ALL THE NEURONS AROUND THE POKE EVENT">

smooth_time = 0.5
smooth_frames = smooth_time * 120

#data = avg_firing_rate_around_random
data = avg_firing_rate_around_suc_trials

t = binning.rolling_window_with_step(data, np.mean, smooth_frames,
                                     int(smooth_frames / 3))
tn = preproc.normalize(t, norm='l1', axis=0)

tn = np.asarray(t)
for i in np.arange(len(t)):
    tn[i, :] = binning.scale(t[i], 0, 1)

y_positions = template_info['position Y'].values
position_sorted_indices = np.argsort(y_positions)

regions_pos = list(const.BRAIN_REGIONS.values())
region_lines = []
for rp in regions_pos:
    region_lines.append(
        sync_funcs.find_nearest(
            y_positions[position_sorted_indices] * const.POSITION_MULT, rp)[0])
region_lines = np.array(region_lines)

tns = tn[position_sorted_indices]

# hack to remove dead neurons
                                 high_pass_cutoff=3000, rectify=True, low_pass_cutoff=400,
                                 avg_reref=True, keep_trials=False)

np.save(join(results_folder, 'Lfp', 'Averages', 'Muaes_around_tp.npy'), avg_muae_around_tp)
np.save(join(results_folder, 'Lfp', 'Averages', 'Muaes_around_ntp.npy'), avg_muae_around_ntp)


#  Normalise

avg_muae_around_tp = np.load(join(results_folder, 'Lfp', 'Averages', 'Muaes_around_tp.npy'))
avg_muae_around_ntp = np.load(join(results_folder, 'Lfp', 'Averages', 'Muaes_around_ntp.npy'))


regions_pos = np.array(list(const.BRAIN_REGIONS.values()))
pos_to_elect_factor = const.NUMBER_OF_AP_CHANNELS_IN_BINARY_FILE / 8100
region_lines = binning.scale(regions_pos, np.min(regions_pos) * pos_to_elect_factor, np.max(regions_pos) * pos_to_elect_factor)

_ = plt.figure(1)
plt.imshow(np.flipud(avg_muae_around_tp), aspect='auto')
plt.vlines(x=avg_muae_around_tp.shape[1] / 2, ymin=0, ymax=avg_muae_around_tp.shape[0] - 1)
plt.hlines(y=avg_muae_around_tp.shape[0] - region_lines, xmin=0, xmax=avg_muae_around_tp.shape[1]-1, linewidth=3, color='w')

tp_n = np.empty((avg_muae_around_ntp.shape))
for i in np.arange(len(avg_muae_around_ntp)):
    tp_n[i, :] = binning.scale(avg_muae_around_ntp[i], 0, 1)

_= plt.figure(2)
plt.imshow(np.flipud(tp_n), aspect='auto')
plt.vlines(x=tp_n.shape[1] / 2, ymin=0, ymax=tp_n.shape[0] - 1)
plt.hlines(y=tp_n.shape[0] - region_lines, xmin=0, xmax=tp_n.shape[1]-1, linewidth=1, color='w')
Пример #5
0
smooth_time = 0.5
smooth_frames = smooth_time * 120

data = avg_firing_rates[trial_type]
events = {
    's': 'Successful',
    'ns': 'Not successful',
    'tb': 'Ball Touch',
    'r': 'Random'
}
frs = binning.rolling_window_with_step(data, np.mean, smooth_frames,
                                       int(smooth_frames / 3))

frs_norm = np.asarray(frs)
for i in np.arange(len(frs)):
    frs_norm[i, :] = binning.scale(frs[i], 0, 1)

y_positions = template_info['position Y'].values
position_sorted_indices = np.argsort(y_positions)

regions_pos = list(const.BRAIN_REGIONS.values())
region_lines = []
for rp in regions_pos:
    region_lines.append(
        sync_funcs.find_nearest(
            y_positions[position_sorted_indices] * const_comm.POSITION_MULT,
            rp)[0])
region_lines = np.array(region_lines)

frs_norm_sorted = frs_norm[position_sorted_indices]
'''