RAW_DATA_PATH = "G:/master_datafiles/raw_data/HC/" FILTERED_DATA_PATH = "session_hc_lw.pkl" nd = Net_data( # Program execution settings epochs=20, evaluate_training=False, slice_size=100, stride=100, y_step=100, win_size=100, search_radius=100, k_cross_validation=10, session_filter=Filter(func=hann, search_radius=100, step_size=100), valid_ratio=0.1, testing_ratio=0, time_shift_steps=1, early_stopping=False, model_path=MODEL_PATH, raw_data_path=RAW_DATA_PATH, filtered_data_path=FILTERED_DATA_PATH, metric="discrete", shuffle_data=True, shuffle_factor=1, lw_classifications=4, lw_normalize=True, lw_differentiate_false_licks=False, num_wells=5, initial_timeshift=-1, from_raw_data=False, dropout=0.2) # print_metric_details(MODEL_PATH,nd.initial_timeshift)
from src.network_functions import run_network_process, initiate_network, run_network from src.database_api_beta import Net_data from src.model_data import c_dmf, chc_dmf, cpfc_dmf, hc_dmf, pfc_dmf if __name__ == '__main__': model_data = hc_dmf nd = Net_data(initial_timeshift=0, time_shift_iter=500, time_shift_steps=1, early_stopping=True, model_path=model_data.model_path, raw_data_path=model_data.raw_data_path, filtered_data_path=model_data.filtered_data_path, k_cross_validation=10, valid_ratio=0.1, naive_test=False, from_raw_data=False, epochs=20, dropout=0.65, behavior_component_filter=None, filter_tetrodes=model_data.filter_tetrodes, shuffle_factor=50, switch_x_y=model_data.switch_x_y) session = initiate_network(nd) # Settings fontsize = 24 plot_error_bars = False rc('font', **{'family': 'serif', 'serif': ['Palatino']}) rc('text', usetex=True)
# filter_tetrodes = range(0, 13) # all neurons # MODEL_PATH = "G:/master_datafiles/trained_networks/c_naive/" # FILTERED_DATA_PATH = "slice_C.pkl" nd = Net_data(initial_timeshift=-2000, time_shift_iter=500, time_shift_steps=21, early_stopping=False, model_path=MODEL_PATH, raw_data_path=RAW_DATA_PATH, filtered_data_path=FILTERED_DATA_PATH, k_cross_validation=1, valid_ratio=0.1, naive_test=True, from_raw_data=True, epochs=30, dropout=0.65, behavior_component_filter=None, filter_tetrodes=filter_tetrodes, shuffle_data=True, shuffle_factor=10, batch_size=50, switch_x_y=combination_data_set) session = initiate_network(nd) run_network(nd, session) nd = Net_data(initial_timeshift=-2500, time_shift_iter=-500, time_shift_steps=20,
model_data = pfc_dmf # model_data = chc_dmf model_data.model_path = "G:/master_datafiles/trained_networks/pfc/" nd = Net_data( initial_timeshift=-10000, time_shift_iter=500, time_shift_steps=41, early_stopping=False, model_path=model_data.model_path, raw_data_path=model_data.raw_data_path, filtered_data_path=model_data.filtered_data_path, k_cross_validation=10, valid_ratio=0.1, naive_test=False, from_raw_data=False, epochs=15, dropout=0.65, # behavior_component_filter="rest", # behavior_component_filter="not at lickwell", # behavior_component_filter="correct trials", # behavior_component_filter="incorrect trials", # behavior_component_filter="move", filter_tetrodes=model_data.filter_tetrodes, shuffle_data=True, shuffle_factor=10, batch_size=50, switch_x_y=model_data.switch_x_y) session = initiate_network(nd) licks_timestamp = [lick.time for lick in session.licks] # session.plot(ax_filtered_spikes=session.filtered_spikes, ax_raw_spikes=session.spikes, ax_licks=licks_timestamp) # speedlist = [] # Speed test
import seaborn as sn import pandas as pd import matplotlib.pyplot as plt if __name__ == '__main__': RAW_DATA_PATH = "G:/master_datafiles/raw_data/C" MODEL_PATH = "G:/master_datafiles/trained_networks/no_shuffle_test_3_different_dataset/" FILTERED_DATA_PATH = "slice_C.pkl" filter_tetrodes = None nd = Net_data(initial_timeshift=0, epochs=1, time_shift_iter=500, time_shift_steps=1, early_stopping=False, model_path=MODEL_PATH, raw_data_path=RAW_DATA_PATH, filtered_data_path=FILTERED_DATA_PATH, k_cross_validation=10, from_raw_data=False) session = initiate_lickwell_network(nd) # Initialize session # x and y are switched for this session and are restored to their original order to make them identical to the other sessions copy_pos_x = session.position_x session.position_x = session.position_y session.position_y = copy_pos_x for lick in session.licks: print(lick.lickwell) array = np.zeros((10, 10))
# Prefrontal Cortex # MODEL_PATH = "G:/master_datafiles/trained_networks/filter_neurons_cpfc_100/" # FILTERED_DATA_PATH = "session_CPFC.pkl" # filter_tetrodes=range(0,13) # Combination # MODEL_PATH = "G:/master_datafiles/trained_networks/filter_neurons_c_100/" # FILTERED_DATA_PATH = "slice_C.pkl" # filter_tetrodes=None nd = Net_data( initial_timeshift=-5000, filter_tetrodes=filter_tetrodes, time_shift_iter=500, time_shift_steps=21, early_stopping=False, model_path=MODEL_PATH, raw_data_path=RAW_DATA_PATH, k_cross_validation = 1, naive_test=False, from_raw_data=True, epochs = 10, neurons_kept_factor=0.8 ) session = initiate_network(nd) copy_pos_x = session.position_x session.position_x = session.position_y session.position_y = copy_pos_x run_network(nd, session)
study="lickwell", nd=Net_data( network_shape=11, # Program execution settings epochs=10, evaluate_training=False, slice_size=200, stride=200, y_step=200, win_size=200, search_radius=200, k_cross_validation=10, session_filter=Filter(func=hann, search_radius=200, step_size=200), valid_ratio=0.1, testing_ratio=0, time_shift_steps=1, early_stopping=False, model_path= "G:/master_datafiles/trained_networks/MLP_PFC_lickwell_example/", raw_data_path="G:/master_datafiles/raw_data/PFC/", filtered_data_path="session_hc_lw.pkl", metric="discrete", shuffle_data=True, shuffle_factor=1, lw_classifications=5, lw_normalize=True, lw_differentiate_false_licks=False, num_wells=5, initial_timeshift=1, )) lickwell_experiment_pfc_memory = Experiment(
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
filter_tetrodes = range(0, 13) # all neurons # MODEL_PATH = "G:/master_datafiles/trained_networks/no_shuffle_test_3_different_dataset/" # FILTERED_DATA_PATH = "slice_C.pkl" # filter_tetrodes=None nd = Net_data(initial_timeshift=-5000, time_shift_iter=5000, time_shift_steps=3, valid_ratio=1, early_stopping=True, model_path=MODEL_PATH, raw_data_path=RAW_DATA_PATH, filtered_data_path=FILTERED_DATA_PATH, k_cross_validation=1, naive_test=False, load_model=True, from_raw_data=True, epochs=1, dropout=0.65, train_model=False) session = initiate_network(nd) if combination_data_set is True: copy_pos_x = session.position_x session.position_x = session.position_y session.position_y = copy_pos_x # pick run_network(nd, session)
def filter_well(x,y,well): if __name__ == '__main__': # prefrontal cortex # MODEL_PATH = "G:/master_datafiles/trained_networks/MLP_PFC_2018-11-06_1000_200_100_dmf/" # RAW_DATA_PATH = "G:/master_datafiles/raw_data/2018-04-09_14-39-52/" # FILTERED_DATA_PATH = "G:/master_datafiles/filtered_data/neocortex_hann_win_size_20.pkl" # hippocampus MODEL_PATH = "G:/master_datafiles/trained_networks/MLP_HC_2018-11-11_1000_200_100_dmf/" RAW_DATA_PATH = "G:/master_datafiles/raw_data/2018-05-16_17-13-37/" FILTERED_DATA_PATH = "G:/master_datafiles/filtered_data/hippocampus_hann_win_size_25_09-5_7.pkl" NEURONS_KEPT_FACTOR = 1 WIN_SIZE = 20 SEARCH_RADIUS = WIN_SIZE * 2 session_filter = Filter(func=hann, search_radius=SEARCH_RADIUS, step_size=WIN_SIZE) nd = Net_data( # Program execution settings EPOCHS=20, SEARCH_RADIUS=SEARCH_RADIUS, WIN_SIZE=WIN_SIZE, INITIAL_TIMESHIFT=0, TIME_SHIFT_ITER=200, TIME_SHIFT_STEPS=1, METRIC_ITER=1, # after how many epochs network is validated <--- SHUFFLE_DATA=True, # whether to randomly shuffle the data in big slices SHUFFLE_FACTOR=500, EARLY_STOPPING=True, NAIVE_TEST=False, K_CROSS_VALIDATION=1, TRAIN_MODEL=True, # Input data parameters SLICE_SIZE=1000, Y_SLICE_SIZE=200, STRIDE=100, BATCH_SIZE=50, VALID_RATIO=0.1, X_MAX=240, Y_MAX=190, X_MIN=0, Y_MIN=100, X_STEP=3, y_step=3, LOAD_MODEL= False, session_filter=session_filter, MODEL_PATH=MODEL_PATH, r2_scores_train=[], r2_scores_valid=[], acc_scores_train=[], acc_scores_valid=[], avg_scores_train=[], avg_scores_valid=[], RAW_DATA_PATH=RAW_DATA_PATH, ) X,y,session = initiate_network(nd) run_network(X,y,nd,session)