sampsapursiainen / zeffiro_interface

Interface for using finite elements in inverse problems with complex domains
GNU General Public License v3.0
24 stars 15 forks source link

Squashed branch continuous_source_model into a single commit (READ ACCOMPANYING MESSAGE BEFORE MERGING) #107

Closed SeSodesa closed 2 years ago

SeSodesa commented 2 years ago

The commit messages of the individual updates are listed below, and the original branch without the squashed_ prefix still exists in the repo.

DO NOT MERGE IF WORKING ON ANOTHER BRANCH AND NOT PREPARED TO DEAL WITH THE RESULTING CONFLICTS!


ZefSourceModel: added continuous variants to the enumeration

… and updated the static from-method to handle integers from 4–6. The mapping is 4 ↦ ContinuousWhitney, 5 ↦ ContinuousHdiv and 6 ↦ ContinuousStVenant.

lead_field_matrix: added a helper function fore generating source- and source space decomposition indices

The source space decomposition indices should be empty, if a discrete source model (as in a coarsely generated gray matter mesh) is used.

Lead field routines and lead_field_matrix: pass source_decomposition_inds as input

lead_field_matrix: removed unnecessary semicolons and improved a section comment

zef_decompose_dof_space: updated documentation (still TODO)

lead_field_eeg_fem: pass source_decomposition_inds generated by zef_decompose_dof_space to interpolation functions

The indices do nothing at this point.

lead_field_matrix: renamed variable aux_vec → brain_activity_ind

lead_field_matrix: dot not remove (now) non-existent field aux_vec from zef

Also removed reference to zef from helper function, as the struct does not exist in its namespace.

lead_field_matrix: pass brain_activity_inds and source_tetra_inds to lead field routines instead of brain_ind and source_ind

Also added a few intrepretive comments, which may or may not be correct.

zef_lead_field_interpolation: dispatch on continuous source models

The function now calls zef_{whitney,hdiv,st_venant}_interpolation with the entire active brain layer as intended source inds in the case of ZefSourceModel.Continuous{Whitney,Hdiv,StVenant}. Continuous variants of the interpolation functions will be needed to make this faster.

zef_lead_field_interpolation: remove _continuous from function name (for now)

zef_decompose_dof_space: improved variables names and documentation

lead field interpolation routines: renamed parameter p_{decomposition_inds → nearest_neighbour_inds}

Now the parameter name actually delivers its purpose. At least somewhat.

lead_field_matrix: renamed zef.{source_decomposition_inds → nearest_neighbour_inds}

lead_field_matrix: renamed zef.{nearest_neighbour_inds → nearest_source_neighbour_inds}

lead field routines: changed parameter {source_decomposition_inds → p_nearest_neighbour_inds}

lead_field_matrix: updated comment

lead_field_matrix: changed default peeling depth to zef.mesh_resolution

zef_lead_field_interpolation: updated documentation to cover the argument p_nearest_neighbour_inds

interpolation routines: started working on continous source model implementation

interpolation routines: added proper documentation

interpolation_routines: removed unnecessary and incomplete TODO comments

interpolation functions: index arguments must be positive, not just non-negative

zef_lead_field_interpolation: both the discrete and continuous models dispatch to the same function

lead_field_matrix: set zef.source_ind again and use it in lead field routines

lead_field_matrix: generate the nearest neighbour indices of all brain indices here

… instead of leaving this responsibility the the interpolation functions called by the lead field routines.

zef_decompose_dof_space: updated variable names again to match prior changes

zef_decompose_dof_space: removed unused lines of code and set precedence with (⋅) instead of [⋅]

lead_field_matrix: pass nearest_source_neighbour_inds to lead field routines

… again.

zef_hdiv_interpolation: added logic to handle continuous source models

This might not be correct, as with 10 000 sources the RDM results with the Ary model are much worse than with a discrete model.

zef_decompose_dof_space: clarified what local lattice_index_fn does

Also added an 's' after nearest_neighbour_ind to accentuate the fact that it contains multiple indices, not just one.

zef_decompose_dof_space: fix typo in comment

zef_decompose_dof_space: improved local lattice_index_fn documentation again.

zef_decompose_dof_space: renamed lattice_index_fn variables to better match documentation

zef_hdiv_interpolation: continuous indexing now seems to produce something sensible with 10 k samples

zef_hdiv_interpolation: rename aux-variable

Variable names should at least try to be descriptive…

zef_whitney_interpolation: added the handling of the continuous source model, just like in zef_hdiv_interpolation

Also removed the 4 neighbour condition. This has a negative effect on ZefSourceModel.Whitney, but a positive one on ZefSourceModel.ContinuousWhitney.

Added new function zef_pbo_system

… to be used in the interpolation functions related to lead field generation.

lead_field_matrix: feed zef.brain_ind to lead field routines, but at the same time limit position of sources into the peeled zef.brain_ind or zef.brain_activity_inds

zef_{whitney,hdiv}_interpolation: use zef_pbo_system to form the interpolation coefficient matrices

Added function zef_mpo_system.m

Still untested. Might be dysfunctional.

zef_mpo_system: fixed typos in documentation

zef_pbo_system: fixed typos in documentation

zef_mpo_system: word interpolation → optimization in documentation

zef_mpo_system: fixed name of function in the file

zef_mpo_system: fixed variable names, transposes and matrix sizes

zef_mpo_system included as a part of EEG routine

The interpolation functions now take an additional parameter called optimization_system_type, which tells Whitney and H(div) routines whether to use PBO or MPO for optimization.

lead_field_matrix: add documentation and change default source depth to 0 mm

ZefSourceModel: added a variants-method.

ZefSourceModel: fixed a typo and added a to_string method

forward_and_inverse_options: source model variants now set based on static method ZefSourceModel.variants