-
Notifications
You must be signed in to change notification settings - Fork 141
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
WIP [Maint] Refactoring Hpi Fitting #884
Conversation
Codecov Report
@@ Coverage Diff @@
## main #884 +/- ##
==========================================
+ Coverage 30.20% 36.17% +5.97%
==========================================
Files 452 199 -253
Lines 39208 11818 -27390
==========================================
- Hits 11841 4275 -7566
+ Misses 27367 7543 -19824
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool! Thx @RDoerfel
@RDoerfel Do you mind creating a rough draft of the class hierarchy and how they play together? If yes, you can just add the image to the PR description. I think it would benefit understating the new structure. |
…es for advanced model
…approach because of not-yet explained sign change
… on proper testing stategy
@juangpc @gabrielbmotta Can you have a look at this PR as well please? We would like to go ahead and start a new round of testing with this version. Thanks! Also, any ideas why the Codecov is failing? |
Hi! The MEG is open on Friday for testing. We can merge as-is and then push any new changes after testing or test and incorporate changes to this PR. Whichever you prefer. |
@gabrielbmotta Thanks for having a look at this. The PR was still WIP and I think Ruben wanted to push some last commits. No need to reopen though, @RDoerfel can you just create a subsequent PR? |
This PR aims to refactor the HPI class to make the code more readable, separate concerns, and make it easier to test. So far, no new functionality itself was implemented. I guess, most of the new lines are unit tests.
Following is a list of newly introduced classes.
HpiDataUpdater
Extracting important information like channel list from the FiffInfo. The used channels directly influence the data and projectors used for the HPI fit. However, this preparation based on the channel list has nothing to do with the HPI fitting algorithm and was therefore moved outside the HpiFit Class. Further, it provides the current SensorSet.
SensorSet and SensorSetCreator
SensorSet
is a class containing the MEG sensor information and is constructed bySensorSetCreator
.SensorSetCreator
stores the link to the coil-definition file and a general FwdCoil object which contains information about all possible sensor types, and therefor, no information that should be carried by a specificSensorSet
HpiModelParameter
Is an object containing all the information (hpi freqs, sfreq, linefreq, number of coils,...) necessary to build the signal model and initiate an hpi fit.
SignalModel
The signal model is utilized by the HpiFit algorithm to compute the HPI coil amplitudes. Since building and fitting the model is a task in itself, it was moved to its own class. Further, a struct
ModelParameters
was introduced. This struct is used to construct the signal model and is also one of the Inputs for the HpiFit class. The struct contains the information necessary for the SignalModel and therefore the HpiFitting. It contains the Hpi Coil frequencies, the line frequency, and whether to use the advanced model or not (should be removed in the future).HpiFit
The HpiFit class is now constructed using a SensorSet. Further, the number of input parameters was reduced, and the
findOrder
andfit
functions were unified, since they do essentially the same, except 5 lines of code. Also, the results are now returned using theHpiFitResult
struct.Please find an example of the new usage of all these classes in the test_hpiFit Unit test.
ToDo
const
if necessaryClass Interaction Diagram
I hope the following makes the usage of the newly implemented classes a little transparent. Time flows from top to bottom.