Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


AFNI_SliceDispManip.m

Go to the documentation of this file.
00001 function [DispManip] = AFNI_SliceDispManip (B_Info)
00002 %
00003 %   [DispManip] = AFNI_SliceDispManip (B_Info)
00004 %
00005 %Purpose:
00006 %   
00007 %   Determine the manipulations necessary to apply to a 
00008 %  slice for proper display a la AFNI
00009 %   
00010 %Input Parameters:
00011 %   B_Info the output of BrickInfo function
00012 %   
00013 %   
00014 %Output Parameters:
00015 %   err : 0 No Problem
00016 %       : 1 Mucho Problems
00017 %   DispManip is a 3x1 structure with the following structures
00018 %      .plane : 2 character string specifying the plane ('Ax', 'Sa', Co')
00019 %            this is a bit redundant since the three elements of 
00020 %             DispManip always refer to 'Ax', 'Sa', 'Co', respectively
00021 %   .SliceDim : The dimension in Brik that the slices are stored in
00022 %      .zflip : must flip in the z-dimension 
00023 %
00024 % The following flags are used for manipulating the slice once extracted
00025 % from the brik. Think of them as being applied to .orient matrix to produce
00026 % .Disporient matrix which is what AFNI displays
00027 %      .orpermute 
00028 %      .udflip
00029 %      .lrflip
00030 %
00031 %      .orient : a 2x2 character matrix. The 1st and 2nd rows indicates 
00032 %          the orientation  of the voxels in the 1st  and 2nd dimension 
00033 %          of the slice as stored in the Brik, respectively.
00034 %      .Disporient : this represents the slice orientations once the 
00035 %          manipulatons are performed on the slices (or .orient)
00036 % 
00037 %Key Terms:
00038 %   
00039 %More Info :
00040 %   see GetAfniSliceTriplet
00041 %   and GetSurfSliceTriplet
00042 %   
00043 %
00044 %     Author : Ziad Saad
00045 %     Date : Wed Sep 20 15:53:29 PDT 2000
00046 %     LBC/NIMH/ National Institutes of Health, Bethesda Maryland
00047 
00048 
00049 %Define the function name for easy referencing
00050 FuncName = 'AFNI_SliceDispManip';
00051 
00052 %Debug Flag
00053 DBG = 1;
00054 
00055 for (i = 1:1:3),
00056         switch i,
00057                 case 1,
00058                         DispManip(i).plane = 'Ax';
00059                         [DispManip(i).SliceDim,SliceDim_col] = find(B_Info.Orientation == 'I'); %The first slice should be the Inferior one
00060                 case 2,
00061                         DispManip(i).plane = 'Sa';
00062                         [DispManip(i).SliceDim,SliceDim_col] = find(B_Info.Orientation == 'L'); %The first slice should be the left one
00063                 case 3,
00064                         DispManip(i).plane = 'Co';              
00065                         [DispManip(i).SliceDim,SliceDim_col] = find(B_Info.Orientation == 'A'); %The first slice should be the Anterior one     
00066         end
00067         
00068         %determine if flipping in Z-dimension is necessary
00069         if (SliceDim_col == 2), DispManip(i).zflip = 1; 
00070                 else DispManip(i).zflip = 0; 
00071         end
00072         
00073         switch DispManip(i).SliceDim, %determine the Brik dimensions that contain the slice
00074                 case 1, % slices are in the first dimension
00075                         DispManip(i).d = [2 3];
00076                 case 2, %slices are in the second dimension
00077                         DispManip(i).d = [1 3];
00078                 case 3, 
00079                         DispManip(i).d = [1 2];
00080         end
00081         
00082         %determine orientation in slice plane
00083                 DispManip(i).orient = B_Info.Orientation(DispManip(i).d,:);
00084         
00085         %determine what manipulatons are required to have the slices display as in AFNI
00086         DispManip(i).udflip = 0;
00087         DispManip(i).lrflip = 0;
00088         DispManip(i).orpermute = 0;
00089         switch i, %different planes
00090                 case 1,
00091                         [iA,jA] = find (DispManip(i).orient == 'A'); [iL,jL] = find (DispManip(i).orient == 'R'); 
00092                         if (iA == 2),  %must permute orders, A--P must be along the columns),
00093                                 DispManip(i).orpermute = 1;             end
00094                         if (jA == 2), %must flip up to down, the column dimention should go in A--P not P--A
00095                                 DispManip(i).udflip = 1; end
00096                         if (jL == 2), %must go L--R (radiologic format)
00097                                 DispManip(i).lrflip = 1; end
00098                 case 2,
00099                         [iA,jA] = find (DispManip(i).orient == 'S'); [iL,jL] = find (DispManip(i).orient == 'A'); 
00100                         if (iA == 2),  %must permute orders, S--I must be along the columns),
00101                                 DispManip(i).orpermute = 1;             end
00102                         if (jA == 2), %must flip up to down, the column dimention should go in S--I not I--S
00103                                 DispManip(i).udflip = 1; end
00104                         if (jL == 2), %must go A--S not S--A
00105                                 DispManip(i).lrflip = 1; end
00106                 case 3,
00107                         [iA,jA] = find (DispManip(i).orient == 'S'); [iL,jL] = find (DispManip(i).orient == 'R'); 
00108                         if (iA == 2),  %must permute orders, S--I must be along the columns),
00109                                 DispManip(i).orpermute = 1;             end
00110                         if (jA == 2), %must flip up to down, the column dimention should go in S--I not I--S
00111                                 DispManip(i).udflip = 1; end
00112                         if (jL == 2), %must go L--R (radiologic format)
00113                                 DispManip(i).lrflip = 1; end    
00114         end 
00115 
00116         %apply the manipulations to the slice orientation matrix, this is good for debugging
00117                 DispManip(i).Disporient = DispManip(i).orient;
00118                 if (DispManip(i).orpermute), DispManip(i).Disporient = permute(DispManip(i).orient,[2 1]); end
00119                 if (DispManip(i).udflip), DispManip(i).Disporient = flipud(DispManip(i).Disporient); end
00120                 if (DispManip(i).lrflip), DispManip(i).Disporient = fliplr(DispManip(i).Disporient); end
00121 
00122 end
00123 
00124 
00125 
00126 err = 0;
00127 return;
00128 
 

Powered by Plone

This site conforms to the following standards: