Skip to content

Commit 3e2d191

Browse files
mariomario
authored andcommitted
improved handling of individual hrfs | corrected progress bar
1 parent fbb6820 commit 3e2d191

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

code/python/cni_toolbox/pRF.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self, parameters, hrf=None):
7777

7878
if hrf is not None:
7979
self.l_hrf = hrf.shape[0]
80-
if hrf.ndim > 2:
80+
if hrf.ndim > 1:
8181
hrf = np.reshape(hrf, (self.l_hrf, self.n_total))
8282
self.hrf_fft = fft(np.vstack((hrf,
8383
np.zeros((self.n_samples,
@@ -148,7 +148,7 @@ def set_hrf(self, hrf):
148148
hemodynamic response function
149149
'''
150150
self.l_hrf = hrf.shape[0]
151-
if hrf.ndim > 2:
151+
if hrf.ndim > 1:
152152
hrf = np.reshape(hrf, (self.l_hrf, self.n_total))
153153
self.hrf_fft = fft(np.vstack((hrf,
154154
np.zeros((self.n_samples,
@@ -160,16 +160,20 @@ def set_hrf(self, hrf):
160160
axis=0)
161161

162162
def set_stimulus(self, stimulus):
163-
self.stimulus = np.zeros((self.n_samples + self.l_hrf,
164-
self.n_total))
163+
'''
164+
Parameters
165+
----------
166+
stimulus : floating point array
167+
'''
165168
if stimulus.ndim == 3:
166-
self.stimulus[0:self.n_samples, :] = np.reshape(
169+
self.stimulus = np.reshape(
167170
stimulus, (self.r_stimulus**2, self.n_samples))
168171
else:
169-
self.stimulus[0:self.n_samples, :] = stimulus
172+
self.stimulus = stimulus
173+
self.stimulus = np.hstack((self.stimulus,
174+
np.zeros((self.r_stimulus**2, self.l_hrf))))
170175

171176
def import_stimulus(self):
172-
173177
root = tk.Tk()
174178
stimulus_directory = ''.join(filedialog.askdirectory(
175179
title='Please select the stimulus directory'))
@@ -382,6 +386,9 @@ def mapping(self, data, threshold=100, mask=[]):
382386
self.slope[self.idx[idx_best, 2]]
383387

384388
i = int(m / n_voxels * 21)
389+
sys.stdout.write('\r')
390+
sys.stdout.write("[%-20s] %d%%"
391+
% ('=' * i, 5 * i))
385392

386393
for key in results:
387394
results[key] = np.squeeze(

0 commit comments

Comments
 (0)