


Platform specific configuration parameters for SPM
FORMAT ans = spm_platform(arg)
arg - optional string argument, can be
- 'bigend' - return whether this architecture is bigendian
- Inf - is not IEEE floating point
- 0 - is little end
- 1 - big end
- 'filesys' - type of filesystem
- 'unx' - UNIX
- 'win' - DOS
- 'mac' - Macintosh
- 'vms' - VMS
- 'sepchar' - returns directory separator
- 'rootlen' - returns number of chars in root directory name
- 'user' - returns username
- 'tempdir' - returns name of temp directory
- 'drives' - returns string containing valid drive letters
FORMAT PlatFontNames = spm_platform('fonts')
Returns structure with fields named after the generic (UNIX) fonts, the
field containing the name of the platform specific font.
FORMAT PlatFontName = spm_platform('font',GenFontName)
Maps generic (UNIX) FontNames to platform specific FontNames
FORMAT PLATFORM = spm_platform('init',comp)
Initialises platform specific parameters in persistent PLATFORM
(External gateway to init_platform(comp) subfunction)
comp - computer to use [defaults to MatLab's `computer`]
PLATFORM - copy of persistent PLATFORM
FORMAT spm_platform
Initialises platform specific parameters in persistent PLATFORM
(External gateway to init_platform(computer) subfunction)
----------------
SUBfunctionS:
FORMAT init_platform(comp)
Initialise platform specific parameters in persistent PLATFORM
comp - computer to use [defaults to MatLab's `computer`]
-----------------------------------------------------------------------
Sinic_e calls to spm_platform will be made frequently, most platform
specific parameters are stored as a structure in the persistent variable
PLATFORM. Subsequent calls use the information from this persistent
variable, if it exists.
Platform specific difinitions are contained in the data structures at
the beginning of the init_platform subfunction at the end of this
file.
_______________________________________________________________________
Copyright (C) 2005 Wellcome Department of Imaging Neuroscienic_e



0001 function varargout=nic_spm_platform(varargin) 0002 % Platform specific configuration parameters for SPM 0003 % 0004 % FORMAT ans = spm_platform(arg) 0005 % arg - optional string argument, can be 0006 % - 'bigend' - return whether this architecture is bigendian 0007 % - Inf - is not IEEE floating point 0008 % - 0 - is little end 0009 % - 1 - big end 0010 % - 'filesys' - type of filesystem 0011 % - 'unx' - UNIX 0012 % - 'win' - DOS 0013 % - 'mac' - Macintosh 0014 % - 'vms' - VMS 0015 % - 'sepchar' - returns directory separator 0016 % - 'rootlen' - returns number of chars in root directory name 0017 % - 'user' - returns username 0018 % - 'tempdir' - returns name of temp directory 0019 % - 'drives' - returns string containing valid drive letters 0020 % 0021 % FORMAT PlatFontNames = spm_platform('fonts') 0022 % Returns structure with fields named after the generic (UNIX) fonts, the 0023 % field containing the name of the platform specific font. 0024 % 0025 % FORMAT PlatFontName = spm_platform('font',GenFontName) 0026 % Maps generic (UNIX) FontNames to platform specific FontNames 0027 % 0028 % FORMAT PLATFORM = spm_platform('init',comp) 0029 % Initialises platform specific parameters in persistent PLATFORM 0030 % (External gateway to init_platform(comp) subfunction) 0031 % comp - computer to use [defaults to MatLab's `computer`] 0032 % PLATFORM - copy of persistent PLATFORM 0033 % 0034 % FORMAT spm_platform 0035 % Initialises platform specific parameters in persistent PLATFORM 0036 % (External gateway to init_platform(computer) subfunction) 0037 % 0038 % ---------------- 0039 % SUBfunctionS: 0040 % 0041 % FORMAT init_platform(comp) 0042 % Initialise platform specific parameters in persistent PLATFORM 0043 % comp - computer to use [defaults to MatLab's `computer`] 0044 % 0045 %----------------------------------------------------------------------- 0046 % 0047 % Sinic_e calls to spm_platform will be made frequently, most platform 0048 % specific parameters are stored as a structure in the persistent variable 0049 % PLATFORM. Subsequent calls use the information from this persistent 0050 % variable, if it exists. 0051 % 0052 % Platform specific difinitions are contained in the data structures at 0053 % the beginning of the init_platform subfunction at the end of this 0054 % file. 0055 %_______________________________________________________________________ 0056 % Copyright (C) 2005 Wellcome Department of Imaging Neuroscienic_e 0057 0058 % Matthew Brett 0059 % $Id: spm_platform.m 250 2005-10-07 16:08:39Z john $ 0060 0061 0062 0063 %-Initialise 0064 %----------------------------------------------------------------------- 0065 persistent PLATFORM 0066 if isempty(PLATFORM), PLATFORM = init_platform; end 0067 0068 if nargin==0, return, end 0069 0070 0071 switch lower(varargin{1}), case 'init' %-(re)initialise 0072 %======================================================================= 0073 init_platform(varargin{2:end}) 0074 varargout = {PLATFORM}; 0075 0076 case 'bigend' %-Return endian for this architecture 0077 %======================================================================= 0078 varargout = {PLATFORM.bigend}; 0079 if ~finite(PLATFORM.bigend), 0080 if isnan(PLATFORM.bigend) 0081 error(['I don''t know if "',computer,'" is big-endian.']) 0082 else 0083 error(['I don''t think that "',computer,... 0084 '" uses IEEE floating point ops.']) 0085 end 0086 end 0087 0088 case 'filesys' %-Return file system 0089 %======================================================================= 0090 varargout = {PLATFORM.filesys}; 0091 0092 case 'sepchar' %-Return file separator character 0093 %======================================================================= 0094 warning('use filesep instead (supported by MathWorks)') 0095 varargout = {PLATFORM.sepchar}; 0096 0097 case 'rootlen' %-Return length in chars of root directory name 0098 %======================================================================= 0099 varargout = {PLATFORM.rootlen}; 0100 0101 case 'user' %-Return user string 0102 %======================================================================= 0103 varargout = {PLATFORM.user}; 0104 0105 case 'drives' %-Return drives 0106 %======================================================================= 0107 varargout = {PLATFORM.drives}; 0108 0109 case 'tempdir' %-Return temporary directory 0110 %======================================================================= 0111 twd = getenv('SPMTMP'); 0112 if isempty(twd) 0113 twd = tempdir; 0114 end 0115 varargout = {twd}; 0116 0117 0118 case {'font','fonts'} %-Map default font names to platform font names 0119 %======================================================================= 0120 if nargin<2, varargout={PLATFORM.font}; return, end 0121 switch lower(varargin{2}) 0122 case 'times' 0123 varargout = {PLATFORM.font.times}; 0124 case 'courier' 0125 varargout = {PLATFORM.font.courier}; 0126 case 'helvetica' 0127 varargout = {PLATFORM.font.helvetica}; 0128 case 'symbol' 0129 varargout = {PLATFORM.font.symbol}; 0130 otherwise 0131 warning(['Unknown font ',varargin{2},', using default']) 0132 varargout = {PLATFORM.font.helvetica}; 0133 end 0134 0135 otherwise %-Unknown Action string 0136 %======================================================================= 0137 error('Unknown Action string') 0138 0139 %======================================================================= 0140 end 0141 0142 0143 0144 %======================================================================= 0145 %- S U B - F U N C T I O N S 0146 %======================================================================= 0147 0148 0149 function PLATFORM = init_platform(comp) %-Initialise platform variables 0150 %======================================================================= 0151 if nargin<1, comp=computer; end 0152 0153 %-Platform definitions 0154 %----------------------------------------------------------------------- 0155 PDefs = { 'PCWIN', 'win', 0;... 0156 'MAC', 'unx', 1;... 0157 'SUN4', 'unx', 1;... 0158 'SOL2', 'unx', 1;... 0159 'HP700', 'unx', 1;... 0160 'SGI', 'unx', 1;... 0161 'SGI64', 'unx', 1;... 0162 'IBM_RS', 'unx', 1;... 0163 'ALPHA', 'unx', 0;... 0164 'AXP_VMSG', 'vms', Inf;... 0165 'AXP_VMSIEEE', 'vms', 0;... 0166 'LNX86', 'unx', 0;... 0167 'GLNX86', 'unx', 0;... 0168 'GLNXA64', 'unx', 0;... 0169 'VAX_VMSG', 'vms', Inf;... 0170 'VAX_VMSD', 'vms', Inf }; 0171 0172 PDefs = cell2struct(PDefs,{'computer','filesys','endian'},2); 0173 0174 0175 %-Which computer? 0176 %----------------------------------------------------------------------- 0177 ci = find(strcmp({PDefs.computer},comp)); 0178 if isempty(ci), error([comp,' not supported architecture for SPM']), end 0179 0180 0181 %-Set bigend 0182 %----------------------------------------------------------------------- 0183 PLATFORM.bigend = PDefs(ci).endian; 0184 0185 0186 %-Set filesys 0187 %----------------------------------------------------------------------- 0188 PLATFORM.filesys = PDefs(ci).filesys; 0189 0190 0191 %-Set filesystem dependent stuff 0192 %----------------------------------------------------------------------- 0193 %-File separators character 0194 %-Length of root directory strings 0195 %-User name finding 0196 %-(mouse button labels?) 0197 switch (PLATFORM.filesys) 0198 case 'unx' 0199 PLATFORM.sepchar = '/'; 0200 PLATFORM.rootlen = 1; 0201 PLATFORM.user = getenv('USER'); 0202 case 'win' 0203 PLATFORM.sepchar = '\'; 0204 PLATFORM.rootlen = 3; 0205 PLATFORM.user = getenv('USERNAME'); 0206 if isempty(PLATFORM.user) 0207 PLATFORM.user = 'anon'; 0208 end 0209 otherwise 0210 error(['Don''t know filesystem ',PLATFORM.filesys]) 0211 end 0212 0213 %-Drives 0214 %----------------------------------------------------------------------- 0215 PLATFORM.drives = ''; 0216 if strcmp(comp,'PCWIN'), 0217 driveLett = cellstr(char(('C':'Z')')); 0218 for i=1:numel(driveLett), 0219 if exist([driveLett{i} ':\']) == 7, 0220 PLATFORM.drives = [PLATFORM.drives driveLett{i}]; 0221 end 0222 end 0223 end 0224 0225 %-Fonts 0226 %----------------------------------------------------------------------- 0227 switch comp 0228 case {'SOL2'} %-Some Sol2 platforms give segmentation violations with Helvetica 0229 PLATFORM.font.helvetica = 'Lucida'; 0230 PLATFORM.font.times = 'Times'; 0231 PLATFORM.font.courier = 'Courier'; 0232 PLATFORM.font.symbol = 'Symbol'; 0233 case {'SUN4','SOL2','HP700','SGI','SGI64','IBM_RS','ALPHA','LNX86','GLNX86','GLNXA64','MAC'} 0234 PLATFORM.font.helvetica = 'Helvetica'; 0235 PLATFORM.font.times = 'Times'; 0236 PLATFORM.font.courier = 'Courier'; 0237 PLATFORM.font.symbol = 'Symbol'; 0238 case {'PCWIN'} 0239 PLATFORM.font.helvetica = 'Arial Narrow'; 0240 PLATFORM.font.times = 'Times New Roman'; 0241 PLATFORM.font.courier = 'Courier New'; 0242 PLATFORM.font.symbol = 'Symbol'; 0243 end