Skip to content

Commit 15689cc

Browse files
committed
corrected keys in results | improved printing to terminal | corrected TC creation
1 parent 163254f commit 15689cc

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

code/python/cni_toolbox/IRM.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,25 +181,26 @@ def create_timecourses(self, FUN, xdata):
181181
for idx, key in enumerate(self.xdata):
182182
n_observations[idx] = np.size(self.xdata[key])
183183

184-
self.n_points = np.prod(n_observations)
184+
self.n_points = np.prod(n_observations).astype(int)
185185

186186
idx_all = np.arange(self.n_points)
187187
self.idx = np.zeros((self.n_points, self.n_predictors))
188188

189189
for p in range(self.n_predictors):
190190
self.idx[:, p] = (idx_all // (np.prod(n_observations[p+1::]))) \
191191
% n_observations[p]
192-
192+
self.idx = self.idx.astype(int)
193193
tc = np.zeros((self.n_samples + self.l_hrf,
194194
self.n_points))
195195
x = np.zeros(self.n_predictors)
196+
print('\ncreating timecourses')
196197
for j in range(self.n_points):
197-
for p, key in enumerate(self.n_predictors):
198-
x[p] = self.xdata[key](self.idx[j, p])
198+
for p, key in enumerate(self.xdata):
199+
x[p] = self.xdata[key][self.idx[j, p]]
199200
tc[0:self.n_samples, j] = FUN(self.stimulus, x)
200201
i = int(j / self.n_points * 21)
201202
sys.stdout.write('\r')
202-
sys.stdout.write("creating timecourses [%-20s] %d%%"
203+
sys.stdout.write("[%-20s] %d%%"
203204
% ('='*i, 5*i))
204205

205206
self.tc_fft = fft(tc, axis = 0)
@@ -241,7 +242,9 @@ def mapping(self, data, threshold = 100, mask = []):
241242

242243

243244
results = {'corr_fit': np.zeros(self.n_total)}
244-
245+
for key in self.xdata:
246+
results[key] = np.zeros(self.n_total)
247+
245248
if self.hrf_fft.ndim==1:
246249
tc = np.transpose(
247250
zscore(
@@ -251,6 +254,7 @@ def mapping(self, data, threshold = 100, mask = []):
251254
axis = 1), axis = 0)), axis = 0))
252255
tc = tc[:, 0:self.n_samples]
253256
mag_tc = np.sqrt(np.sum(tc**2, axis = 1))
257+
print('\nmapping model parameters')
254258
for m in range(n_voxels):
255259
v = voxel_index[m]
256260

@@ -266,7 +270,7 @@ def mapping(self, data, threshold = 100, mask = []):
266270

267271
i = int(m / n_voxels * 21)
268272
sys.stdout.write('\r')
269-
sys.stdout.write("irm mapping [%-20s] %d%%"
273+
sys.stdout.write("[%-20s] %d%%"
270274
% ('='*i, 5*i))
271275

272276
else:
@@ -295,7 +299,7 @@ def mapping(self, data, threshold = 100, mask = []):
295299

296300
i = int(m / n_voxels * 21)
297301
sys.stdout.write('\r')
298-
sys.stdout.write("irm mapping [%-20s] %d%%"
302+
sys.stdout.write("[%-20s] %d%%"
299303
% ('='*i, 5*i))
300304

301305

@@ -306,4 +310,4 @@ def mapping(self, data, threshold = 100, mask = []):
306310
self.n_cols,
307311
self.n_slices)))
308312

309-
return results
313+
return results

0 commit comments

Comments
 (0)