BUNPC / Homer3

MATLAB application for fNIRS data processing and visualization
92 stars 54 forks source link

Update hmrR_GLM.m #131

Closed NoPenguinsLand closed 10 months ago

NoPenguinsLand commented 2 years ago

Testing: I tested all 4 different basis functions (idxBasis) and 2 different glmSolveMethod (GLM or iterative WGLM AR(1)). I also tested it for both t-test and F-test. So I think it should work under most reasonable scenarios. Another thing to note, technically, you can use it for both t-test and reduced model F-test but I don't think using p-value from reduced model makes sense. Any extraordinary scenarios, like users abusing Homer3, I haven't really checked these.

Changes:

  1. the degree of freedom for yvar and t-statistics for p-value are corrected.
  2. Fit HbT and compute statistics directly. Since HbT yields highest classification accuracy in my dataset, HbT is more interesting to me.
  3. Now users can access sum of squares and degree of freedom for F-test, they are returned in hmrstats struct output.
  4. c_vector can now be a matrix to support multiple testing.
  5. For t-test, you can now specify a subset of beta coefficients. For example, the GLM fits the data to the model from -2 to 15 seconds. But I expect the significant activation to be between 0 and 5 seconds. So I only want to perform t-test on that subset. I can do so by setting betaList = [3 4 5 6 7 8]. betaList is meant to work together with c_vector for pval_contrast and tval_contrast.
  6. Return full beta coefficients. This is important so I can get the beta coefficients for the SS channels for my research. I'm thinking about returning two different beta variables: one for the HRFs and another for non-HRF regressors such as short-separation, nth-order polynomial, drifting, motion aux, etc.
  7. preallocate arrays for faster processing

Considerations:

  1. In my code, the confidence intervals for both beta coefficients and y average response variable are computed outside of hmrR_GLM function, although they can be computed inside.
  2. For F-test, the users will need to run hmrR_GLM.m function twice, once for full model, and once for reduced model. This isn't automated.
  3. Also if using F-test for reduced model by setting condListF variable, the dimension of data will remain the same as the full model, but the dimension of all fields in hmrstats will be reduced but the beta_label will inform the users.
  4. For F-test, you cannot specify a subset of HRF regressors because that'll require drastically altering the code structure. (Instead of looping through outer and inner for loops for nCond and nB, I'll have to restructure to one loop in order to loop through the total number of HRF regressors.
sstucker commented 2 years ago

I am really happy to see contributions to the project but this is a rather large change to the GLM function, which is already bloated in functionality. Is it possible to add this additional functionality as another user function?

NoPenguinsLand commented 2 years ago

Hey Stephen, happy to help! I added multiple functionalities, do you mean to break them down in separate functions (which is rather hard to separate them) or just rename the function (maybe hmrR_GLM_Extended)?

sstucker commented 2 years ago

I am not familiar with what you're doing here, but ideally more sophisticated analysis can be modularized and made into a function which operates on the outputs of GLM... Maybe this is totally impossible in this scenario? @mayucel

NoPenguinsLand commented 2 years ago

It's possible but all of these functionalities are intimately tied to GLM calculations so I personally think it's best to leave it as is, plus it will run faster when put together. Sure, let's wait and hear what Meryem has to say.

Thanks Stephen!

On Mon, May 16, 2022, 7:51 AM stephen scott tucker @.***> wrote:

I am not familiar with what you're doing here, but ideally more sophisticated analysis can be modularized and made into a function which operates on the outputs of GLM... Maybe this is totally impossible in this scenario? @mayucel https://github.com/mayucel

— Reply to this email directly, view it on GitHub https://github.com/BUNPC/Homer3/pull/131#issuecomment-1127573991, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRZ6NUMLLMXDNQYU4FISADVKIZFJANCNFSM5TIWD65Q . You are receiving this because you authored the thread.Message ID: @.***>