source: aedes_rot3d.m

Last change on this file was 120, checked in by tjniskan, 9 years ago
  • Fixed an indexing bug in aedes_readfid when reading multireceiver

EPI data

  • Added EPIPhasedArrayData -property to aedes_readfid for manually

getting the data from individual coils from multireceiver EPI data

  • Fixed aedes_rot3d to work with n-D arrays
  • Added 18 new ROI colors and removed the ROI number limitation

M aedes_rot3d.m
M aedes.m
M aedes_readfid.m
M aedes_revision.m

File size: 2.3 KB
RevLine 
[80]1function B = aedes_rot3d(A,k,dim)
2% AEDES_ROT3D - Rotate 3D (or 4D) matrix in 90 degree steps in 3 dimensions
[2]3%
4%
5% Synopsis:
6%
7% Description:
8%
9% Examples:
10%
11% See also:
12%
13
[39]14% This function is a part of Aedes - A graphical tool for analyzing
[36]15% medical images
[2]16%
[36]17% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
18%
[45]19% Department of Physics, Department of Neurobiology
[39]20% University of Kuopio, FINLAND
[36]21%
22% This program may be used under the terms of the GNU General Public
23% License version 2.0 as published by the Free Software Foundation
24% and appearing in the file LICENSE.TXT included in the packaging of
25% this program.
26%
27% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
[2]29
[36]30
[2]31if nargin<2
[80]32  error('AEDES_ROT3D: Too few input arguments!')
[2]33elseif nargin<3
34  dim = 3; % Use dim 3 as a default
35end
36
[120]37if ~( isnumeric(A) || islogical(A) )
[51]38  error('First input argument must be a numerical 3D (or 4D)-matrix!')
[2]39end
40
41if ~isnumeric(k) || ~any(k==[0 1 2 3 4])
42  error('The second input argument has to be a scalar 0,1,2,3, or 4!')
43end
44
[120]45dim_inds = 1:ndims(A);
46
[2]47switch dim
48  case 1
[120]49    dim_inds(1:3)=dim_inds(3:-1:1);
[53]50        if k==1 % Rotate 90 degrees along dim 1 (rows)
[120]51          B = flipdim(permute(A,dim_inds),1);
[53]52        elseif k==2 % Rotate 180 degrees along dim 1 (rows)
53          B = flipdim(flipdim(A,3),1);
54    elseif k==3 % Rotate 270 degrees along dim 1 (rows)
[120]55          B = flipdim(permute(A,dim_inds),3);
[53]56        elseif k==0 || k==4
57          B=A;
58        end
59  case 2
[120]60    dim_inds(2:3)=dim_inds(3:-1:2);
[53]61        if k==1 % Rotate 90 degrees along dim 2 (cols)
[120]62      B = flipdim(permute(A,dim_inds),3);
[53]63    elseif k==2 % Rotate 180 degrees along dim 2 (cols)
[2]64      B = flipdim(flipdim(A,3),2);
[53]65    elseif k==3 % Rotate 270 degrees along dim 2 (cols)
[120]66      B = flipdim(permute(A,dim_inds),2);
[2]67    elseif k==0 || k==4
68      B=A;
[53]69        end
[2]70  case 3
[120]71    dim_inds(1:2)=dim_inds(2:-1:1);
[2]72    if k==1 % Rotate 90 degrees along dim 3
[120]73      B = flipdim(permute(A,dim_inds),1);
[2]74    elseif k==2 % Rotate 180 degrees along dim 3
75      B = flipdim(flipdim(A,2),1);
76    elseif k==3 % Rotate 270 degrees along dim 3
[120]77      B = flipdim(permute(A,dim_inds),2);
[2]78    elseif k==0 || k==4
79      B=A;
[51]80        end
[2]81  otherwise
82    return
83end
Note: See TracBrowser for help on using the repository browser.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008