@@ -206,22 +206,24 @@ def import_stimulus(self):
206
206
207
207
self .stimulus = np .zeros ((self .h_stimulus ,
208
208
self .w_stimulus ,
209
- self .n_samples + self . l_hrf ))
209
+ self .n_samples ))
210
210
211
211
for f in files :
212
212
number = int ('' .join ([str (s ) for s in f if s .isdigit ()]))
213
213
img = cv2 .imread (f )
214
214
self .stimulus [:, :, number ] = img [:, :, 0 ]
215
215
216
- mn = np .min (self .stimulus [:, :, :: self . n_samples ] )
216
+ mn = np .min (self .stimulus )
217
217
mx = np .max (self .stimulus )
218
218
self .stimulus = (self .stimulus - mn ) / (mx - mn )
219
219
220
-
221
220
self .stimulus = np .reshape (self .stimulus ,
222
221
(self .h_stimulus * self .w_stimulus ,
223
- self .n_samples + self . l_hrf ))
222
+ self .n_samples ))
224
223
224
+ self .stimulus = np .hstack ((self .stimulus ,
225
+ np .zeros ((self .h_stimulus * self .w_stimulus , self .l_hrf ))))
226
+
225
227
def create_timecourses (self , max_radius = 10.0 , n_xy = 30 ,
226
228
min_slope = 0.1 , max_slope = 1.2 ,
227
229
n_slope = 10 ):
@@ -318,16 +320,17 @@ def mapping(self, data, threshold = 100, mask = []):
318
320
self .n_total ))
319
321
320
322
mean_signal = np .mean (data , axis = 0 )
321
- data = zscore ( data , axis = 0 )
323
+
322
324
323
325
if np .size (mask )== 0 :
324
326
mask = mean_signal >= threshold
325
327
326
328
mask = np .reshape (mask ,self .n_total )
327
329
voxel_index = np .where (mask )[0 ]
330
+ data = zscore (data [:, mask ], axis = 0 )
328
331
n_voxels = voxel_index .size
329
-
330
- mag_d = np .sqrt (np .sum (data [:, mask ] ** 2 , axis = 0 ))
332
+
333
+ mag_d = np .sqrt (np .sum (data ** 2 , axis = 0 ))
331
334
332
335
333
336
results = {'corr_fit' : np .zeros (self .n_total ),
@@ -347,7 +350,7 @@ def mapping(self, data, threshold = 100, mask = []):
347
350
for m in range (n_voxels ):
348
351
v = voxel_index [m ]
349
352
350
- CS = np .matmul (tc , data [:, v ]) / (mag_tc * mag_d [m ])
353
+ CS = np .matmul (tc , data [:, m ]) / (mag_tc * mag_d [m ])
351
354
idx_remove = (CS == np .Inf )| (CS == np .NaN );
352
355
CS [idx_remove ] = 0
353
356
@@ -380,7 +383,7 @@ def mapping(self, data, threshold = 100, mask = []):
380
383
tc = tc [:, 0 :self .n_samples ]
381
384
mag_tc = np .sqrt (np .sum (tc ** 2 , axis = 1 ))
382
385
383
- CS = np .matmul (tc , data [:, v ]) / (mag_tc * mag_d [m ])
386
+ CS = np .matmul (tc , data [:, m ]) / (mag_tc * mag_d [m ])
384
387
idx_remove = (CS == np .Inf ) | (CS == np .NaN )
385
388
CS [idx_remove ] = 0
386
389
@@ -414,4 +417,4 @@ def mapping(self, data, threshold = 100, mask = []):
414
417
415
418
return results
416
419
417
-
420
+
0 commit comments