Skip to content

Commit 79aee09

Browse files
committed
improved terminal printing
1 parent 01cd716 commit 79aee09

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

code/python/cni_toolbox/pRF.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import sys
2121
import cv2
2222
import glob
23+
import time
2324
import numpy as np
2425
import tkinter as tk
2526
from tkinter import filedialog
@@ -273,6 +274,8 @@ def create_timecourses(self, max_radius = 10.0, n_xy = 30,
273274

274275
W = np.zeros((self.n_points,
275276
self.w_stimulus * self.h_stimulus))
277+
start = time.time()
278+
print('\ncreating timecourses')
276279
for p in range(self.n_points):
277280
x = np.cos(self.pa[self.idx[p, 0]]) * self.ecc[self.idx[p, 1]]
278281
y = np.sin(self.pa[self.idx[p, 0]]) * self.ecc[self.idx[p, 1]]
@@ -281,13 +284,14 @@ def create_timecourses(self, max_radius = 10.0, n_xy = 30,
281284

282285
i = int(p / self.n_points * 19)
283286
sys.stdout.write('\r')
284-
sys.stdout.write("creating timecourses [%-20s] %d%%"
287+
sys.stdout.write("[%-20s] %d%%"
285288
% ('='*i, 5*i))
286289

287290
tc = np.matmul(W, self.stimulus).transpose()
288291
sys.stdout.write('\r')
289-
sys.stdout.write("creating timecourses [%-20s] %d%%\n" % ('='*20, 100))
290-
self.tc_fft = fft(tc, axis = 0)
292+
sys.stdout.write("[%-20s] %d%%" % ('='*20, 100))
293+
self.tc_fft = fft(tc, axis = 0)
294+
291295

292296
def mapping(self, data, threshold = 100, mask = []):
293297
'''
@@ -338,6 +342,8 @@ def mapping(self, data, threshold = 100, mask = []):
338342
'mu_y': np.zeros(self.n_total),
339343
'sigma': np.zeros(self.n_total)}
340344

345+
start = time.time()
346+
print('\nmapping receptive fields')
341347
if self.hrf_fft.ndim==1:
342348
tc = np.transpose(
343349
zscore(
@@ -366,7 +372,7 @@ def mapping(self, data, threshold = 100, mask = []):
366372

367373
i = int(m / n_voxels * 21)
368374
sys.stdout.write('\r')
369-
sys.stdout.write("pRF mapping [%-20s] %d%%"
375+
sys.stdout.write("[%-20s] %d%%"
370376
% ('='*i, 5*i))
371377

372378
else:
@@ -397,11 +403,7 @@ def mapping(self, data, threshold = 100, mask = []):
397403
results['sigma'][v] = self.ecc[self.idx[idx_best, 1]] * \
398404
self.slope[self.idx[idx_best, 2]]
399405

400-
i = int(m / n_voxels * 21)
401-
sys.stdout.write('\r')
402-
sys.stdout.write("pRF mapping [%-20s] %d%%"
403-
% ('='*i, 5*i))
404-
406+
i = int(m / n_voxels * 21)
405407

406408
for key in results:
407409
results[key] = np.squeeze(
@@ -414,7 +416,7 @@ def mapping(self, data, threshold = 100, mask = []):
414416
results['mu_y'] * 1j)
415417
results['polar_angle'] = np.angle(results['mu_x'] +
416418
results['mu_y'] * 1j)
417-
419+
418420
return results
419421

420422

0 commit comments

Comments
 (0)