-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathavw_flip.m
57 lines (49 loc) · 1.72 KB
/
avw_flip.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
46
47
48
49
50
51
52
53
54
55
56
57
function [ avw ] = avw_flip(avw,dims)
% AVW_FLIP - ortho-flip Analyze data image (avw.img)
%
% [ avw ] = avw_flip(avw,dims)
%
% where avw is the data struct returned from avw_img_read
% and dims is a cell array of strings, eg: dims = {'x','y','z'}
% with any number of cells, in any order.
%
% For each cell of dims, the dimension of avw.img is flipped,
% independently of all other dimensions and the order in which
% they are specified. There are no 3D rotations, which are
% not orthogonal flips.
%
% This function will most likely invalidate the .img orientation,
% so use of it is not recommended. There is no attempt in this
% function to maintain the validity of the avw.hdr.hist.orient
% field. In fact, this will be set to an invalid value (9).
%
% see also AVW_IMG_READ, AVW_VIEW
%
% $Revision: 1.1 $ $Date: 2004/11/12 01:30:25 $
% Licence: GNU GPL, no express or implied warranties
% History: 01/2003, [email protected]
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
version = '[$Revision: 1.1 $]';
fprintf('\nAVW_FLIP [v%s]\n',version(12:16));
fprintf('...warning, this function can invalidate the .img orientation,\n');
fprintf('...setting avw.hdr.hist.orient to invalid value = 9.\n');
avw.hdr.hist.orient = uint8(9);
for i = 1:length(dims),
dim = lower(dims{i});
switch dim,
case 'x',
fprintf('...flipping X\n');
xdim = size(avw.img,1);
avw.img = avw.img(xdim:-1:1,:,:);
case 'y',
fprintf('...flipping Y\n');
ydim = size(avw.img,2);
avw.img = avw.img(:,ydim:-1:1,:);
case 'z',
fprintf('...flipping Z\n');
zdim = size(avw.img,3);
avw.img = avw.img(:,:,zdim:-1:1);
end
end
return