changes
This commit is contained in:
		
							parent
							
								
									65fe9db570
								
							
						
					
					
						commit
						efc79f9d07
					
				| @ -3,7 +3,7 @@ import nixio as nix | ||||
| import os | ||||
| from numpy.core.fromnumeric import repeat | ||||
| from traitlets.traitlets import Instance | ||||
| from chirp_ams import get_signals | ||||
| from chirp_ams import get_signals, other_freq, other_signal, self_freq | ||||
| from model import simulate, load_models | ||||
| from IPython import embed | ||||
| import matplotlib.pyplot as plt | ||||
| @ -21,8 +21,7 @@ def append_settings(section, sec_name, sec_type, settings): | ||||
|                 section[k] = settings[k] | ||||
| 
 | ||||
|      | ||||
| def save(filename, name, stimulus_settings, model_settings, stimulus, responses, overwrite=False): | ||||
|     print("saving! ", filename, name) | ||||
| def save(filename, name, stimulus_settings, model_settings, self_signal, other_signal, self_freq, other_freq, complete_stimulus, responses, overwrite=False): | ||||
|     if os.path.exists(filename) and not overwrite: | ||||
|         nf = nix.File.open(filename, nix.FileMode.ReadWrite) | ||||
|     else: | ||||
| @ -40,8 +39,8 @@ def save(filename, name, stimulus_settings, model_settings, stimulus, responses, | ||||
|     b.metadata = mdata | ||||
|      | ||||
|     # save stimulus | ||||
|     stim_da = b.create_data_array("stimulus", "nix.timeseries.sampled", dtype=nix.DataType.Float, | ||||
|                                   data=stimulus) | ||||
|     stim_da = b.create_data_array("complete_stimulus", "nix.timeseries.sampled", dtype=nix.DataType.Float, | ||||
|                                   data=complete_stimulus) | ||||
|     stim_da.label = "voltage" | ||||
|     stim_da.label = "mv/cm" | ||||
|     dim = stim_da.append_sampled_dimension(model_settings["deltat"]) | ||||
| @ -56,22 +55,18 @@ def save(filename, name, stimulus_settings, model_settings, stimulus, responses, | ||||
|         da.unit = "s" | ||||
|         dim = da.append_range_dimension() | ||||
|         dim.link_data_array(da, [-1]) | ||||
|          | ||||
|      | ||||
|     nf.close() | ||||
|     pass | ||||
| 
 | ||||
| 
 | ||||
| def plot_responses(): | ||||
|     pass | ||||
| 
 | ||||
| 
 | ||||
| def simulate_responses(stimulus_params, model_params, repeats=10): | ||||
| def simulate_responses(stimulus_params, model_params, repeats=10, deltaf=20): | ||||
|     cell_params = model_params.copy() | ||||
|     cell = cell_params["cell"] | ||||
|     del cell_params["cell"] | ||||
|     del cell_params["EODf"] | ||||
|     for c in stimulus_params["contrasts"]: | ||||
|         print("creating stimuli\n\tcontrast: ", str(c), "\t condition: ",  | ||||
|               stimulus_params["condition"]) | ||||
|         print("\t\tcreating stimuli ... ") | ||||
|         params = stimulus_params.copy() | ||||
|         del params["contrasts"] | ||||
|         del params["chirp_frequency"] | ||||
| @ -79,20 +74,27 @@ def simulate_responses(stimulus_params, model_params, repeats=10): | ||||
|         time, self_signal, self_freq, other_signal, other_freq = get_signals(**params) | ||||
|         signal = (self_signal + other_signal) | ||||
|         signal /= np.max(signal) | ||||
|         print("create p-unit responses for cell: ", cell) | ||||
|         print("\t\tcreating p-unit responses ...") | ||||
|          | ||||
|         spikes = [] | ||||
|         no_other_spikes = [] | ||||
|         for r in range(repeats): | ||||
|             spikes.append(simulate(signal, **cell_params)) | ||||
|         save("test.nix", "contrast_%.3f_condition_%s" %(c, stimulus_params["condition"]), params, | ||||
|              cell_params, signal, spikes) | ||||
|             no_other_spikes.append(simulate, self_signal)) | ||||
|         print("\t\tsaving ...") | ||||
|         save("cell_%s.nix" % cell, "contrast_%.3f_condition_%s_deltaf_%i" %(c, stimulus_params["condition"], deltaf), params, | ||||
|              cell_params, self_signal, other_signal, self_freq, other_freq, signal, spikes) | ||||
| 
 | ||||
| 
 | ||||
| def main(): | ||||
|     cell_id = 20 | ||||
|     models = load_models("models.csv") | ||||
|     deltaf = 20.  # Hz, difference frequency between self and other | ||||
|     deltafs = [-200, -100, -20, 20, 100, 200]  # Hz, difference frequency between self and other | ||||
|      | ||||
|     for cell_id in range(len(models)): | ||||
|         model_params = models[cell_id] | ||||
|         print("Cell: %s" % model_params["cell"]) | ||||
|         for deltaf in deltafs: | ||||
|             print("\t Deltaf: %i" % deltaf) | ||||
|             stimulus_params = {"eodfs": {"self": model_params["EODf"], | ||||
|                                         "other": model_params["EODf"] + deltaf}, | ||||
|                             "contrasts": [20, 10, 5, 2.5, 1.25, 0.625, 0.3125], | ||||
| @ -110,10 +112,10 @@ def main(): | ||||
|             conditions = ["other", "self"] | ||||
|          | ||||
|             for c in conditions: | ||||
|                 print("\t\tcondition: %s" % c) | ||||
|                 stimulus_params["condition"] = c | ||||
|         simulate_responses(stimulus_params, model_params, repeats=25) | ||||
|     pass | ||||
| 
 | ||||
|                 simulate_responses(stimulus_params, model_params, repeats=25, | ||||
|                                    deltaf=deltaf) | ||||
|      | ||||
| if __name__ == "__main__": | ||||
|     main() | ||||
							
								
								
									
										9
									
								
								response_discriminability.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								response_discriminability.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| import nixio as nix | ||||
| import matplotlib.pyplot as plt | ||||
| 
 | ||||
| 
 | ||||
| def main(): | ||||
|     pass | ||||
| 
 | ||||
| if __name__ == "__main__": | ||||
|     main() | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user