|
31 | 31 | from ...utils.compat3 import open4csv
|
32 | 32 |
|
33 | 33 | from .hemodynamic_models import compute_regressor, _orthogonalize
|
| 34 | +from .realfuncs import dct_ii_cut_basis |
34 | 35 |
|
35 | 36 |
|
36 | 37 | ######################################################################
|
@@ -63,37 +64,7 @@ def _poly_drift(order, frametimes):
|
63 | 64 |
|
64 | 65 |
|
65 | 66 | def _cosine_drift(period_cut, frametimes):
|
66 |
| - """Create a cosine drift matrix with periods greater or equals to period_cut |
67 |
| -
|
68 |
| - Parameters |
69 |
| - ---------- |
70 |
| - period_cut: float |
71 |
| - Cut period of the low-pass filter (in sec) |
72 |
| - frametimes: array of shape(nscans) |
73 |
| - The sampling times (in sec) |
74 |
| -
|
75 |
| - Returns |
76 |
| - ------- |
77 |
| - cdrift: array of shape(n_scans, n_drifts) |
78 |
| - cosin drifts plus a constant regressor at cdrift[:,0] |
79 |
| -
|
80 |
| - Ref: http://en.wikipedia.org/wiki/Discrete_cosine_transform DCT-II |
81 |
| - """ |
82 |
| - len_tim = len(frametimes) |
83 |
| - n_times = np.arange(len_tim) |
84 |
| - hfcut = 1./ period_cut # input parameter is the period |
85 |
| - |
86 |
| - dt = frametimes[1] - frametimes[0] # frametimes.max() should be (len_tim-1)*dt |
87 |
| - order = int(np.floor(2*len_tim*hfcut*dt)) # s.t. hfcut = 1/(2*dt) yields len_tim |
88 |
| - cdrift = np.zeros((len_tim, order)) |
89 |
| - nfct = np.sqrt(2.0/len_tim) |
90 |
| - |
91 |
| - for k in range(1, order): |
92 |
| - cdrift[:,k-1] = nfct * np.cos((np.pi/len_tim)*(n_times + .5)*k) |
93 |
| - |
94 |
| - cdrift[:,order-1] = 1. # or 1./sqrt(len_tim) to normalize |
95 |
| - return cdrift |
96 |
| - |
| 67 | + return dct_ii_cut_basis(frametimes, period_cut) |
97 | 68 |
|
98 | 69 |
|
99 | 70 | def _blank_drift(frametimes):
|
|
0 commit comments