Beispiel #1
0
f_20 = np.array(
    binning.rolling_window_with_step(
        spike_rates_0p25[speed_very_corr_neurons_index, :].T * 2, np.mean, 8,
        1))
plt.plot((f_20 - f_20.mean()) / f_20.std())

# Shuffle the spike rates of one of the best correlated neurons and calculate MI between the shuffled frs and speed
# (1000 times) to generate the basic chance base of MI

speed_corr_neurons_index = [204]
shuffled, mean, conf_intervals = MI.shuffle_test(
    MI.mi_LNC,
    spike_rates_0p25[speed_corr_neurons_index[0], ],
    speeds_0p25,
    z=False,
    ns=1000,
    ci=0.95,
    k=10,
    base=np.exp(1),
    alpha=0.4,
    intens=1e-10)
np.save(
    join(mutual_information_folder,
         'shuffled_mut_info_spike_rate_1140_vs_speed.npy'), shuffled)

# Have a look at the MIs vs the chance level
shuffled = np.load(
    join(mutual_information_folder,
         'shuffled_mut_info_spike_rate_1140_vs_speed.npy'))
mean_sh = np.mean(shuffled)
confidence_level = 0.99
Beispiel #2
0
mutual_infos_spikes_vs_position = np.array(mutual_infos_spikes_vs_position)
np.save(join(mutual_information_folder, 'mutual_infos_spikes_vs_position.npy'),
        mutual_infos_spikes_vs_position)

mutual_infos_spikes_vs_position = np.load(
    join(mutual_information_folder, 'mutual_infos_spikes_vs_position.npy'))

position_corr_neuron_index = 522
number_of_shuffles = 1000
shuffled, mean, conf_intervals = MI.shuffle_test(
    MI.mi_LNC,
    spike_rates_0p25[
        position_corr_neuron_index, :const.BRAIN_DATA_UP_TO_QUARTER_SECOND],
    pca_body_position[:const.BRAIN_DATA_UP_TO_QUARTER_SECOND],
    z=False,
    ns=number_of_shuffles,
    ci=0.95,
    k=10,
    base=np.exp(1),
    alpha=0.4,
    intens=1e-8)
np.save(
    join(mutual_information_folder,
         'shuffled_mut_info_spike_rate_522_vs_position.npy'), shuffled)

shuffled = np.load(
    join(mutual_information_folder,
         'shuffled_mut_info_spike_rate_522_vs_position.npy'))
mean_sh = np.mean(shuffled)
confidence_level = 0.95
confi_intervals = shuffled[int((1. - confidence_level) / 2 * number_of_shuffles)], \
Beispiel #3
0
n = 0
mi_pb_spikes_vs_speed = []
for rate in spike_rates_patterned_behaviour_0p25:
    mi_pb_spikes_vs_speed.append(MI.mi_LNC([rate.tolist(), speeds_patterned_behaviour_0p25],
                                           k=10, base=np.exp(1), alpha=0.4, intens=1e-10))
    n += 1
    print('Done neuron {}'.format(str(n)))

mi_pb_spikes_vs_speed = np.array(mi_pb_spikes_vs_speed)
np.save(join(mutual_information_folder, 'mutual_infos_spikes_vs_speed_patterned_behaviour.npy'), mi_pb_spikes_vs_speed)

#   Do the shuffle of the best patterned behaviour vs speed
max_neuron = np.argmax(mi_pb_spikes_vs_speed)

shuffled, mean, conf_intervals = MI.shuffle_test(MI.mi_LNC,  spike_rates_patterned_behaviour_0p25[max_neuron],
                                                 speeds_patterned_behaviour_0p25,
                                                 z=False, ns=1000, ci=0.95, k=10, base=np.exp(1), alpha=0.4,
                                                 intens=1e-10)
np.save(join(mutual_information_folder, 'shuffled_mut_info_spike_rate_589_vs_speed_patterned_behaviour.npy'), shuffled)

#   Do the patterned behaviour vs distance to poke
n = 0
mi_pb_spikes_vs_distance_to_poke = []
for rate in spike_rates_patterned_behaviour_0p25:
    mi_pb_spikes_vs_distance_to_poke.append(MI.mi_LNC([rate.tolist(), distance_to_poke_patterned_behaviour_0p25],
                                           k=10, base=np.exp(1), alpha=0.4, intens=1e-10))
    n += 1
    print('Done neuron {}'.format(str(n)))

mi_pb_spikes_vs_distance_to_poke = np.array(mi_pb_spikes_vs_distance_to_poke)
np.save(join(mutual_information_folder, 'mutual_infos_spikes_vs_distance_to_poke_patterned_behaviour.npy'),
        mi_pb_spikes_vs_distance_to_poke)
for rate in spike_rates_away_from_poke_smoothed:
    mi_spike_rates_vs_distance_traveled_from_poke.append(MI.mi_LNC([rate.tolist(), distance_traveled_from_poke_smoothed],
                                                                  k=10, base=np.exp(1), alpha=0.4, intens=1e-10))
    n += 1
    print('Done neuron {}'.format(str(n)))

mi_spike_rates_vs_distance_traveled_from_poke = np.array(mi_spike_rates_vs_distance_traveled_from_poke)
np.save(join(mutual_information_folder, 'mutual_infos_spikes_vs_distance_traveled_from_poke.npy'),
        mi_spike_rates_vs_distance_traveled_from_poke)


#   Do the shuffle of the best fr vs distance to travel to next poke
max_neuron = np.argmax(mi_spike_rates_vs_distance_traveled_from_poke)

shuffled, mean, conf_intervals = MI.shuffle_test(MI.mi_LNC,  spike_rates_away_from_poke_smoothed[max_neuron],
                                                 distance_traveled_from_poke_smoothed,
                                                 z=False, ns=1000, ci=0.95, k=10, base=np.exp(1), alpha=0.4,
                                                 intens=1e-10)
np.save(join(mutual_information_folder,
             'shuffled_mut_info_spike_rate_{}_vs_distance_traveled_from_poke.npy'.format(str(max_neuron))),
        shuffled)

# </editor-fold>
# -------------------------------------------------

# -------------------------------------------------
# <editor-fold desc="VISUALISE RESULTS OF THE MI CALCULATIONS">

#   Load the MIs and the shuffle
distance_traveled_from_poke_smoothed = np.array(distance_traveled_from_poke_smoothed)

mi_spike_rates_vs_distance_traveled_from_poke = \