%plot motion params from realignment

sub = spm_get(1,'.txt',' Select Subject:');
load(sub);
[fpath,fname,fext] = fileparts(sub);


%sub = input('which subject? ', 's');
%load (['c:\data\' sub '\realignment_params_aI_001.txt']);

% irritatingly, we run into trouble now if our filename has a dot in it,
% because MATLAB tries to interpret that as a structure field reference.
dot = findstr(fname, '.');
if ~(isempty(dot))
    fname = fname(1:(dot - 1));
end
data1 = eval(fname);

page = figure('NumberTitle', 'off', 'PaperOrientation', 'landscape', 'PaperPosition', [0 0 11 8.5], 'Units', 'inches', 'Position', [0 0 11 8.5]);
h1 = subplot(2,1,1), plot(data1(:,1:3));
h2 = subplot(2,1,2), plot(data1(:,4:6));

%plotline(14,'k:');
%plotline(320,'k:');
subplot(h1), ylabel('movement in mm');
xlabel('scans');
y_lim = get(gca, 'YLim');
legend('x mvmt', 'y mvmt', 'z mvmt',0);
%legend('x mvmt', 'y mvmt', 'z mvmt', ['max:' num2str(y_lim(2))], ['min:' num2str(y_lim(1))],0);

subplot(h2);
ylabel('movement in rad');
xlabel('scans');
y_lim = get(gca, 'YLim');
%legend('pitch', 'roll', 'yaw',0);
legend('pitch', 'roll', 'yaw', ['max:' num2str(y_lim(2))], ['min:' num2str(y_lim(1))],0);

set(h1,'Ygrid','on');
set(h2,'Ygrid','on');