Esempio n. 1
0
        overlaps.append(np.squeeze(np.argwhere(t)))

overlaps = np.squeeze(np.array(overlaps))
print(overlaps)
print(len(overlaps))

start_pokes_after_delay = np.delete(start_pokes_after_delay, overlaps)
# start_pokes_after_delay = start_pokes_after_delay[2:]

np.save(join(poke_folder, 'time_points_of_non_trial_pokes.npy'),
        start_pokes_after_delay)

time_around_beam_break = 8
avg_firing_rate_around_suc_trials = fr_funcs.get_avg_firing_rates_around_events(
    spike_rates=spike_rates,
    event_time_points=start_pokes_after_delay,
    ev_video_df=event_dataframes['ev_video'],
    time_around_event=time_around_beam_break)

increasing_firing_rates_neuron_index, increasing_firing_rates = \
    fr_funcs.get_neurons_following_pattern_around_an_event(avg_firing_rate_around_event=avg_firing_rate_around_suc_trials,
                                                           time_around_pattern=time_around_beam_break,
                                                           pattern_regions_to_compare=[0, 0.6, 0.8, 1.2],
                                                           comparison_factor=3, comparison_direction='increase',
                                                           baserate=0.1)

fr_funcs.show_firing_rates_around_event(increasing_firing_rates)

# Show where the neurons are in the brain
template_info_increasing_fr_neurons = template_info.iloc[
    increasing_firing_rates_neuron_index]
Esempio n. 2
0
                                                      const_com.CAMERA_TTL_PULSES_TIMEPOINT_PERIOD)
sounds_dur = sounds[:, 1] - sounds[:, 0]
reward_sounds = sounds[sounds_dur < 4000]

# Using the trialend csv file to generate events
# succesful_trials = event_dataframes['ev_trial_end'][event_dataframes['ev_trial_end']['Result'] == 'Food']
# succesful_trials =  succesful_trials['AmpTimePoints'].values

# Using the start of the reward tone to generate events
# There is a difference of 78.6 frames (+-2) between the reward tone and the csv file event (about 700ms)
succesful_trials = reward_sounds[:, 0]

# Get the average firing rates of all neurons a few seconds around the successful pokes
time_around_beam_break = 8
avg_firing_rate_around_suc_trials = fr_funcs.get_avg_firing_rates_around_events(spike_rates=spike_rates,
                                                                                event_time_points=succesful_trials,
                                                                                ev_video_df=event_dataframes['ev_video'],
                                                                                time_around_event=time_around_beam_break)

# Get the average firing rates of all neurons a few seconds around the touch ball
time_around_beam_break = 8
avg_firing_rate_around_touch_ball = fr_funcs.get_avg_firing_rates_around_events(spike_rates=spike_rates,
                                                                                event_time_points=events_touch_ball,
                                                                                ev_video_df=event_dataframes['ev_video'],
                                                                                time_around_event=time_around_beam_break)

events_random = np.random.choice(np.arange(succesful_trials.min(), succesful_trials.max(), 100),
                                 len(succesful_trials), replace=False)
avg_firing_rate_around_random_times = fr_funcs.get_avg_firing_rates_around_events(spike_rates=spike_rates,
                                                                                event_time_points=events_random,
                                                                                ev_video_df=event_dataframes['ev_video'],
                                                                                time_around_event=time_around_beam_break)
plt.plot(distance_to_travel_to_poke)
plt.vlines(x=start_of_ballistic_traj_frames_hand_picked, ymin=0, ymax=4000)

# ------
#   Find any increasing or decreasing neurons
start_of_ballistic_traj_frames_hand_picked = frame_windows_away_from_poke[
    start_of_ballistic_traj_frames_hand_picked]
start_of_ballistic_traj_time_points = ev_video['AmpTimePoints'].iloc[
    start_of_ballistic_traj_frames_hand_picked].values

time_around_start_of_bal_mov = 6
frames_around_start_of_bal_mov = time_around_start_of_bal_mov * 2 * 120

avg_firing_rate_around_start_bal_mov = fr_funcs.get_avg_firing_rates_around_events(
    spike_rates=spike_rates,
    event_time_points=start_of_ballistic_traj_time_points,
    ev_video_df=ev_video,
    time_around_event=time_around_start_of_bal_mov)

decreasing_firing_rates_neuron_index, decreasing_firing_rates = \
    fr_funcs.get_neurons_following_pattern_around_an_event(avg_firing_rate_around_event=avg_firing_rate_around_start_bal_mov,
                                                           time_around_pattern=time_around_start_of_bal_mov,
                                                           pattern_regions_to_compare=[0, 0.9, 1.0, 1.2],
                                                           comparison_factor=3, comparison_direction='decrease',
                                                           baserate=0.1)

fr_funcs.show_firing_rates_around_event(decreasing_firing_rates)

template_info_decreasing_fr_neurons = template_info.iloc[
    decreasing_firing_rates_neuron_index]
spp.view_grouped_templates_positions(
sounds_dur = sounds[:, 1] - sounds[:, 0]
reward_sounds = sounds[sounds_dur < 4000]

# Using the trialend csv file to generate events
# succesful_trials = event_dataframes['ev_trial_end'][event_dataframes['ev_trial_end']['Result'] == 'Food']
# succesful_trials =  succesful_trials['AmpTimePoints'].values

# Using the start of the reward tone to generate events
# There is a difference of 78.6 frames (+-2) between the reward tone and the csv file event (about 700ms)
succesful_trials = reward_sounds[:, 0]

# Get the average firing rates of all neurons a few seconds around the successful pokes
time_around_beam_break = 8
avg_firing_rate_around_suc_trials = fr_funcs.get_avg_firing_rates_around_events(
    spike_rates=spike_rates,
    event_time_points=succesful_trials,
    ev_video_df=event_dataframes['ev_video'],
    time_around_event=time_around_beam_break)

# Get the average firing rates of all neurons a few seconds around random times
time_around_beam_break = 8
random_points = np.random.choice(np.arange(10000, raw_data.shape[1] - 10000,
                                           1000),
                                 50,
                                 replace=False)
avg_firing_rate_around_random = fr_funcs.get_avg_firing_rates_around_events(
    spike_rates=spike_rates,
    event_time_points=random_points,
    ev_video_df=event_dataframes['ev_video'],
    time_around_event=time_around_beam_break)
Esempio n. 5
0
    if date_folder == 8:
        nst = nst[1:]

    trials['ns'] = nst

trials['r'] = np.random.choice(np.arange(200000, raw_data.shape[1] - 200000),
                               len(trials['s']))

# Get the average firing rates of all neurons a few seconds around the trials
time_before_and_after_event = 8

avg_firing_rates = {}
for t in ['s', 'tb', 'r']:
    avg_firing_rates[t] = fr_funcs.get_avg_firing_rates_around_events(
        spike_rates=spike_rates,
        event_time_points=trials[t],
        ev_video_df=event_dataframes['ev_video'],
        time_around_event=time_before_and_after_event)

if date_folder != 6:
    avg_firing_rates['ns'] = fr_funcs.get_avg_firing_rates_around_events(
        spike_rates=spike_rates,
        event_time_points=trials['ns'],
        ev_video_df=event_dataframes['ev_video'],
        time_around_event=time_before_and_after_event)

# </editor-fold>

# -------------------------------------------------
# <editor-fold desc="NEURONS THAT INCREASE THEIR FIRING RATES AROUND THE POKE EVENT">
# Find which neurons increase their firing rate on average around a successful poke