コード例 #1
0
def return_bar_values(nd, lickstart, lickstop, resolution):
    # local function, determines lists of times of entry and exit for plot
    session = initiate_lickwell_network(nd)  # Initialize session
    speed_list = []
    spike_rate_list = []
    for lick in session.licks:
        if lick.lickwell == 1:
            speeds = []
            spike_rates = []
            timeslice = session[int(lick.time + lickstart):int(lick.time +
                                                               lickstop)]

            # determine what percentage of licks are in range for histogram
            for i in range(0, len(timeslice.position_x), resolution):
                interval = timeslice[i:i + resolution]
                speed = np.average(interval.speed)
                speeds.append(speed)
                spikes = [a for li in interval.spikes
                          for a in li]  # flatten all spikes in time range
                spike_rates.append(len(spikes) / nd.n_neurons)
            spike_rate_list.append(spike_rates)
            speed_list.append(speeds)
    speed_list = np.average(speed_list, axis=0)
    spike_rate_list = np.average(spike_rate_list, axis=0)
    return speed_list, spike_rate_list
コード例 #2
0
ファイル: time_histogram.py プロジェクト: imandor/NNMaster
def timehistogram_bar_values(nd,lickstart,lickstop,searchradius,interval):
    # Determines lists of times of entry and exit for plot
    entry_list = []
    exit_list = []
    lickids = []
    session = initiate_lickwell_network(nd)  # Initialize session
    for lick in session.licks:
        if lick.lickwell == 1:
            timeslice = session[int(lick.time+lickstart):int(lick.time+lickstop)]
            enter_time = None
            exit_time = None
            for time, position in enumerate(timeslice.position_x):
                is_before_lick = (time<-lickstart) # determines if current time is before lick event
                if not is_before_lick and enter_time is None: # sets time when rat enters vicinity of well 1
                    enter_time = 0
                    print("Warning: there seems to be a problem with the position of the rat during a lick at well 1")
                if (position < searchradius or time == lickstart) and enter_time is None: # determine when rat enters area
                    enter_time = time
                if position>searchradius and exit_time is None:
                    if is_before_lick: # rat leaves area before lick
                        enter_time = None
                    else: # set exit time
                        exit_time = time
                if exit_time is None and time == lickstop-lickstart-1:
                    print("Warning: the rat does not leave the vicinity inside the given time range")
                    exit_time = lickstop-lickstart
                if enter_time is not None and exit_time is not None:
                    entry_list.append(enter_time+lickstart)
                    exit_list.append(exit_time+lickstart)
                    lickids.append(lick.lick_id)
                    break

    # determine what percentage of licks are in range for histogram

    counter_list = []
    ind_labels = []
    for i in range(lickstart,lickstop+1,interval):
        counter = 0
        for j in range(0,len(lickids)):
            if i>=entry_list[j] and i<=exit_list[j]:
                counter += 1
        counter_list.append(counter/len(lickids))
        ind_labels.append(i)

    return lickids,entry_list,exit_list,counter_list,ind_labels
コード例 #3
0
        number_of_bins=10,
    )
    print_metric_details(
        "C:/Users/NN/Desktop/Master/experiments/Experiments for thesis 2/well decoding/hc/",
        1)
    print_metric_details(
        "C:/Users/NN/Desktop/Master/experiments/Experiments for thesis 2/well decoding/hc/",
        -1)
    print_metric_details(
        "C:/Users/NN/Desktop/Master/experiments/Experiments for thesis 2/well decoding/pfc/",
        1)
    print_metric_details(
        "C:/Users/NN/Desktop/Master/experiments/Experiments for thesis 2/well decoding/pfc/",
        -1)

    session = initiate_lickwell_network(nd)  # Initialize session
    X, y, nd, session, = lickwells_io(session,
                                      nd,
                                      excluded_wells=[1],
                                      shift=nd.initial_timeshift,
                                      target_is_phase=True,
                                      lickstart=0,
                                      lickstop=5000)

    # counts = [0,0,0,0,0]
    # for lick in y:
    #     counts[lick.target-1] +=1
    # print("&",counts[1], "&", counts[2], "&", counts[3], "&", counts[4], "&", max(counts), "\\\ \hline")
    #
    # print("&",counts[1]*40, "&", counts[2]*40, "&", counts[3]*40, "&", counts[4]*40, "&", max(counts)*40, "\\\ \hline")
