|
19 | 19 | from bsi_zoo.config import get_leadfield_path
|
20 | 20 |
|
21 | 21 | n_jobs = 20
|
22 |
| -nruns = 10 |
23 |
| -spatial_cv = [False, True] |
| 22 | +nruns = 1 |
| 23 | +# spatial_cv = [False, True] |
| 24 | +spatial_cv = [False] |
| 25 | + |
24 | 26 | #
|
25 | 27 | subjects = ["CC120166", "CC120264", "CC120313", "CC120309"]
|
26 | 28 | metrics = [
|
|
38 | 40 |
|
39 | 41 | for do_spatial_cv in spatial_cv:
|
40 | 42 | for subject in subjects:
|
41 |
| - """Fixed orientation parameters for the benchmark""" |
42 |
| - |
43 |
| - orientation_type = "fixed" |
44 |
| - data_args_I = { |
45 |
| - # "n_sensors": [50], |
46 |
| - "n_times": [10], |
47 |
| - # "n_sources": [200], |
48 |
| - "nnz": nnzs, |
49 |
| - "cov_type": ["diag"], |
50 |
| - "path_to_leadfield": [get_leadfield_path(subject, type=orientation_type)], |
51 |
| - "orientation_type": [orientation_type], |
52 |
| - "alpha": alpha_SNR, # this is actually SNR |
53 |
| - } |
54 |
| - |
55 |
| - data_args_II = { |
56 |
| - # "n_sensors": [50], |
57 |
| - "n_times": [10], |
58 |
| - # "n_sources": [200], |
59 |
| - "nnz": nnzs, |
60 |
| - "cov_type": ["full"], |
61 |
| - "path_to_leadfield": [get_leadfield_path(subject, type=orientation_type)], |
62 |
| - "orientation_type": [orientation_type], |
63 |
| - "alpha": alpha_SNR, # this is actually SNR |
64 |
| - } |
65 |
| - |
66 |
| - estimators = [ |
67 |
| - (fake_solver, data_args_I, {"alpha": estimator_alphas_I}, {}), |
68 |
| - (eloreta, data_args_I, {"alpha": estimator_alphas_II}, {}), |
69 |
| - (iterative_L1, data_args_I, {"alpha": estimator_alphas_I}, {}), |
70 |
| - (iterative_L2, data_args_I, {"alpha": estimator_alphas_I}, {}), |
71 |
| - (iterative_sqrt, data_args_I, {"alpha": estimator_alphas_I}, {}), |
72 |
| - (iterative_L1_typeII, data_args_II, {"alpha": estimator_alphas_I}, {}), |
73 |
| - (iterative_L2_typeII, data_args_II, {"alpha": estimator_alphas_I}, {}), |
74 |
| - # (gamma_map, data_args_II, {"alpha": estimator_alphas_I}, {"update_mode": 1}), |
75 |
| - (gamma_map, data_args_II, {"alpha": estimator_alphas_II}, {"update_mode": 2}), |
76 |
| - # (gamma_map, data_args_II, {"alpha": estimator_alphas_I}, {"update_mode": 3}), |
77 |
| - ] |
78 |
| - |
79 |
| - df_results = [] |
80 |
| - for estimator, data_args, estimator_args, estimator_extra_params in estimators: |
81 |
| - benchmark = Benchmark( |
82 |
| - estimator, |
83 |
| - subject, |
84 |
| - metrics, |
85 |
| - data_args, |
86 |
| - estimator_args, |
87 |
| - random_state=42, |
88 |
| - memory=memory, |
89 |
| - n_jobs=n_jobs, |
90 |
| - do_spatial_cv=do_spatial_cv, |
91 |
| - estimator_extra_params=estimator_extra_params, |
92 |
| - ) |
93 |
| - results = benchmark.run(nruns=nruns) |
94 |
| - df_results.append(results) |
95 |
| - # save results |
96 |
| - data_path = Path("bsi_zoo/data/updated_alpha_grid") |
97 |
| - data_path.mkdir(exist_ok=True) |
98 |
| - if do_spatial_cv: |
99 |
| - FILE_NAME = f"{estimator}_{subject}_{data_args['orientation_type'][0]}_spatialCV_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
100 |
| - else: |
101 |
| - FILE_NAME = f"{estimator}_{subject}_{data_args['orientation_type'][0]}_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
102 |
| - results.to_pickle(data_path / FILE_NAME) |
103 |
| - |
104 |
| - |
105 |
| - df_results = pd.concat(df_results, axis=0) |
106 |
| - |
107 |
| - data_path = Path("bsi_zoo/data/ramen") |
108 |
| - data_path.mkdir(exist_ok=True) |
109 |
| - if do_spatial_cv: |
110 |
| - FILE_NAME = f"benchmark_data_{subject}_{data_args['orientation_type'][0]}_spatialCV_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
111 |
| - else: |
112 |
| - FILE_NAME = f"benchmark_data_{subject}_{data_args['orientation_type'][0]}_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
113 |
| - df_results.to_pickle(data_path / FILE_NAME) |
114 |
| - |
115 |
| - print(df_results) |
| 43 | + # """Fixed orientation parameters for the benchmark""" |
| 44 | + |
| 45 | + # orientation_type = "fixed" |
| 46 | + # data_args_I = { |
| 47 | + # # "n_sensors": [50], |
| 48 | + # "n_times": [10], |
| 49 | + # # "n_sources": [200], |
| 50 | + # "nnz": nnzs, |
| 51 | + # "cov_type": ["diag"], |
| 52 | + # "path_to_leadfield": [get_leadfield_path(subject, type=orientation_type)], |
| 53 | + # "orientation_type": [orientation_type], |
| 54 | + # "alpha": alpha_SNR, # this is actually SNR |
| 55 | + # } |
| 56 | + |
| 57 | + # data_args_II = { |
| 58 | + # # "n_sensors": [50], |
| 59 | + # "n_times": [10], |
| 60 | + # # "n_sources": [200], |
| 61 | + # "nnz": nnzs, |
| 62 | + # "cov_type": ["full"], |
| 63 | + # "path_to_leadfield": [get_leadfield_path(subject, type=orientation_type)], |
| 64 | + # "orientation_type": [orientation_type], |
| 65 | + # "alpha": alpha_SNR, # this is actually SNR |
| 66 | + # } |
| 67 | + |
| 68 | + # estimators = [ |
| 69 | + # (fake_solver, data_args_I, {"alpha": estimator_alphas_I}, {}), |
| 70 | + # (eloreta, data_args_I, {"alpha": estimator_alphas_II}, {}), |
| 71 | + # (iterative_L1, data_args_I, {"alpha": estimator_alphas_I}, {}), |
| 72 | + # (iterative_L2, data_args_I, {"alpha": estimator_alphas_I}, {}), |
| 73 | + # (iterative_sqrt, data_args_I, {"alpha": estimator_alphas_I}, {}), |
| 74 | + # (iterative_L1_typeII, data_args_II, {"alpha": estimator_alphas_I}, {}), |
| 75 | + # (iterative_L2_typeII, data_args_II, {"alpha": estimator_alphas_I}, {}), |
| 76 | + # # (gamma_map, data_args_II, {"alpha": estimator_alphas_I}, {"update_mode": 1}), |
| 77 | + # (gamma_map, data_args_II, {"alpha": estimator_alphas_II}, {"update_mode": 2}), |
| 78 | + # # (gamma_map, data_args_II, {"alpha": estimator_alphas_I}, {"update_mode": 3}), |
| 79 | + # ] |
| 80 | + |
| 81 | + # df_results = [] |
| 82 | + # for estimator, data_args, estimator_args, estimator_extra_params in estimators: |
| 83 | + # benchmark = Benchmark( |
| 84 | + # estimator, |
| 85 | + # subject, |
| 86 | + # metrics, |
| 87 | + # data_args, |
| 88 | + # estimator_args, |
| 89 | + # random_state=42, |
| 90 | + # memory=memory, |
| 91 | + # n_jobs=n_jobs, |
| 92 | + # do_spatial_cv=do_spatial_cv, |
| 93 | + # estimator_extra_params=estimator_extra_params, |
| 94 | + # ) |
| 95 | + # results = benchmark.run(nruns=nruns) |
| 96 | + # df_results.append(results) |
| 97 | + # # save results |
| 98 | + # data_path = Path("bsi_zoo/data/updated_alpha_grid") |
| 99 | + # data_path.mkdir(exist_ok=True) |
| 100 | + # if do_spatial_cv: |
| 101 | + # FILE_NAME = f"{estimator}_{subject}_{data_args['orientation_type'][0]}_spatialCV_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
| 102 | + # else: |
| 103 | + # FILE_NAME = f"{estimator}_{subject}_{data_args['orientation_type'][0]}_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
| 104 | + # results.to_pickle(data_path / FILE_NAME) |
| 105 | + |
| 106 | + |
| 107 | + # df_results = pd.concat(df_results, axis=0) |
| 108 | + |
| 109 | + # data_path = Path("bsi_zoo/data/ramen") |
| 110 | + # data_path.mkdir(exist_ok=True) |
| 111 | + # if do_spatial_cv: |
| 112 | + # FILE_NAME = f"benchmark_data_{subject}_{data_args['orientation_type'][0]}_spatialCV_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
| 113 | + # else: |
| 114 | + # FILE_NAME = f"benchmark_data_{subject}_{data_args['orientation_type'][0]}_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
| 115 | + # df_results.to_pickle(data_path / FILE_NAME) |
| 116 | + |
| 117 | + # print(df_results) |
116 | 118 |
|
117 | 119 | """ Free orientation parameters for the benchmark """
|
118 | 120 |
|
|
142 | 144 | if spatial_cv:
|
143 | 145 | # currently no support for type II methods
|
144 | 146 | estimators = [
|
145 |
| - (fake_solver, data_args_I, {"alpha": estimator_alphas_I}, {}), |
| 147 | + # (fake_solver, data_args_I, {"alpha": estimator_alphas_I}, {}), |
146 | 148 | (iterative_L1, data_args_I, {"alpha": estimator_alphas_I}, {}),
|
147 | 149 | (iterative_L2, data_args_I, {"alpha": estimator_alphas_I}, {}),
|
148 | 150 | (iterative_sqrt, data_args_I, {"alpha": estimator_alphas_I}, {}),
|
149 | 151 | ]
|
150 | 152 | else:
|
151 | 153 | estimators = [
|
152 |
| - (fake_solver, data_args_I, {"alpha": estimator_alphas_I}, {}), |
153 |
| - (eloreta, data_args_I, {"alpha": estimator_alphas_II}, {}), |
| 154 | + # (fake_solver, data_args_I, {"alpha": estimator_alphas_I}, {}), |
| 155 | + # (eloreta, data_args_I, {"alpha": estimator_alphas_II}, {}), |
154 | 156 | (iterative_L1, data_args_I, {"alpha": estimator_alphas_I}, {}),
|
155 |
| - (iterative_L2, data_args_I, {"alpha": estimator_alphas_I}, {}), |
156 |
| - (iterative_sqrt, data_args_I, {"alpha": estimator_alphas_I}, {}), |
157 |
| - (iterative_L1_typeII, data_args_II, {"alpha": estimator_alphas_I}, {}), |
158 |
| - (iterative_L2_typeII, data_args_II, {"alpha": estimator_alphas_I}, {}), |
| 157 | + # (iterative_L2, data_args_I, {"alpha": estimator_alphas_I}, {}), |
| 158 | + # (iterative_sqrt, data_args_I, {"alpha": estimator_alphas_I}, {}), |
| 159 | + # (iterative_L1_typeII, data_args_II, {"alpha": estimator_alphas_I}, {}), |
| 160 | + # (iterative_L2_typeII, data_args_II, {"alpha": estimator_alphas_I}, {}), |
159 | 161 | # (gamma_map, data_args_II, {"alpha": estimator_alphas_I}, {"update_mode": 1}),
|
160 |
| - (gamma_map, data_args_II, {"alpha": estimator_alphas_II}, {"update_mode": 2}), |
| 162 | + # (gamma_map, data_args_II, {"alpha": estimator_alphas_II}, {"update_mode": 2}), |
161 | 163 | # (gamma_map, data_args_II, {"alpha": estimator_alphas_I}, {"update_mode": 3}),
|
162 | 164 | ]
|
163 | 165 |
|
|
178 | 180 | results = benchmark.run(nruns=nruns)
|
179 | 181 | df_results.append(results)
|
180 | 182 | # save results
|
181 |
| - data_path = Path("bsi_zoo/data/free2") |
| 183 | + data_path = Path("bsi_zoo/data/free3") |
182 | 184 | data_path.mkdir(exist_ok=True)
|
183 | 185 |
|
184 | 186 | if do_spatial_cv:
|
|
189 | 191 |
|
190 | 192 | df_results = pd.concat(df_results, axis=0)
|
191 | 193 |
|
192 |
| - data_path = Path("bsi_zoo/data/free2") |
| 194 | + data_path = Path("bsi_zoo/data/free3") |
193 | 195 | data_path.mkdir(exist_ok=True)
|
194 | 196 | if do_spatial_cv:
|
195 | 197 | FILE_NAME = f"benchmark_data_{subject}_{data_args['orientation_type'][0]}_spatialCV_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl"
|
|
0 commit comments