-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatch_mepmetric.m
45 lines (40 loc) · 2.22 KB
/
patch_mepmetric.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function mepmetric = patch_mepmetric(field, norms, metric, ntransfer)
switch(metric)
case 'C0' %simply the field magnitude summed over all faces in the patch, wighted for triangle size (length of normal)
lengthnorm=(sqrt(sum( (norms.*norms)' ))');
if ntransfer
mepmetric=sum( neuronal_transfer(sqrt(sum( (field.*field)' ))',35,0.2) .* lengthnorm); %metric C0
else
mepmetric=sum( sqrt(sum( (field.*field)' ))' .* lengthnorm); %metric C0
end
case 'CE' %simply the field magnitude summed over all faces in the patch, wighted for triangle size (length of normal)
lengthnorm=(sqrt(sum( (norms.*norms)' ))');
if ntransfer
mepmetric=sum( neuronal_transfer(sqrt(sum( (field.*field)' ))',35,0.2) .* lengthnorm); %metric C0
else
mepmetric=sum( sqrt(sum( (field.*field)' ))' .* lengthnorm); %metric C0
end
case 'C3' %the well known C3 metric
mepmetric=sum(abs(sum(field.*norms,2)))/2; %metric C3 summed over all faces. As norms are not normalized to unit length, this also multiplies by triangle surface
case 'C4' %like C3, but assymetric (strongest when field pointing OUTWARD)
fieldmag=(sqrt(sum( (field.*field)' ))');
lengthnorm=(sqrt(sum( (norms.*norms)' ))');
if ntransfer
mepmetric_all=lengthnorm.*neuronal_transfer( (fieldmag+sum(field.*(norms./lengthnorm),2))/4,5,0.5); %metric C4 summed over all faces
else
mepmetric_all=(fieldmag.*lengthnorm+sum(field.*(norms),2))/4; %metric C4 summed over all faces
end
mepmetric=sum(mepmetric_all);
case 'C5' %like C3, but assymetric (strongest when field pointing INWARD)
fieldmag=(sqrt(sum( (field.*field)' ))');
lengthnorm=(sqrt(sum( (norms.*norms)' ))');
if ntransfer
mepmetric_all=lengthnorm.*neuronal_transfer( (fieldmag+sum(field.*(-norms./(lengthnorm * [1 1 1]) ),2))/4,5,0.5); %metric C4 summed over all faces
else
mepmetric_all=(fieldmag.*lengthnorm+sum(field.*(-norms),2))/4; %metric C4 summed over all faces
end
mepmetric=sum(mepmetric_all);
otherwise
mepmetric=NaN;
end
end