コード例 #4
0
ファイル: main.py プロジェクト: imandor/NNMaster
def guiRun_network():
    nd = Net_data(
        model_path=tbx_model_path.value,
        raw_data_path=tbx_raw_data_path.value,
        dropout=float(tbx_dropout.value),
        filtered_data_path=tbx_filtered_data_path.value,
        stride=int(tbx_stride.value),
        epochs=int(tbx_epochs.value),
        from_raw_data=bool(cbo_from_raw_data.value == "True"),
        evaluate_training=bool(cbo_evaluate_training.value == "True"),
        session_filter=Filter(func=hann,
                              search_radius=int(tbx_search_radius.value),
                              step_size=int(tbx_step_size.value)),
        time_shift_steps=int(tbx_time_shift_steps.value),
        shuffle_data=bool(cbo_shuffle_data.value == "True"),
        shuffle_factor=int(tbx_shuffle_factor.value),
        time_shift_iter=int(tbx_time_shift_iter.value),
        initial_timeshift=int(tbx_initial_timeshift.value),
        metric_iter=int(tbx_metric_iter.value),
        batch_size=int(tbx_batch_size.value),
        slice_size=int(tbx_slice_size.value),
        x_max=int(tbx_x_max.value),
        y_max=int(tbx_y_max.value),
        x_min=int(tbx_x_min.value),
        y_min=int(tbx_y_min.value),
        x_step=int(tbx_x_step.value),
        y_step=int(tbx_y_step.value),
        early_stopping=bool(cbo_early_stopping.value == "True"),
        naive_test=bool(cbo_naive_test.value == "True"),
        valid_ratio=float(tbx_valid_ratio.value),
        testing_ratio=float(tbx_testing_ratio.value),
        k_cross_validation=int(tbx_k_cross_validation.value),
        load_model=bool(cbo_load_model.value == "True"),
        train_model=bool(cbo_train_model.value == "True"),
        keep_neurons=-1,
        neurons_kept_factor=float(tbx_neurons_kept_factor.value),
        lw_classifications=None
        if not tbx_lw_classifications.value.isnumeric() else int(
            tbx_lw_classifications.value),
        lw_normalize=bool(cboLw_normalize.value == "True"),
        lw_differentiate_false_licks=bool(
            cbo_lw_differentiate_false_licks.value == "True"),
        num_wells=int(tbx_num_wells.value),
        metric=tbx_metric.value,
        valid_licks=None
        if tbx_valid_licks.value == 'None' else tbx_valid_licks.value,
        filter_tetrodes=None
        if tbx_filter_tetrodes.value == 'None' else tbx_filter_tetrodes.value,
        phases=None if tbx_phases.value == 'None' else tbx_phases.value,
        phase_change_ids=None if tbx_phase_change_ids.value == 'None' else
        tbx_phase_change_ids.value,
        number_of_bins=int(tbx_number_of_bins.value),
        start_time_by_lick_id=None
        if not tbx_start_time_by_lick_id.value.isnumeric() else int(
            tbx_start_time_by_lick_id.value),
        behavior_component_filter=None if cbo_behavior_component.value
        == 'None' else cbo_behavior_component.value)
    if tbx_metric.value == "map":
        session = initiate_network(nd)
        run_network(nd, session)
    else:
        session = initiate_lickwell_network(nd)  # Initialize session
        X, y, nd, session, = lickwells_io(session,
                                          nd,
                                          _excluded_wells=[1],
                                          shift=nd.initial_timeshift,
                                          target_is_phase=False,
                                          lickstart=0,
                                          lickstop=5000)

    pass