@@ -284,8 +284,6 @@ def conn_covgc(data, dt, lag, t0, step=1, roi=None, times=None, method='gc',
284
284
* 0 : pairs[:, 0] -> pairs[:, 1] (x->y)
285
285
* 1 : pairs[:, 1] -> pairs[:, 0] (y->x)
286
286
* 2 : instantaneous (x.y)
287
- pairs : array_like
288
- Array of pairs of shape (n_pairs, 2)
289
287
290
288
References
291
289
----------
@@ -304,15 +302,12 @@ def conn_covgc(data, dt, lag, t0, step=1, roi=None, times=None, method='gc',
304
302
t0 = np .asarray (t0 ).astype (int )
305
303
dt , lag , step , trials = int (dt ), int (lag ), int (step ), None
306
304
# handle dataarray input
307
- if isinstance (data , xr .DataArray ):
308
- trials = data ['trials' ].data
309
- data , roi , times = conn_io (data , roi = roi , times = times , verbose = verbose )
305
+ data , trials , roi , times , attrs = conn_io (data , roi = roi , times = times ,
306
+ verbose = verbose )
310
307
# force C contiguous array because operations on row-major
311
308
if not data .flags .c_contiguous :
312
309
data = np .ascontiguousarray (data )
313
310
n_epochs , n_roi , n_times = data .shape
314
- if trials is None :
315
- trials = np .arange (n_epochs )
316
311
# default roi vector
317
312
if roi is None :
318
313
roi = np .array ([f"roi_{ k } " for k in range (n_roi )])
@@ -370,32 +365,28 @@ def conn_covgc(data, dt, lag, t0, step=1, roi=None, times=None, method='gc',
370
365
# change output type
371
366
dire = np .array (['x->y' , 'y->x' , 'x.y' ])
372
367
gc = xr .DataArray (gc , dims = ('trials' , 'roi' , 'times' , 'direction' ),
373
- coords = (trials , roi_p , times_p , dire ))
368
+ coords = (trials , roi_p , times_p , dire ), name = 'covgc' )
374
369
# set attributes
375
- gc .attrs ['lag' ] = lag
376
- gc .attrs ['step' ] = step
377
- gc .attrs ['dt' ] = dt
378
- gc .attrs ['t0' ] = t0
379
- gc .attrs ['conditional' ] = conditional
380
- gc .attrs ['type' ] = 'covgc'
381
- gc .name = 'covgc'
370
+ cfg = dict (lag = 'lag' , step = 'step' , dt = 'dt' , t0 = 't0' ,
371
+ conditional = 'conditional' , type = 'covgc' )
372
+ gc .attrs = {** attrs , ** cfg }
382
373
383
- return gc , pairs , roi_p , times_p
374
+ return gc
384
375
385
376
386
377
if __name__ == '__main__' :
387
378
from frites .simulations import StimSpecAR
388
379
import matplotlib .pyplot as plt
389
380
390
381
ss = StimSpecAR ()
391
- ar = ss .fit (ar_type = 'ding_3 ' , n_stim = 2 , n_epochs = 20 )
382
+ ar = ss .fit (ar_type = 'ding_3_direct ' , n_stim = 2 , n_epochs = 20 )
392
383
# plot the model
393
384
# plt.figure(figsize=(7, 8))
394
385
# ss.plot()
395
386
# compute covgc
396
387
dt , lag , step = 50 , 5 , 2
397
388
t0 = np .arange (lag , ar .shape [- 1 ] - dt , step )
398
389
gc = conn_covgc (ar , roi = 'roi' , times = 'times' , dt = dt , lag = lag , t0 = t0 ,
399
- n_jobs = - 1 , conditional = False )[ 0 ]
390
+ n_jobs = - 1 , conditional = False )
400
391
ss .plot_covgc (gc = gc )
401
392
plt .show ()
0 commit comments