Пример #1
0
def load_align_data(args, options, config):
    # Load raw data and calculate behaviours
    behaviour_data = behaviour.get_behaviour(
        args.dlc_files,
        config.meters_per_pixel,
        config.camera_frames_per_sec,
        options,
    )
    num_behaviour_measurements = len(behaviour_data.index)

    # Load spiking data
    spike_data = spikes.get_spikes(
        args.spike_time_file,
        args.spike_clusters_file,
        args.cluster_groups_file,
        args.sync_param_file,
        num_behaviour_measurements,
        config.camera_frames_per_sec,
        config.probe_samples_per_sec,
    )

    # Align spiking data and behavioural data to a single dataframe
    total_df = combine.make_combined_df(spike_data, behaviour_data)

    # Remove any frames based on global conditions
    total_df = clean.clean_df(total_df, speed_cutoff=options.speed_cut_off)
    # Align data with externally supplied conditions
    total_df = condition_select.add_conditions(total_df, config)
    return total_df
Пример #2
0
    def __init__(self, cell_specific_data, df, place, cell_name, options,
                 config):
        df = clean_df(df, speed_cutoff=options.place_speed_cut_off, copy=True)
        idx = get_idx(cell_specific_data, cell_name)
        self._smoothing = options.place_firing_smooth_width
        self._min_time_in_spatial_bin = options.min_time_in_spatial_bin
        self.place_peak_magnitude = []
        self.peak_percentile = []

        self.place_firing = cell_specific_data.place_cell_spikes_freq[idx]

        self.get_peak_firing_magnitude()

        if options.place_shuffle_test:
            self.get_place_cell_sig(
                df,
                place,
                cell_name,
                options,
                config,
                min_shuffle_dist_time=options.place_shuffle_min_magnitude,
                max_shuffle_dist_time=options.place_shuffle_max_magnitude,
                num_iterations=options.place_shuffle_iterations,
                camera_frames_per_sec=config.camera_frames_per_sec,
                num_processes=options.num_processes,
                parallel=options.parallel,
            )
Пример #3
0
 def calc_hd(self, df, hd, options):
     df = clean_df(df, speed_cutoff=options.hd_speed_cut_off, copy=True)
     self.get_firing_directions(df)
     self.get_direction_firing_rates_bins(
         hd, smooth_width=options.hd_smooth_sigma
     )
     self.direction_firing_kde(kappa=options.hd_kde_kappa)
     self.kde_normalise(hd.time_spent_each_head_angle_kde)
Пример #4
0
    def __init__(self, cell_specific_data, df, hd_behaviour, cell_name,
                 options, config):
        df = clean_df(df, speed_cutoff=options.hd_speed_cut_off, copy=True)
        self.mean_vec_percentile = []
        self.hd_stability_percentile = []
        self.rayleigh_test_p = []
        self.rayleigh_test_z = []
        self.omnibus_test_p = []
        self.omnibus_test_m = []
        self.mean_vec_length = []
        self.mean_direction = []
        self.hd_background_hz = []
        self.hd_peak_hz = []
        self.hd_preferred_firing_angle = []
        self.hd_snr = []
        self.stability_index = []
        self.cell_name = cell_name

        idx = get_idx(cell_specific_data, cell_name)
        bins, spikes_per_bin = self.get_angles(cell_specific_data, idx)
        head_angle_sampling = hd_behaviour.time_spent_each_head_angle_hist
        bin_spacing_rad = np.deg2rad(options.direction_bin)
        self.descriptive(bins, spikes_per_bin, bin_spacing_rad)
        self.firing(
            cell_specific_data,
            idx,
            df,
            options,
            config,
            calc_hd_peak_method=options.calc_hd_peak_method,
            smooth_width=options.calc_hd_hist_smooth_width,
            baseline_bin=options.direction_baseline_bin,
            bin_size=options.direction_bin,
        )

        self.directionality(bins, spikes_per_bin)

        self.calc_stability_index(
            df,
            cell_name,
            config.camera_frames_per_sec,
            bin_width=options.direction_bin,
            smooth_width=options.hd_smooth_sigma,
        )
        if options.hd_shuffle_test:
            self.hd_shuffled_stats(
                df,
                cell_name,
                head_angle_sampling,
                min_shuffle_dist_time=options.hd_shuffle_min_magnitude,
                max_shuffle_dist_time=options.hd_shuffle_max_magnitude,
                num_iterations=options.hd_shuffle_iterations,
                bin_spacing=bin_spacing_rad,
                camera_frames_per_sec=config.camera_frames_per_sec,
                num_processes=options.num_processes,
                parallel=options.parallel,
                smooth_width=options.hd_smooth_sigma,
            )
Пример #5
0
    def __init__(self, cell_specific_data, df, cell_name, options, config):
        df = clean_df(df, speed_cutoff=options.ahv_speed_cut_off, copy=True)
        self.cell_name = cell_name
        self.ahv_baseline_hz = []
        self.ahv_peak_hz = []
        self.ahv_pearson_r_neg = []
        self.ahv_pearson_p_neg = []
        self.ahv_pearson_r_pos = []
        self.ahv_pearson_p_pos = []
        self.ahv_fit_intercept_neg = []
        self.ahv_fit_intercept_pos = []
        self.ahv_fit_slope_neg = []
        self.ahv_fit_slope_pos = []
        self.pearson_neg_percentile = []
        self.pearson_pos_percentile = []
        self.ahv_stability_index = []
        self.ahv_r_percentile_first_half_neg = []
        self.ahv_r_percentile_first_half_pos = []
        self.ahv_r_percentile_second_half_neg = []
        self.ahv_r_percentile_second_half_pos = []
        self.ahv_pearson_r_first_half_neg = []
        self.ahv_pearson_r_first_half_pos = []
        self.ahv_pearson_r_second_half_neg = []
        self.ahv_pearson_r_second_half_pos = []
        self.ahv_null_correlation_percentile = []

        self.__shuffled_binned_data = []

        idx = get_idx(cell_specific_data, cell_name)

        cw_ccw_firing = GetCWandCCW(cell_specific_data, idx)

        self.firing(df, cw_ccw_firing, options, config)
        self.get_correlation(cw_ccw_firing)
        self.get_fit(cw_ccw_firing)

        if options.ahv_shuffle_test:
            self.get_ahv_cell_sig(
                cell_specific_data,
                df,
                cell_name,
                min_shuffle_dist_time=options.ahv_shuffle_min_magnitude,
                max_shuffle_dist_time=options.ahv_shuffle_max_magnitude,
                num_iterations=options.ahv_shuffle_iterations,
                camera_frames_per_sec=config.camera_frames_per_sec,
                num_processes=options.num_processes,
                correlation_mag_force=options.ahv_correlation_magnitude,
                parallel=options.parallel,
            )
Пример #6
0
    def __init__(self, df, options, camera_frames_per_sec):
        df = clean_df(df,
                      speed_cutoff=options.velocity_speed_cut_off,
                      copy=True)
        self.velocity = df["total_speed"]
        self.camera_frames_per_sec = camera_frames_per_sec
        self.bin_size = options.velocity_bin_size
        self.bins = []
        self.velocity_hist_seconds = []
        self.velocity_hist_centers = []

        self.min_velocity = 0
        self.max_velocity = options.max_velocity

        self.velocity_hist()
Пример #7
0
    def __init__(self, df, options, config):
        df = clean_df(df, speed_cutoff=options.place_speed_cut_off, copy=True)
        self.x = []
        self.y = []
        self.x_max = config.camera_x
        self.y_max = config.camera_y
        self.x_bins = []
        self.y_bins = []
        self.x_bin_centers = []
        self.y_bin_centers = []
        self.place_hist_seconds = []

        self.camera_frames_per_sec = config.camera_frames_per_sec
        self.bin_size = options.spatial_bin_size

        self.x, self.y = get_positions(
            df, use_head_as_position=options.spatial_position_head)
        self.convert_positions_to_m(config.meters_per_pixel)
        self.get_bins()
        self.place_hist()
