|
7 | 7 | import ncpi |
8 | 8 |
|
9 | 9 | # Folder with parameters of LIF model simulations |
10 | | -sys.path.append(os.path.join(os.path.dirname(__file__), '../../simulation/Hagen_model/simulation/params')) |
| 10 | +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'simulation', 'Hagen_model', 'simulation', 'params')) |
11 | 11 |
|
12 | 12 | # Path to the folder with prediction results |
13 | | -pred_results = '../data' |
| 13 | +pred_results = os.path.join('..', 'data') |
14 | 14 |
|
15 | 15 | # Calculate new firing rates (True) or load them from file if they already exist (False). If firing rates do not |
16 | 16 | # exist, they will not be plotted. |
17 | 17 | compute_firing_rate = False |
18 | 18 |
|
19 | 19 | # Path to saved firing rates |
20 | | -fr_path = './data' |
| 20 | +fr_path = os.path.join('.', 'data') |
21 | 21 |
|
22 | 22 | # Number of samples to draw from the predictions for computing the firing rates |
23 | 23 | n_samples = 50 |
|
118 | 118 | LIF_params['J_ext'] = J_ext |
119 | 119 |
|
120 | 120 | # Create a Simulation object |
121 | | - sim = ncpi.Simulation(param_folder='../../simulation/Hagen_model/simulation/params', |
122 | | - python_folder='../../simulation/Hagen_model/simulation/python', |
123 | | - output_folder='../../simulation/Hagen_model/simulation/output') |
| 121 | + sim = ncpi.Simulation(param_folder = os.path.join('../../simulation/Hagen_model/simulation/params'), |
| 122 | + python_folder = os.path.join('../../simulation/Hagen_model/simulation/python'), |
| 123 | + output_folder = os.path.join('../../simulation/Hagen_model/simulation/output')) |
124 | 124 |
|
125 | 125 | # Save parameters to a pickle file |
126 | | - with open(os.path.join('../../simulation/Hagen_model/simulation/output', 'network.pkl'), 'wb') as f: |
| 126 | + with open(os.path.join('..', '..', 'simulation', 'Hagen_model', 'simulation', 'output', 'network.pkl'), 'wb') as f: |
127 | 127 | pickle.dump(LIF_params, f) |
128 | 128 |
|
129 | 129 | # Run the simulation |
130 | 130 | sim.simulate('simulation.py', 'simulation_params.py') |
131 | 131 |
|
132 | 132 | # Load spike times |
133 | | - with open(os.path.join('../../simulation/Hagen_model/simulation/output', 'times.pkl'), 'rb') as f: |
| 133 | + with open(os.path.join('..', '..', 'simulation', 'Hagen_model', 'simulation', 'output', 'times.pkl'), 'rb') as f: |
134 | 134 | times = pickle.load(f) |
135 | 135 |
|
136 | 136 | # Load tstop |
137 | | - with open(os.path.join('../../simulation/Hagen_model/simulation/output', 'tstop.pkl'), 'rb') as f: |
| 137 | + with open(os.path.join('..', '..', 'simulation', 'Hagen_model', 'simulation', 'output', 'tstop.pkl'), 'rb') as f: |
138 | 138 | tstop = pickle.load(f) |
139 | 139 |
|
140 | 140 | # Transient period |
|
155 | 155 | if compute_firing_rate: |
156 | 156 | if not os.path.exists('data'): |
157 | 157 | os.makedirs('data') |
158 | | - with open('data/firing_rates_preds.pkl', 'wb') as f: |
| 158 | + with open('data', 'firing_rates_preds.pkl', 'wb') as f: |
159 | 159 | pickle.dump(firing_rates, f) |
160 | | - with open('data/IDs.pkl', 'wb') as f: |
| 160 | + with open('data', 'IDs.pkl', 'wb') as f: |
161 | 161 | pickle.dump(IDs, f) |
162 | 162 | else: |
163 | 163 | try: |
164 | | - with open(os.path.join(fr_path,'firing_rates_preds.pkl'), 'rb') as f: |
| 164 | + with open(os.path.join(fr_path, 'firing_rates_preds.pkl'), 'rb') as f: |
165 | 165 | firing_rates = pickle.load(f) |
166 | | - with open(os.path.join(fr_path,'IDs.pkl'), 'rb') as f: |
| 166 | + with open(os.path.join(fr_path, 'IDs.pkl'), 'rb') as f: |
167 | 167 | IDs = pickle.load(f) |
168 | 168 | except FileNotFoundError: |
169 | 169 | print('Firing rates not found.') |
|
383 | 383 | ax.text(0.5, 0.49, y_labels[1], color = 'blue', alpha = 0.5, fontsize = 10, ha='center') |
384 | 384 |
|
385 | 385 | # Save the figure |
386 | | -plt.savefig('LFP_predictions.png', bbox_inches='tight') |
| 386 | +plt.savefig(f'LFP_predictions_{statistical_analysis}.png', bbox_inches='tight') |
387 | 387 | # plt.show() |
0 commit comments