Doxygen Source Code Documentation
CheckPrefix.m
Go to the documentation of this file.00001 function [ans, Prefix] = PrefixStatus (Prefix)
00002 %
00003 % [Status, Prefix] = PrefixStatus (Name)
00004 %
00005 %Purpose:
00006 % Determines if the name chosen is a valid for an AFNI Brick
00007 % If you pass a name containing prefix only and no view then
00008 % View is assumed to be +orig
00009 %
00010 %
00011 %Input Parameters:
00012 % Name: a string containing an AFNI Prefix,
00013 % or Prefix and view moon+orig or
00014 % Prefix, view and extension moon+acpc.HEAD
00015 %
00016 %
00017 %
00018 %Output Parameters:
00019 % Status : -1 error
00020 % : 0 Read Only
00021 % : 1 Read Write
00022 % Prefix: The Prefix
00023 %
00024 %
00025 %Key Terms:
00026 %
00027 %More Info :
00028 %
00029 % The function checks for the existence of a brick with a similar
00030 % prefix
00031 %
00032 %
00033 % Author : Ziad Saad
00034 % Date : Wed Sep 19 10:30:05 EDT 2001
00035 % LBC/NIMH/ National Institutes of Health, Bethesda Maryland
00036
00037
00038 %Define the function name for easy referencing
00039 FuncName = 'CheckPrefix';
00040
00041 %Debug Flag
00042 DBG = 1;
00043
00044 %initailize return variables
00045 ans = 0;
00046
00047 %make sure you have no HEAD or BRIK as an extension
00048 [Prefix, Ext] = RemoveExtension(Prefix, '.HEAD|.BRIK'));
00049
00050 %make sure you have no view
00051 [Prefix, ViewName] = RemoveExtension(Prefix, '+orig|+acpc|+tlrc');
00052
00053 %check for conflict
00054 if (~isempty(Ext) & isempty(ViewName)),
00055 ans = -1;
00056 ErrEval(FuncName,'Err_Expected a correct view (+orig, +acpc or +tlrc) but found none.');
00057 return;
00058 end
00059
00060 if (~isempty(ViewName), View = ViewName; else View = '+orig'; end
00061
00062 %look for various files
00063 if (exist(sprintf('%s%s.HEAD', Prefix, View)) == 2), return; end
00064 if (exist(sprintf('%s%s.BRIK', Prefix, View)) == 2), return; end
00065
00066
00067
00068
00069 ans = 1;
00070 return;
00071