Пример #8
0
    def __init__(self, df, options, camera_frames_per_sec):
        df = clean_df(df, speed_cutoff=options.hd_speed_cut_off, copy=True)
        self.camera_frames_per_sec = camera_frames_per_sec
        self.bin_size = options.direction_bin
        self.kde_kappa = options.hd_kde_kappa

        self.time_spent_each_head_angle_hist = []
        self.hd_bin_centers_hist = []
        self.time_spent_each_head_angle_kde = []
        self.hd_bin_centers_kde = []

        self.angles = column_as_array(df, "absolute_head_angle")

        # todo: combine bin centers (standardise to a range) ???
        # i.e. combine kde and hist bin numbers?

        self.hd_hist(
            bin_size=options.direction_bin,
            smooth_width=options.hd_smooth_sigma,
        )
        self.hd_kde(kappa=self.kde_kappa)
Пример #9
0
    def __init__(self,
                 df,
                 options,
                 camera_frames_per_sec,
                 border_choice="max"):
        df = clean_df(df, speed_cutoff=options.ahv_speed_cut_off, copy=True)
        self.ang_vel = df["angular_head_velocity"]
        self.camera_frames_per_sec = camera_frames_per_sec
        self.bin_size = options.ang_vel_bin_size
        self.central_ahv_fraction = options.central_ahv_fraction
        self.border_choice = border_choice
        self.max_ahv = options.max_ahv
        self.min_ahv = []
        self.bins = []
        self.ahv_hist_seconds = []
        self.ahv_hist_centers = []
        self.retained_ahv_timepoint_fraction = []

        self.dp = 2  # decimal points for reporting values

        self.ahv_hist()
        self.calculate_ahc_cutoffs()
        self.calculate_retained_timepoints()
Пример #10
0
    def __init__(self, cell_specific_data, df, cell_name, options, config):
        df = clean_df(df,
                      speed_cutoff=options.velocity_speed_cut_off,
                      copy=True)

        self.velocity_pearson_r = []
        self.velocity_pearson_p = []
        self.pearson_percentile = []
        self.velocity_fit_intercept = []
        self.velocity_fit_slope = []
        self.velocity_stability_index = []
        self.velocity_r_percentile_first_half = []
        self.velocity_r_percentile_second_half = []
        self.velocity_pearson_r_first_half = []
        self.velocity_pearson_r_second_half = []
        self.velocity_null_correlation_percentile = []

        self.__shuffled_binned_data = []
        idx = get_idx(cell_specific_data, cell_name)

        self.get_correlations(idx, cell_specific_data)
        self.get_fit(idx, cell_specific_data)

        if options.velocity_shuffle_test:
            self.get_velocity_cell_sig(
                cell_specific_data,
                df,
                cell_name,
                min_shuffle_dist_time=options.velocity_shuffle_min_magnitude,
                max_shuffle_dist_time=options.velocity_shuffle_max_magnitude,
                num_iterations=options.velocity_shuffle_iterations,
                camera_frames_per_sec=config.camera_frames_per_sec,
                num_processes=options.num_processes,
                parallel=options.parallel,
                correlation_mag_force=options.velocity_correlation_magnitude,
            )
Пример #11
0
 def calc_place(self, df, place, options):
     df = clean_df(df, speed_cutoff=options.place_speed_cut_off, copy=True)
     self.get_place_firing_bins(
         df, place, min_time_in_spatial_bin=options.min_time_in_spatial_bin
     )
Пример #12
0
 def calc_velocity(self, df, velocity, options):
     df = clean_df(
         df, speed_cutoff=options.velocity_speed_cut_off, copy=True
     )
     self.get_velocity_firing_rates_bins(df, velocity)
Пример #13
0
 def calc_ahv(self, df, ahv, options):
     df = clean_df(df, speed_cutoff=options.ahv_speed_cut_off, copy=True)
     self.get_ahv_firing_rates_bins(df, ahv)