|
| 1 | +import string |
| 2 | +from pathlib import Path |
| 3 | + |
| 4 | +import wandb |
| 5 | + |
| 6 | +from movie_decoding.main import pipeline |
| 7 | +from movie_decoding.utils.initializer import * |
| 8 | + |
| 9 | +# for patient in ['562', '563', '566', 'i728', '567', '572']: |
| 10 | +patient_list = ["i728", "572", "567", "566", "563", "562"] |
| 11 | +sd_list = [4, 4, 3.5, 4, 4, 3.5] |
| 12 | +# data_list = ['notch CAR4.5', 'notch CAR3.5', 'notch CAR4.5', 'notch CAR4', 'notch CAR3.5', 'notch CAR3.5'] |
| 13 | +data_list = [ |
| 14 | + "notch CAR-quant-neg", |
| 15 | + "notch CAR-quant-neg", |
| 16 | + "notch CAR-quant-neg", |
| 17 | + "notch CAR-quant-neg", |
| 18 | + "notch CAR-quant-neg", |
| 19 | + "notch CAR-quant-neg", |
| 20 | +] |
| 21 | +early_stop = [100, 100, 100, 50, 50, 75] |
| 22 | +for patient, sd, dd in zip(patient_list, sd_list, data_list): |
| 23 | + print() |
| 24 | + print("start: ", patient) |
| 25 | + for data_type in ["clusterless"]: |
| 26 | + for run in range(5, 6): |
| 27 | + # root_path = os.path.dirname(os.path.abspath(__file__)) |
| 28 | + root_path = Path(__file__).parent.parent |
| 29 | + # save the results |
| 30 | + letters = string.ascii_lowercase |
| 31 | + # suffix = ''.join(random.choice(letters) for i in range(3)) |
| 32 | + suffix = f"test53_optimalX_CARX_{run}" |
| 33 | + if data_type == "clusterless": |
| 34 | + use_clusterless = True |
| 35 | + use_lfp = False |
| 36 | + use_combined = False |
| 37 | + model_architecture = "multi-vit" #'multi-vit' |
| 38 | + elif data_type == "lfp": |
| 39 | + use_clusterless = False |
| 40 | + use_lfp = True |
| 41 | + use_combined = False |
| 42 | + model_architecture = "multi-vit" |
| 43 | + elif data_type == "combined": |
| 44 | + use_clusterless = True |
| 45 | + use_lfp = True |
| 46 | + use_combined = True |
| 47 | + model_architecture = "multi-crossvit" |
| 48 | + else: |
| 49 | + ValueError(f"undefined data_type: {data_type}") |
| 50 | + |
| 51 | + args = initialize_configs(architecture=model_architecture) |
| 52 | + args["seed"] = 42 |
| 53 | + args["device"] = "cuda:1" |
| 54 | + args["patient"] = patient |
| 55 | + args["use_spike"] = use_clusterless |
| 56 | + args["use_lfp"] = use_lfp |
| 57 | + args["use_combined"] = use_combined |
| 58 | + args["use_spontaneous"] = False |
| 59 | + if use_clusterless: |
| 60 | + args["use_shuffle"] = True |
| 61 | + elif use_lfp: |
| 62 | + args["use_shuffle"] = False |
| 63 | + |
| 64 | + args["use_bipolar"] = False |
| 65 | + args["use_sleep"] = False |
| 66 | + args["use_overlap"] = False |
| 67 | + args["model_architecture"] = model_architecture |
| 68 | + |
| 69 | + args["spike_data_mode"] = dd |
| 70 | + args["spike_data_mode_inference"] = dd |
| 71 | + args["spike_data_sd"] = [sd] |
| 72 | + args["spike_data_sd_inference"] = sd |
| 73 | + args["use_augment"] = False |
| 74 | + args["use_long_input"] = False |
| 75 | + args["use_shuffle_diagnostic"] = False |
| 76 | + args["model_aggregate_type"] = "sum" |
| 77 | + |
| 78 | + train_save_path = os.path.join( |
| 79 | + root_path, |
| 80 | + "results/8concepts/{}_{}_{}_{}/train".format(args["patient"], data_type, model_architecture, suffix), |
| 81 | + ) |
| 82 | + valid_save_path = os.path.join( |
| 83 | + root_path, |
| 84 | + "results/8concepts/{}_{}_{}_{}/valid".format(args["patient"], data_type, model_architecture, suffix), |
| 85 | + ) |
| 86 | + test_save_path = os.path.join( |
| 87 | + root_path, |
| 88 | + "results/8concepts/{}_{}_{}_{}/test".format(args["patient"], data_type, model_architecture, suffix), |
| 89 | + ) |
| 90 | + memory_save_path = os.path.join( |
| 91 | + root_path, |
| 92 | + "results/8concepts/{}_{}_{}_{}/memory".format(args["patient"], data_type, model_architecture, suffix), |
| 93 | + ) |
| 94 | + os.makedirs(train_save_path, exist_ok=True) |
| 95 | + os.makedirs(valid_save_path, exist_ok=True) |
| 96 | + os.makedirs(test_save_path, exist_ok=True) |
| 97 | + os.makedirs(memory_save_path, exist_ok=True) |
| 98 | + args["train_save_path"] = train_save_path |
| 99 | + args["valid_save_path"] = valid_save_path |
| 100 | + args["test_save_path"] = test_save_path |
| 101 | + args["memory_save_path"] = memory_save_path |
| 102 | + |
| 103 | + os.environ["WANDB_MODE"] = "offline" |
| 104 | + # os.environ['WANDB_API_KEY'] = '5a6051ed615a193c44eb9f655b81703925460851' |
| 105 | + wandb.login() |
| 106 | + if use_lfp: |
| 107 | + run_name = "LFP Concept level {} MultiEncoder".format(args["patient"]) |
| 108 | + else: |
| 109 | + run_name = "Clusterless Concept level {} MultiEncoder".format(args["patient"]) |
| 110 | + wandb.init(project="24_Concepts", name=run_name, reinit=True, entity="24") |
| 111 | + |
| 112 | + trainer = pipeline(args) |
| 113 | + |
| 114 | + print("Start training") |
| 115 | + # start_time = time.time() |
| 116 | + |
| 117 | + trainer.train(args["epochs"], 1) |
| 118 | + print("done: ", patient) |
| 119 | + print() |
0 commit comments