-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
134 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# | ||
# Created: 2019-01-22 09:07:47 | ||
# Last modified by: Stefan Fuertinger [[email protected]] | ||
# Last modification time: <2019-10-09 12:09:31> | ||
# Last modification time: <2019-10-10 11:10:29> | ||
|
||
# Builtin/3rd party package imports | ||
import numpy as np | ||
|
@@ -217,7 +217,7 @@ def freqanalysis(data, method='mtmfft', output='fourier', | |
# Construct array of maximally attainable frequencies | ||
minTrialLength = minSampleNum/data.samplerate | ||
nFreq = int(np.floor(minSampleNum / 2) + 1) | ||
freqs = np.arange(nFreq) | ||
freqs = np.linspace(0, data.samplerate / 2, nFreq) | ||
|
||
# Match desired frequencies as close as possible to actually attainable freqs | ||
if foi is not None: | ||
|
@@ -230,7 +230,12 @@ def freqanalysis(data, method='mtmfft', output='fourier', | |
foi.sort() | ||
foi = foi[foi <= freqs.max()] | ||
foi = foi[foi >= freqs.min()] | ||
foi = freqs[np.unique(np.searchsorted(freqs, foi, side="right") - 1)] | ||
fidx = np.searchsorted(freqs, foi, side="left") | ||
for k, fid in enumerate(fidx): | ||
if np.abs(freqs[fid - 1] - foi[k]) < np.abs(freqs[fid] - foi[k]): | ||
fidx[k] = fid -1 | ||
fidx = np.unique(fidx) | ||
foi = freqs[fidx] | ||
else: | ||
foi = freqs | ||
|
||
|
@@ -312,7 +317,8 @@ def freqanalysis(data, method='mtmfft', output='fourier', | |
log_dct["nTaper"] = nTaper | ||
|
||
# Set up compute-kernel | ||
specestMethod = MultiTaperFFT(nTaper=nTaper, | ||
specestMethod = MultiTaperFFT(1 / data.samplerate, | ||
nTaper=nTaper, | ||
timeAxis=timeAxis, | ||
taper=taper, | ||
taperopt=taperopt, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# | ||
# Created: 2019-09-02 14:25:34 | ||
# Last modified by: Stefan Fuertinger [[email protected]] | ||
# Last modification time: <2019-10-09 12:12:19> | ||
# Last modification time: <2019-10-10 11:11:12> | ||
|
||
# Builtin/3rd party package imports | ||
import numpy as np | ||
|
@@ -19,7 +19,7 @@ | |
|
||
# Local workhorse that performs the computational heavy lifting | ||
@unwrap_io | ||
def mtmfft(trl_dat, nTaper=1, timeAxis=0, | ||
def mtmfft(trl_dat, dt, nTaper=1, timeAxis=0, | ||
taper=spwin.hann, taperopt={}, tapsmofrq=None, | ||
pad="nextpow2", padtype="zero", padlength=None, foi=None, | ||
keeptapers=True, polyorder=None, output_fmt="pow", | ||
|
@@ -30,6 +30,8 @@ def mtmfft(trl_dat, nTaper=1, timeAxis=0, | |
---------- | ||
trl_dat : 2D :class:`numpy.ndarray` | ||
Multi-channel uniformly sampled time-series | ||
dt : float | ||
sampling interval (between 0 and 1) | ||
nTaper : int | ||
number of filter windows to use | ||
timeAxis : int | ||
|
@@ -88,16 +90,17 @@ def mtmfft(trl_dat, nTaper=1, timeAxis=0, | |
nFreq = int(np.floor(nSamples / 2) + 1) | ||
fidx = slice(None) | ||
if foi is not None: | ||
freqs = np.arange(nFreq) | ||
freqs = np.linspace(0, 1 /(2 * dt), nFreq) | ||
foi = foi[foi <= freqs.max()] | ||
foi = foi[foi >= freqs.min()] | ||
fidx = np.searchsorted(freqs, foi, side="right") - 1 | ||
fidx = np.searchsorted(freqs, foi, side="left") | ||
for k, fid in enumerate(fidx): | ||
if np.abs(freqs[fid - 1] - foi[k]) < np.abs(freqs[fid] - foi[k]): | ||
fidx[k] = fid -1 | ||
fidx = np.unique(fidx) | ||
nFreq = fidx.size | ||
outShape = (1, max(1, nTaper * keeptapers), nFreq, nChannels) | ||
|
||
# For initialization of computational routine, just return output shape and dtype | ||
if noCompute: | ||
return outShape, freq.spectralDTypes[output_fmt] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.