GithubHelp home page GithubHelp logo

pranaysy / riksneurotools Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mrc-cbu/riksneurotools

1.0 1.0 0.0 106 KB

Rik Henson's neuroimaging analysis tools

License: GNU General Public License v3.0

MATLAB 100.00%

riksneurotools's People

Contributors

jooh avatar pranaysy avatar rikhenson avatar

Stargazers

 avatar

riksneurotools's Issues

Norm used for scaling CL is neither Frobenius nor L2

Problem

In fuse_lfp:L137 the $\text{norm}$ of the leadfield that has been reduced from $sensors\times vertices$ to $sensors\times ROIs$ does not correspond to any known $\text{norm}$.

More precisely, the $\text{norm}$ is estimated in code as: sqrt(trace(CL{m}*CL{m}')/Nchn(m)),
but, for matrices $\text{Frobenius norm}$* is defined as sqrt(trace(CL{m}*CL{m}')) (of many sources, here's one at MATLAB's docs)
while $L_2 \text{ norm}$ for a matrix (also called the spectral norm) is defined as max(svd(CL{m})) (MATLAB's docs)


*For matrices: $\text{Frobenius norm}$ = norm(CL{m}, 'fro') = sqrt(trace(CL{m}*CL{m}')) = sqrt(sum(CL{m}(:).^2))

Reproducible example A

x = ones(5);

% Frobenius norms
norm(x, 'fro')      % returns 5
sqrt(trace(x*x'))   % returns 5
sqrt(sum(x(:).^2))  % returns 5

% L2 norms
norm(x, 2)          % returns 5
max(svd(x))         % returns 5

% Implemented norm
sqrt(trace(x*x')/5) % returns 2.2361

Reproducible example B

x = magic(5);

% x =
%
%    17    24     1     8    15
%    23     5     7    14    16
%     4     6    13    20    22
%    10    12    19    21     3
%    11    18    25     2     9

% Frobenius norms
norm(x, 'fro')      % returns 74.330
sqrt(trace(x*x'))   % returns 74.330
sqrt(sum(x(:).^2))  % returns 74.330

% L2 norms
norm(x, 2)          % returns 65
max(svd(x))         % returns 65

% Implemented norm
sqrt(trace(x*x')/5) % returns 33.242

Solution

As the implemented $\text{norm}$ closely matches the $\text{Frobenius norm}$, switch to MATLAB's default implementation with norm(x, 'fro')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.