iChaker / CPM_framework

CPM for fMRI voxelwise estimation of arbitrary models
0 stars 1 forks source link

Gaussian field #10

Open SRSteinkamp opened 2 years ago

SRSteinkamp commented 2 years ago

https://github.com/iChaker/CPM_framework/blob/2d5f6a516761ec5588cf700c8ebb15c1456812e5/CPM_Toolbox/model_functions/cpm_RF_Gaussian.m#L20

Hi Iyadh, could you remind me, what the two normalizations here do?

Shouldn't we get a pdf already from the function?

iChaker commented 2 years ago

The normalization comes from the original PRF paper. The double normalization comes from Felix's code, I copied and pasted it, I think this should be fixed.

SRSteinkamp commented 2 years ago

Thanks ... I will investigate.

SRSteinkamp commented 2 years ago

This is the code in the PRF toolbox (https://github.com/pzeidman/BayespRF/blob/master/toolbox/response_functions/spm_prf_fcn_gaussian_polar.m):

% Std dev -> covariance matrix
sigma = diag( [P.width P.width] );
sigma = sigma .* sigma;

% Normalized Gaussian
x = spm_mvNpdf(xy', [mu_x mu_y], sigma);

% Scale
x = P.beta .* x;

Which would mean in the original paper they didn't apply any form of normalization.

Second, I am wondering, right now, if we by accident got rid of the exponentiation of the BOLD parameters?

SRSteinkamp commented 2 years ago

Nevermind about the second part, exponentiation happens in the spm_prf_fx and spm_prf_gx.

iChaker commented 2 years ago

Hey Simon

The normalization is written in the paper, it's weird how they don't implement it. For CPM, we do need normalization, imagine a field with point like certainty, without normalization, the values around the point would be higher than 1 which would amplify the neuronal signal and skew the BOLD for no reason (as compared to a model with no field). IMO the weights should never exceed 1, preferably they should sum to 1, so they can be interpreted as a probability function in case there's no negative values.

SRSteinkamp commented 2 years ago

Well I agree, but it's still somewhat weird^^

The other thing is, that in our code we use sigma, but spm_mvNpdf expects the Variance, so we need to put a little square before.

iChaker commented 2 years ago

I guess that one is a bug not a feature :^)

SRSteinkamp commented 2 years ago

:D ... yeah... though the squaring somehow messes the estimation of the eta parameter up, and I am not too certain why... so I am playing around a bit, let you know if I have any update^^

SRSteinkamp commented 2 years ago

x = spm_mvNpdf(coords, mu, V) * sqrt(((2*pi)^3)*det(V));

To be honest, I only have a slight idea that this term is supposed to normalize the multinomial. But actually, it does not do anything in our code... It's a scalar and we normalize again by 1 / sum(x)...