Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not recompute lf if already existing #2339

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mcpiastra
Copy link
Contributor

this relates to the issue #2188
after the dipole scan, the leadfield should be recomputed only if not already existing

Copy link

github-actions bot commented Nov 9, 2023

You should test whether your modifications do not break anything.
See https://www.fieldtriptoolbox.org/development/testing/

When outside the DCCN, please consider testing: test_ft_dipolefitting, test_example_simulate_forward_dipolefit, test_pull1377b

When inside the DCCN, please also consider testing: test_bug3119, test_eeglab_ft_integration, test_pull1377b, test_bug2773

Suggested tests outside the DCCN use public data or do not use data.
Suggested tests inside the DCCN use private data.

Copy link
Contributor

@schoffelen schoffelen left a comment

Choose a reason for hiding this comment

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

Hmmm, are you sure that this change will work? Also in general?

Specifically, you check for ~lf, but this will throw an error if the variable lf does not exist in the function. This could be the case for instance if someone runs a nonlinear fit only (i.e. without gridsearch).
Also, generically, lf to me seems the forward solution to one of the dipoles in the grid, which is updated in the for-loop across the dipoles in the grid. The lf outside the gridsearch loop is just the leadfield of the last dipole in the grid, and not necessarily the one that gave the optimal solution.

Or am I missing something?

Copy link

github-actions bot commented Nov 9, 2023

You should test whether your modifications do not break anything.
See https://www.fieldtriptoolbox.org/development/testing/

When outside the DCCN, please consider testing: test_ft_dipolefitting, test_example_simulate_forward_dipolefit, test_pull1377b

When inside the DCCN, please also consider testing: test_bug2773, test_eeglab_ft_integration, test_bug3119, test_pull1377b

Suggested tests outside the DCCN use public data or do not use data.
Suggested tests inside the DCCN use private data.

Copy link

github-actions bot commented Nov 9, 2023

You should test whether your modifications do not break anything.
See https://www.fieldtriptoolbox.org/development/testing/

When outside the DCCN, please consider testing: test_ft_dipolefitting, test_pull1377b, test_example_simulate_forward_dipolefit

When inside the DCCN, please also consider testing: test_bug2773, test_pull1377b, test_eeglab_ft_integration, test_bug3119

Suggested tests outside the DCCN use public data or do not use data.
Suggested tests inside the DCCN use private data.

@mcpiastra
Copy link
Contributor Author

you are right, sorry.
I now modified the code so that the corresponding leadfield is copied along the dipole, and there is a check on the field of of dipole.
does it make sense to you now?
thanks.

% if there is no leadfield, re-compute it in order to compute the model potential and dipole moment
lf = ft_compute_leadfield(dip(t).pos, sens, headmodel, leadfieldopt{:});
else
lf = dip.lf;
Copy link
Contributor

Choose a reason for hiding this comment

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

would you need to consider the loop-variable (and also in line 466?)?

Copy link

github-actions bot commented Nov 9, 2023

You should test whether your modifications do not break anything.
See https://www.fieldtriptoolbox.org/development/testing/

When outside the DCCN, please consider testing: test_pull1377b, test_example_simulate_forward_dipolefit, test_ft_dipolefitting

When inside the DCCN, please also consider testing: test_pull1377b, test_bug2773, test_eeglab_ft_integration, test_bug3119

Suggested tests outside the DCCN use public data or do not use data.
Suggested tests inside the DCCN use private data.

@schoffelen
Copy link
Contributor

Hi @mcpiastra, have you tried to run the suggested test functions on your end (given the changed code)? Let me know if those functions ran through without error, then I will merge.

Copy link

You should test whether your modifications do not break anything.
See https://www.fieldtriptoolbox.org/development/testing/

When outside the DCCN, please consider testing: test_example_simulate_forward_dipolefit, test_pull1377b, test_ft_dipolefitting

When inside the DCCN, please also consider testing: test_bug3119, test_eeglab_ft_integration, test_pull1377b, test_bug2773

Suggested tests outside the DCCN use public data or do not use data.
Suggested tests inside the DCCN use private data.

@mcpiastra
Copy link
Contributor Author

hi @schoffelen, after the last commit, yes, all the suggested tests run with no error.
thanks!

@schoffelen
Copy link
Contributor

Hi @mcpiastra I think that there is not much work to be done on this anymore. In other words, I think it can be merged, but it would be great if this PR also includes a snippet of test code added to a relevant test function (or a new test function altogether). Do you have some code lying around that allows for testing the functionality, or could you write some?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants