make eod calculation more lightweight, save/load results to a file
This commit is contained in:
parent
dbd28a7bd3
commit
3faabb353b
17
CellData.py
17
CellData.py
@ -264,15 +264,22 @@ class CellData:
|
||||
self.recording_times = self.parser.get_recording_times()
|
||||
return self.recording_times[3]
|
||||
|
||||
def get_eod_frequency(self):
|
||||
def get_eod_frequency(self, recalculate=False):
|
||||
eod_freq_file_name = "eod_freq_peak_based.npy"
|
||||
eod_freq_file_path = os.path.join(self.get_data_path(), eod_freq_file_name)
|
||||
if os.path.exists(eod_freq_file_path) and not recalculate:
|
||||
print("Loaded eod_freq from file")
|
||||
return np.load(eod_freq_file_path)
|
||||
else:
|
||||
eods = self.get_base_traces(self.EOD)
|
||||
sampling_interval = self.get_sampling_interval()
|
||||
frequencies = []
|
||||
for eod in eods:
|
||||
time = np.arange(0, len(eod) * sampling_interval, sampling_interval)
|
||||
frequencies.append(hf.calculate_eod_frequency(time, eod))
|
||||
|
||||
return np.mean(frequencies)
|
||||
frequencies.append(hf.calculate_eod_frequency(eod, sampling_interval))
|
||||
mean_freq = np.mean(frequencies)
|
||||
np.save(eod_freq_file_path, mean_freq)
|
||||
print("Saved eod freq to file.")
|
||||
return mean_freq
|
||||
|
||||
def __read_fi_spiketimes_info__(self):
|
||||
if self.fi_spiketimes is None:
|
||||
|
Loading…
Reference in New Issue
Block a user