Skip to content

added example for FIT#59

Merged
EtienneCmb merged 6 commits into
brainets:masterfrom
aopy:master
Jun 22, 2023
Merged

added example for FIT#59
EtienneCmb merged 6 commits into
brainets:masterfrom
aopy:master

Conversation

@aopy
Copy link
Copy Markdown
Contributor

@aopy aopy commented Jun 21, 2023

No description provided.

@EtienneCmb
Copy link
Copy Markdown
Collaborator

EtienneCmb commented Jun 21, 2023

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 the conn_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?

@EtienneCmb
Copy link
Copy Markdown
Collaborator

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.

@EtienneCmb
Copy link
Copy Markdown
Collaborator

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,

@aopy
Copy link
Copy Markdown
Contributor Author

aopy commented Jun 22, 2023

@EtienneCmb thanks!

@EtienneCmb EtienneCmb self-assigned this Jun 22, 2023
@EtienneCmb EtienneCmb added the enhancement New feature or request label Jun 22, 2023
Copy link
Copy Markdown
Collaborator

@EtienneCmb EtienneCmb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we need to put the conn_fit in the API tab of the doc. Below conn_pid, can you add conn_fit please?

Comment thread frites/conn/tests/test_conn.py
Comment thread frites/conn/conn_fit.py
Comment thread examples/conn/plot_fit.py Outdated
Copy link
Copy Markdown
Collaborator

@EtienneCmb EtienneCmb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally, can you add your contribution to What's new tab? Add a line below in the whatsnew file, something like :

- New function :func:`frites.conn.conn_fit` to estimate the feature specific information transfer (:PR:`59`) - :author:`aopy`

@EtienneCmb
Copy link
Copy Markdown
Collaborator

All lights are green @aopy !!! Thank you so much 👍

@EtienneCmb EtienneCmb merged commit b0c7e40 into brainets:master Jun 22, 2023
@aopy
Copy link
Copy Markdown
Contributor Author

aopy commented Jun 22, 2023

@EtienneCmb no problem :) thanks for your input!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants