-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtractGradient.m
More file actions
41 lines (34 loc) · 2.01 KB
/
Copy pathExtractGradient.m
File metadata and controls
41 lines (34 loc) · 2.01 KB
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
%% gradMetricSub1.m — gradient concentration of D = moco - noMoco (Subject 1)
noMocoFile = 'I:\yannic.delisle\scripts\sub-09\baseline_nomoco\x_nomoco_1bin_mathilda_manual_finalNu240.mat';
% Add the paths of the best stride per window
mocoFiles = {
'I:\yannic.delisle\scripts\sub-09\sliding_L5.5_S1.1\x_moco_mathilda_smoothedMotion_from_x_cs_tres1.1s_Nu120x120x120_delta1_sliding.mat'
'I:\yannic.delisle\scripts\sub-09\sliding_L3.5_S2.1\x_moco_mathilda_smoothedMotion_from_x_cs_tres2.1s_Nu120x120x120_delta2_sliding.mat'
};
% --- no-moco: load, magnitude, normalize by its own 99th percentile ---
S = load(noMocoFile,'x_nomoco'); A = abs(double(S.x_nomoco));
A = A / prctile(A(:),99);
zc = round(size(A,3)/2); % central axial slice (matches the heatmap figure)
ref = A(:,:,zc);
% --- brain mask + interior / boundary bands (needs Image Processing Toolbox) ---
mask = imfill(ref > 0.3, 'holes'); % tune 0.12 if the mask looks wrong
interior = imerode(mask, strel('disk',6));
boundary = mask & ~interior;
figure; imagesc(mask); axis image; % <-- uncomment to sanity-check the mask
for k = 1:numel(mocoFiles)
T = load(mocoFiles{k},'x_moco'); B = abs(double(T.x_moco));
B = B / prctile(B(:),99);
D = B(:,:,zc) - ref; % same D as the heatmap
gx = (D([2:end end],:) - D([1 1:end-1],:))/2;
gy = (D(:,[2:end end]) - D(:,[1 1:end-1]))/2;
g = sqrt(gx.^2 + gy.^2); % |grad D|
ri = mean(g(interior)); rb = mean(g(boundary));
fprintf('%s\n interior=%.4g boundary=%.4g ratio=%.2f\n\n', ...
mocoFiles{k}, ri, rb, rb/ri);
end
% Subject 6 results:
% I:\yannic.delisle\scripts\sub-06\sliding_L5.5_S5.5\x_moco_mathilda_smoothedMotion_from_x_cs_tres5.5s_Nu120x120x120_delta1_sliding.mat
% interior=0.03341 boundary=0.03815 ratio=1.14
%
% I:\yannic.delisle\scripts\sub-06\sliding_L3.5_S2.8\x_moco_mathilda_smoothedMotion_from_x_cs_tres2.8s_Nu120x120x120_delta2_sliding.mat
% interior=0.03238 boundary=0.03799 ratio=1.17