Skip to content

AFNI/NIfTI Server

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

Doxygen Source Code Documentation


GetAfniSliceTriplet.m

Go to the documentation of this file.
00001 function [err, slc] = GetAfniSliceTriplet (Brik, BrikInfo, DM, Opt)
00002 %
00003 %   [err, slc] = GetAfniSliceTriplet (Brik, BrikInfo, DM, Opt)
00004 %
00005 %Purpose:
00006 %   Get the slices to display as they appear in the AFNI window
00007 %   
00008 %   
00009 %Input Parameters:
00010 %   Brik: is a vector or a matrix containing the brik values
00011 %   BrikInfo is a structure containing Header info
00012 %      (both are output by BrikLoad function)
00013 %
00014 %   DM is the output of function AFNI_SliceDispManip
00015 %
00016 %   Opt is a an options structure with the following fields
00017 %    .iSlc is an 1x3 vector with the Axial, Sagittal and Coronal slice indices to show (a la AFNI, first slice is indexed 0)
00018 %        for examle [45 12 3] retrieves Axial slice 45, Sagittal slice 12 and Coronal slice 3.
00019 %        if you need just one slice, then pass -1 where you do not need any slices
00020 %        for example [45 -1 3] retrieves the axial and coronal slices only
00021 %   .index is the sub-brick index, default is 0
00022 %
00023 %Output Parameters:
00024 %   err : 0 No Problem
00025 %       : 1 Mucho Problems
00026 %   slc is a structure [3x1] vector containing the slices requested in .iSlc
00027 %                       (where iSlc is -1, slc is empty)
00028 %    .M   [N x M] the slice as present in the brick
00029 %    .Mdisp [O x P] the slice ready for display
00030 %   
00031 %      
00032 %Key Terms:
00033 %   
00034 %More Info :
00035 %   Test_DispAFNISlice
00036 %   GetSurfSliceTriplet
00037 %
00038 %
00039 %     Author : Ziad Saad
00040 %     Date : Tue Aug 22 18:36:04 PDT 2000
00041 %     LBC/NIMH/ National Institutes of Health, Bethesda Maryland
00042 %    last modified: Mon Aug 27 13:29:42 PDT 2001
00043 
00044 
00045 %Define the function name for easy referencing
00046 FuncName = 'GetAfniSliceTriplet';
00047 
00048 %Debug Flag
00049 DBG = 1;
00050 
00051 %initailize return variables
00052 err = 1;
00053 
00054 %turn Brick into a matrix if it isn't already
00055 if (ndims(Brik) < 3),
00056         Brik = reshape(Brik, BrikInfo.DATASET_DIMENSIONS(1), BrikInfo.DATASET_DIMENSIONS(2),...
00057                                                 BrikInfo.DATASET_DIMENSIONS(3), BrikInfo.DATASET_RANK(2));
00058 end
00059 
00060 if (~isfield(Opt, 'index') | isempty(Opt.index)), 
00061         Opt.index = 0;
00062 end
00063 
00064 for (ip = 1:1:3),
00065         if (Opt.iSlc(ip) > 0),
00066                 
00067                 if (DM(ip).zflip), 
00068                         %added -1 on Mon Aug 27 13:29:42 PDT 2001
00069                         Opt.iSlc(ip) = BrikInfo.DATASET_DIMENSIONS(DM(ip).SliceDim) - Opt.iSlc(ip) -1;
00070                 end
00071 
00072                 %grab the slices
00073                 switch DM(ip).SliceDim,
00074                         case 1,                                 
00075                                 slc(ip).M = permute(Brik(Opt.iSlc(ip)+1, :, : , Opt.index+1), [2 3 1]);
00076                         case 2
00077                                 slc(ip).M = permute(Brik(:, Opt.iSlc(ip)+1, :, Opt.index+1), [1 3 2]); 
00078                         case 3
00079                                 slc(ip).M = Brik(:, :, Opt.iSlc(ip)+1, Opt.index+1);
00080                 end 
00081                 %now manipulate them to have them display properly 
00082                         if (DM(ip).orpermute), slc(ip).Mdisp = permute(slc(ip).M,[2 1]);        
00083                                 else slc(ip).Mdisp = slc(ip).M; end
00084                         if (DM(ip).udflip), slc(ip).Mdisp = flipud(slc(ip).Mdisp);      end
00085                         if (DM(ip).lrflip), slc(ip).Mdisp = fliplr(slc(ip).Mdisp);      end
00086         else
00087                 slc(ip).M = [];
00088                 slc(ip).Mdisp = [];
00089         end
00090 end %plane
00091 
00092 err = 0;
00093 return;
00094 
 

Powered by Plone

This site conforms to the following standards: