-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkPlotMotion.m
46 lines (40 loc) · 1.46 KB
/
kPlotMotion.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
% from Marko Wilke: https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=spm;29083d7c.0911
function kPlotMotion(mcFldr,voxSize,pauseAfterEach)
clf
% looks for [mcPath '/rp*' '.txt'], creates motion plot and saves in mcFldr
% (voxSize is scalar)
b=filenames([mcFldr '/rp*' '.txt'],'char');
% plot motion parameters from spm
% filt = ['^rp_*','.*\.txt$'];
% b = spm_select([Inf],'any','Select realignment parameters',[],pwd,filt);
if size(b,1)<1
error([mcFldr '/rp* not found'])
end
for i = 1:size(b,1)
[~, name, ~] = fileparts(b(i,:));
printfig = figure;
set(printfig, 'Name', ['Motion parameters: ' name ], 'Visible', 'on');
loadmot = load(deblank(b(i,:)));
if numel(find(loadmot(:)>voxSize)>0)
disp('%%%%%%%%%%%%%%%%%%%% MOTION %%%%%%%%%%%%%%%%%%%%%%%%%%')
disp(name)
disp('======================================================')
end
subplot(2,1,1);
plot(loadmot(:,1:3));
grid on;
% ylim([-3 3]); % enable to always scale between fixed values
title(['Motion parameters: shifts (top, in mm) and rotations (bottom, in dg)'], 'interpreter', 'none');
subplot(2,1,2);
plot(loadmot(:,4:6)*180/pi);
grid on;
% ylim([-3 3]);
title(['Data from ' name], 'interpreter', 'none');
mydate = date;
motname = [mcFldr filesep 'motion_sub' sprintf('%02.0f', i) '_' mydate '.png'];
print(printfig, '-dpng', '-noui', '-r100', motname);
if pauseAfterEach==1
k=input('ok?');
end
% close(printfig)
end;