[useful_functions.py] added sam_spectrum function
This commit is contained in:
		
							parent
							
								
									8f5c2f65e6
								
							
						
					
					
						commit
						732f4d39a9
					
				| @ -399,6 +399,39 @@ def sam_data(sam): | |||||||
|     avg_dur = np.mean(durations) |     avg_dur = np.mean(durations) | ||||||
|     return avg_dur, sam_amp, sam_am, sam_df, sam_eodf, sam_nyquist, sam_stim |     return avg_dur, sam_amp, sam_am, sam_df, sam_eodf, sam_nyquist, sam_stim | ||||||
| 
 | 
 | ||||||
|  | def sam_spectrum(sam): | ||||||
|  |     """ | ||||||
|  |     Creates a power spectrum for a ReproRun of a SAM. | ||||||
|  | 
 | ||||||
|  |     Parameters | ||||||
|  |     ---------- | ||||||
|  |     sam : ReproRun Object | ||||||
|  |         The Reprorun the powerspectrum should be generated from. | ||||||
|  | 
 | ||||||
|  |     Returns | ||||||
|  |     ------- | ||||||
|  |     sam_frequency : np.array | ||||||
|  |         The frequencies of the powerspectrum. | ||||||
|  |     sam_power : np.array | ||||||
|  |         The powers of the frequencies. | ||||||
|  | 
 | ||||||
|  |     """ | ||||||
|  |     stimuli = sam.stimuli | ||||||
|  |     # lists for the power spectra | ||||||
|  |     frequencies = [] | ||||||
|  |     powers = [] | ||||||
|  |     # loop over the stimuli | ||||||
|  |     for stimulus in stimuli: | ||||||
|  |         # get the powerspectrum for each stimuli | ||||||
|  |         frequency, power = power_spectrum(stimulus) | ||||||
|  |         # append the power spectrum data | ||||||
|  |         frequencies.append(frequency) | ||||||
|  |         powers.append(power) | ||||||
|  |     #average over the stimuli | ||||||
|  |     sam_frequency = np.mean(frequencies, axis = 0) | ||||||
|  |     sam_power = np.mean(powers, axis = 0) | ||||||
|  |     return sam_frequency, sam_power | ||||||
|  | 
 | ||||||
| def spike_times(stim): | def spike_times(stim): | ||||||
|     """ |     """ | ||||||
|     Reads out the spike times and other necessary parameters |     Reads out the spike times and other necessary parameters | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user