Skip to content

Commit ac41696

Browse files
mariomario
authored andcommitted
corrected convolution
1 parent 3189d76 commit ac41696

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

code/python/cni_toolbox/HGR.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,4 +413,8 @@ def __convolution__(self, x):
413413
x = np.vstack((x, np.zeros((np.ceil(self.l_hrf / self.p_sampling).astype(int),
414414
self.n_features))))
415415
x_conv = ifft(fft(x) * fft(kernel))
416+
x_conv = np.abs(
417+
ifft(fft(x, axis=0) *
418+
np.expand_dims(fft(kernel),
419+
axis=1), axis=0))
416420
return x_conv[:n_samples]

code/python/cni_toolbox/gadgets.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,10 @@ def convolve(self, x):
199199
convolved sample
200200
'''
201201

202-
x_fft = fft(np.vstack((x, np.zeros((self.l_subsampled, self.n_channels)))))
203-
self.conv_x = np.vstack((self.conv_x, np.zeros(self.n_channels)))
204-
self.conv_x[self.step:self.step + self.l_subsampled, :] += ifft(
205-
x_fft * self.kernel_fft)
202+
x_fft = fft(np.vstack((x, np.zeros((self.l_subsampled, self.n_channels)))), axis=0)
203+
self.conv_x = np.append(self.conv_x, np.zeros(self.n_channels))
204+
self.conv_x[self.step:self.step + self.l_subsampled, :] += np.abs(ifft(
205+
x_fft * np.expand_dims(self.kernel_fft , axis=1), axis=0))
206206

207207
return self.conv_x[self.step, :]
208208

0 commit comments

Comments
 (0)