|
18 | 18 | from bsi_zoo.metrics import euclidean_distance, mse, emd, f1, reconstructed_noise
|
19 | 19 | from bsi_zoo.config import get_leadfield_path
|
20 | 20 |
|
21 |
| -n_jobs = 30 |
22 |
| -nruns = 10 |
23 |
| -spatial_cv = [False, True] |
24 |
| -subjects = ["CC120264", "CC120313", "CC120309"] |
25 |
| -# "CC120166", "CC120313", |
| 21 | +n_jobs = 12 |
| 22 | +nruns = 1 |
| 23 | +spatial_cv = [True] |
| 24 | +# True] |
| 25 | +subjects = ["CC120313", "CC120309", "CC120166", "CC120264"] |
26 | 26 | metrics = [
|
27 | 27 | euclidean_distance,
|
28 | 28 | mse,
|
|
42 | 42 | # 0.13572088,
|
43 | 43 | # 0.2096144,
|
44 | 44 | # ] # logspaced
|
45 |
| -estimator_alphas = np.logspace(0, -2, 20)[1:] |
| 45 | +estimator_alphas_I = np.logspace(0, -2, 20)[1:] |
| 46 | +estimator_alphas_II = [0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000, 10000, 100000] |
46 | 47 | memory = Memory(".")
|
47 | 48 |
|
48 | 49 | for do_spatial_cv in spatial_cv:
|
49 | 50 | for subject in subjects:
|
50 |
| - """Fixed orientation parameters for the benchmark""" |
| 51 | + |
| 52 | + # """Fixed orientation parameters for the benchmark""" |
51 | 53 |
|
52 |
| - orientation_type = "fixed" |
| 54 | + # orientation_type = "fixed" |
| 55 | + # data_args_I = { |
| 56 | + # # "n_sensors": [50], |
| 57 | + # "n_times": [10], |
| 58 | + # # "n_sources": [200], |
| 59 | + # "nnz": nnzs, |
| 60 | + # "cov_type": ["diag"], |
| 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 | + # data_args_II = { |
| 67 | + # # "n_sensors": [50], |
| 68 | + # "n_times": [10], |
| 69 | + # # "n_sources": [200], |
| 70 | + # "nnz": nnzs, |
| 71 | + # "cov_type": ["full"], |
| 72 | + # "path_to_leadfield": [get_leadfield_path(subject, type=orientation_type)], |
| 73 | + # "orientation_type": [orientation_type], |
| 74 | + # "alpha": alpha_SNR, # this is actually SNR |
| 75 | + # } |
| 76 | + |
| 77 | + # estimators = [ |
| 78 | + # # (fake_solver, data_args_I, {"alpha": estimator_alphas_I}, {}), |
| 79 | + # (eloreta, data_args_I, {"alpha": estimator_alphas_II}, {}), |
| 80 | + # # (iterative_L1, data_args_I, {"alpha": estimator_alphas_I}, {}), |
| 81 | + # # (iterative_L2, data_args_I, {"alpha": estimator_alphas_I}, {}), |
| 82 | + # # (iterative_sqrt, data_args_I, {"alpha": estimator_alphas_I}, {}), |
| 83 | + # # (iterative_L1_typeII, data_args_II, {"alpha": estimator_alphas_I}, {}), |
| 84 | + # # (iterative_L2_typeII, data_args_II, {"alpha": estimator_alphas_I}, {}), |
| 85 | + # # (gamma_map, data_args_II, {"alpha": estimator_alphas_I}, {"update_mode": 1}), |
| 86 | + # (gamma_map, data_args_II, {"alpha": estimator_alphas_II}, {"update_mode": 2}), |
| 87 | + # # (gamma_map, data_args_II, {"alpha": estimator_alphas_I}, {"update_mode": 3}), |
| 88 | + # ] |
| 89 | + |
| 90 | + # df_results = [] |
| 91 | + # for estimator, data_args, estimator_args, estimator_extra_params in estimators: |
| 92 | + # benchmark = Benchmark( |
| 93 | + # estimator, |
| 94 | + # subject, |
| 95 | + # metrics, |
| 96 | + # data_args, |
| 97 | + # estimator_args, |
| 98 | + # random_state=42, |
| 99 | + # memory=memory, |
| 100 | + # n_jobs=n_jobs, |
| 101 | + # do_spatial_cv=do_spatial_cv, |
| 102 | + # estimator_extra_params=estimator_extra_params, |
| 103 | + # ) |
| 104 | + # results = benchmark.run(nruns=nruns) |
| 105 | + # df_results.append(results) |
| 106 | + # # save results |
| 107 | + # data_path = Path("bsi_zoo/data/updated_alpha_grid") |
| 108 | + # data_path.mkdir(exist_ok=True) |
| 109 | + # if do_spatial_cv: |
| 110 | + # FILE_NAME = f"{estimator}_{subject}_{data_args['orientation_type'][0]}_spatialCV_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
| 111 | + # else: |
| 112 | + # FILE_NAME = f"{estimator}_{subject}_{data_args['orientation_type'][0]}_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
| 113 | + # results.to_pickle(data_path / FILE_NAME) |
| 114 | + |
| 115 | + |
| 116 | + # df_results = pd.concat(df_results, axis=0) |
| 117 | + |
| 118 | + # data_path = Path("bsi_zoo/data/ramen") |
| 119 | + # data_path.mkdir(exist_ok=True) |
| 120 | + # if do_spatial_cv: |
| 121 | + # FILE_NAME = f"benchmark_data_{subject}_{data_args['orientation_type'][0]}_spatialCV_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
| 122 | + # else: |
| 123 | + # FILE_NAME = f"benchmark_data_{subject}_{data_args['orientation_type'][0]}_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
| 124 | + # df_results.to_pickle(data_path / FILE_NAME) |
| 125 | + |
| 126 | + # print(df_results) |
| 127 | + |
| 128 | + """ Free orientation parameters for the benchmark """ |
| 129 | + |
| 130 | + orientation_type = "free" |
53 | 131 | data_args_I = {
|
54 |
| - # "n_sensors": [50], |
| 132 | + "n_sensors": [50], |
55 | 133 | "n_times": [10],
|
56 |
| - # "n_sources": [200], |
| 134 | + "n_sources": [200], |
57 | 135 | "nnz": nnzs,
|
58 | 136 | "cov_type": ["diag"],
|
59 | 137 | "path_to_leadfield": [get_leadfield_path(subject, type=orientation_type)],
|
|
62 | 140 | }
|
63 | 141 |
|
64 | 142 | data_args_II = {
|
65 |
| - # "n_sensors": [50], |
| 143 | + "n_sensors": [50], |
66 | 144 | "n_times": [10],
|
67 |
| - # "n_sources": [200], |
| 145 | + "n_sources": [200], |
68 | 146 | "nnz": nnzs,
|
69 | 147 | "cov_type": ["full"],
|
70 | 148 | "path_to_leadfield": [get_leadfield_path(subject, type=orientation_type)],
|
|
73 | 151 | }
|
74 | 152 |
|
75 | 153 | estimators = [
|
76 |
| - (fake_solver, data_args_I, {"alpha": estimator_alphas}, {}), |
77 |
| - # (eloreta, data_args_I, {"alpha": estimator_alphas}, {}), |
78 |
| - # (iterative_L1, data_args_I, {"alpha": estimator_alphas}, {}), |
79 |
| - # (iterative_L2, data_args_I, {"alpha": estimator_alphas}, {}), |
80 |
| - # (iterative_sqrt, data_args_I, {"alpha": estimator_alphas}, {}), |
81 |
| - # (iterative_L1_typeII, data_args_II, {"alpha": estimator_alphas}, {}), |
82 |
| - # (iterative_L2_typeII, data_args_II, {"alpha": estimator_alphas}, {}), |
83 |
| - # (gamma_map, data_args_II, {"alpha": estimator_alphas}, {"update_mode": 1}), |
84 |
| - # (gamma_map, data_args_II, {"alpha": estimator_alphas}, {"update_mode": 2}), |
85 |
| - # (gamma_map, data_args_II, {"alpha": estimator_alphas}, {"update_mode": 3}), |
| 154 | + # (fake_solver, data_args_I, {"alpha": estimator_alphas_I}, {}), |
| 155 | + (eloreta, data_args_I, {"alpha": estimator_alphas_II}, {}), |
| 156 | + # (iterative_L1, data_args_I, {"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}, {}), |
| 161 | + # (gamma_map, data_args_II, {"alpha": estimator_alphas_I}, {"update_mode": 1}), |
| 162 | + # (gamma_map, data_args_II, {"alpha": estimator_alphas_II}, {"update_mode": 2}), |
| 163 | + # (gamma_map, data_args_II, {"alpha": estimator_alphas_I}, {"update_mode": 3}), |
86 | 164 | ]
|
87 | 165 |
|
88 | 166 | df_results = []
|
|
102 | 180 | results = benchmark.run(nruns=nruns)
|
103 | 181 | df_results.append(results)
|
104 | 182 | # save results
|
105 |
| - data_path = Path("bsi_zoo/data") |
| 183 | + data_path = Path("bsi_zoo/data/eloreta") |
106 | 184 | data_path.mkdir(exist_ok=True)
|
107 |
| - FILE_NAME = f"{estimator}_{subject}_{data_args['orientation_type'][0]}_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
| 185 | + |
| 186 | + if do_spatial_cv: |
| 187 | + FILE_NAME = f"{estimator}_{subject}_{data_args['orientation_type'][0]}_spatialCV_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
| 188 | + else: |
| 189 | + FILE_NAME = f"{estimator}_{subject}_{data_args['orientation_type'][0]}_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
108 | 190 | results.to_pickle(data_path / FILE_NAME)
|
| 191 | + print(results) |
109 | 192 |
|
110 | 193 | df_results = pd.concat(df_results, axis=0)
|
111 | 194 |
|
112 |
| - data_path = Path("bsi_zoo/data") |
| 195 | + data_path = Path("bsi_zoo/data/eloreta") |
113 | 196 | data_path.mkdir(exist_ok=True)
|
114 | 197 | if do_spatial_cv:
|
115 | 198 | FILE_NAME = f"benchmark_data_{subject}_{data_args['orientation_type'][0]}_spatialCV_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl"
|
|
119 | 202 |
|
120 | 203 | print(df_results)
|
121 | 204 |
|
122 |
| - # """ Free orientation parameters for the benchmark """ |
123 |
| - |
124 |
| - # orientation_type = "free" |
125 |
| - # data_args_I = { |
126 |
| - # "n_sensors": [50], |
127 |
| - # "n_times": [10], |
128 |
| - # "n_sources": [200], |
129 |
| - # "nnz": nnzs, |
130 |
| - # "cov_type": ["diag"], |
131 |
| - # "path_to_leadfield": [get_leadfield_path(subject, type=orientation_type)], |
132 |
| - # "orientation_type": [orientation_type], |
133 |
| - # "alpha": alpha_SNR, # this is actually SNR |
134 |
| - # } |
135 |
| - |
136 |
| - # data_args_II = { |
137 |
| - # "n_sensors": [50], |
138 |
| - # "n_times": [10], |
139 |
| - # "n_sources": [200], |
140 |
| - # "nnz": nnzs, |
141 |
| - # "cov_type": ["full"], |
142 |
| - # "path_to_leadfield": [get_leadfield_path(subject, type=orientation_type)], |
143 |
| - # "orientation_type": [orientation_type], |
144 |
| - # "alpha": alpha_SNR, # this is actually SNR |
145 |
| - # } |
146 |
| - |
147 |
| - # estimators = [ |
148 |
| - # (fake_solver, data_args_I, {"alpha": estimator_alphas}, {}), |
149 |
| - # (eloreta, data_args_I, {"alpha": estimator_alphas}, {}), |
150 |
| - # (iterative_L1, data_args_I, {"alpha": estimator_alphas}, {}), |
151 |
| - # (iterative_L2, data_args_I, {"alpha": estimator_alphas}, {}), |
152 |
| - # (iterative_sqrt, data_args_I, {"alpha": estimator_alphas}, {}), |
153 |
| - # (iterative_L1_typeII, data_args_II, {"alpha": estimator_alphas}, {}), |
154 |
| - # (iterative_L2_typeII, data_args_II, {"alpha": estimator_alphas}, {}), |
155 |
| - # # (gamma_map, data_args_II, {"alpha": estimator_alphas}, {"update_mode": 1}), |
156 |
| - # (gamma_map, data_args_II, {"alpha": estimator_alphas}, {"update_mode": 2}), |
157 |
| - # # (gamma_map, data_args_II, {"alpha": estimator_alphas}, {"update_mode": 3}), |
158 |
| - # ] |
159 |
| - |
160 |
| - # df_results = [] |
161 |
| - # for estimator, data_args, estimator_args, estimator_extra_params in estimators: |
162 |
| - # benchmark = Benchmark( |
163 |
| - # estimator, |
164 |
| - # subject, |
165 |
| - # metrics, |
166 |
| - # data_args, |
167 |
| - # estimator_args, |
168 |
| - # random_state=42, |
169 |
| - # memory=memory, |
170 |
| - # n_jobs=n_jobs, |
171 |
| - # do_spatial_cv=do_spatial_cv, |
172 |
| - # estimator_extra_params=estimator_extra_params, |
173 |
| - # ) |
174 |
| - # results = benchmark.run(nruns=nruns) |
175 |
| - # df_results.append(results) |
176 |
| - # # save results |
177 |
| - # data_path = Path("bsi_zoo/data") |
178 |
| - # data_path.mkdir(exist_ok=True) |
179 |
| - # FILE_NAME = f"{estimator}_{subject}_{data_args['orientation_type'][0]}_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
180 |
| - # results.to_pickle(data_path / FILE_NAME) |
181 |
| - |
182 |
| - # df_results = pd.concat(df_results, axis=0) |
183 |
| - |
184 |
| - # data_path = Path("bsi_zoo/data") |
185 |
| - # data_path.mkdir(exist_ok=True) |
186 |
| - # if do_spatial_cv: |
187 |
| - # FILE_NAME = f"benchmark_data_{subject}_{data_args['orientation_type'][0]}_spatialCV_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
188 |
| - # else: |
189 |
| - # FILE_NAME = f"benchmark_data_{subject}_{data_args['orientation_type'][0]}_{time.strftime('%b-%d-%Y_%H%M', time.localtime())}.pkl" |
190 |
| - # df_results.to_pickle(data_path / FILE_NAME) |
191 |
| - |
192 |
| - # print(df_results) |
|
0 commit comments