Closed aopy closed 1 year ago
Thx @aopy. Can you check code quality? You need to install flake8 and, inside a terminal, go to frites directly and run flake8
to fix the issues related to code quality.
Also, net computations is not correct for intracranial EEG data. In conn_fit
, can you replace the block:
if net:
# get unique pairs
i_s, i_t = np.stack((i_s, i_t))[:, i_s < i_t]
# computes net transfer
fit = fit[i_s, :] - fit[i_t, :]
roi_p = np.array(roi_p)[i_s]
by :
if net:
roi_po = roi_p.copy()
done, roi_p, i_st = [], [], []
for n_s, (s, t) in enumerate(zip(i_s, i_t)):
# ignore if indices have already been stored
if ([s, t] in done) or ([t, s] in done): continue # noqa
# find [source, target] and [target, source]
result = np.where((i_s == t) & (i_t == s))[0]
assert len(result) == 1
n_t = result[0]
# decide if (x->y - y->x) or (y->x - x->y)
r_s, r_t = roi_po[n_s], roi_po[n_t]
if not np.all(np.array([r_s, r_t]) == np.sort([r_s, r_t])):
n_s, n_t = n_t, n_s
r_s, r_t = roi_po[n_s].split('->')[0], roi_po[n_t].split('->')[0]
# store results
i_st.append([n_s, n_t])
roi_p.append(f"{r_s}-{r_t}")
done.append([s, t])
# computes net transfer
i_s, i_t = np.array(i_st).T
fit = fit[i_s, :] - fit[i_t, :]
Thank you in advance,
@EtienneCmb thanks!
All lights are green @aopy !!! Thank you so much :+1:
@EtienneCmb no problem :) thanks for your input!
Hi @aopy. You pushed to
conn_fit
to xfrites, therefore the example can not import the function. Prior to the example, we should first include theconn_fit
function, then the unit tests and finally the example.Can you append to this PR the code you made for the PR inside xfrites?