-
Notifications
You must be signed in to change notification settings - Fork 17
Description
-
processing_data.high_gamma_estimationrecomputes the spectral decomposition bands, even if they have already been computed inprocessing_data.spectral_decomposition. It would be nice if the code would check to see if they have been run already, and use the precomputed bands if possible. If it is computing new bands, it would make sense to append these to the existing decomposition table (or make a new decomposition table?) to save the processing. -
The spectral decomposition code is copy and pasted between
processing_data.spectral_decompositionandprocessing_data.high_gamma_estimation:
ecogVIS/ecogvis/signal_processing/processing_data.py
Lines 377 to 397 in a5eda73
nBands = len(band_param_0) nSamples = lfp.data.shape[0] nChannels = lfp.data.shape[1] Xp = np.zeros((nBands, nChannels, nSamples)) # power (nBands,nChannels,nSamples) # Apply Hilbert transform --------------------------------------------- print('Running Spectral Decomposition...') start = time.time() for ch in np.arange(nChannels): Xch = lfp.data[:, ch] * 1e6 # 1e6 scaling helps with numerical accuracy Xch = Xch.reshape(1, -1) Xch = Xch.astype('float32') # signal (nChannels,nSamples) X_fft_h = None for ii, (bp0, bp1) in enumerate(zip(band_param_0, band_param_1)): kernel = gaussian(Xch.shape[-1], rate, bp0, bp1) X_analytic, X_fft_h = hilbert_transform(Xch, rate, kernel, phase=None, X_fft_h=X_fft_h) Xp[ii, ch, :] = abs(X_analytic).astype('float32') print('Spectral Decomposition finished in {} seconds'.format(time.time() - start)) # data: (ndarray) dims: num_times * num_channels * num_bands Xp = np.swapaxes(Xp, 0, 2)
ecogVIS/ecogvis/signal_processing/processing_data.py
Lines 467 to 488 in a5eda73
nBands = len(band_param_0) nSamples = lfp.data.shape[0] nChannels = lfp.data.shape[1] Xp = np.zeros((nBands, nChannels, nSamples)) # power (nBands,nChannels,nSamples) # Apply Hilbert transform --------------------------------------------- print('Running High Gamma estimation...') start = time.time() for ch in np.arange(nChannels): Xch = lfp.data[:, ch] * 1e6 # 1e6 scaling helps with numerical accuracy Xch = Xch.reshape(1, -1) Xch = Xch.astype('float32') # signal (nChannels,nSamples) X_fft_h = None for ii, (bp0, bp1) in enumerate(zip(band_param_0, band_param_1)): kernel = gaussian(Xch.shape[-1], rate, bp0, bp1) X_analytic, X_fft_h = hilbert_transform( Xch, rate, kernel, phase=None, X_fft_h=X_fft_h) Xp[ii, ch, :] = abs(X_analytic).astype('float32') print('High Gamma estimation finished in {} seconds'.format(time.time() - start)) # data: (ndarray) dims: num_times * num_channels * num_bands Xp = np.swapaxes(Xp, 0, 2)
(I can look into writing a PR for this when I have some time)