-
Notifications
You must be signed in to change notification settings - Fork 0
/
pfGetHSTFilenames.m
63 lines (52 loc) · 1.78 KB
/
pfGetHSTFilenames.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function [fname,fpath]=pfGetHSTFilenames(full_fname)
% check for file existence
if ~any(strcmp(full_fname(end-2:end),{'xml','raw','vol'}))
% disp('No valid extension (vol,raw,xml) supplied')
full_fname(end+1)='.'; % append a pseudo extension
end
[fpath,filename,fext]=fileparts(full_fname);
% fileparts doesn't work if the filename is supplied
if ~isempty(fpath)
% disp('Path supplied')
fpath=[fpath filesep];
else
% disp('NO path supplied');
fpath=[pwd filesep];
end
% *** replace this with (sub?) function to strip extensions
switch fext
case '.xml' % user has specified the .xml file
% is it a vol.xml or a raw.xml?
if strcmp(filename(end-2:end),'vol')
fname.vol=[fpath filename];
fname.xml=[fpath filename fext];
[tmp,fname.prefix]=fileparts(fname.vol);
elseif strcmp(filename(end-2:end),'raw')
fname.raw=[fpath filename];
fname.info=[fpath filename '.info'];
[tmp,fname.prefix]=fileparts(fname.raw);
end
case '.vol' % user has specified the .vol file
fname.vol=[fpath filename fext];
fname.xml=[fpath filename fext '.xml'];
[tmp,fname.prefix]=fileparts(fname.vol);
case '.raw'
fname.raw=[fpath filename fext];
fname.info=[fpath filename fext '.info'];
[tmp,fname.prefix]=fileparts(fname.raw);
case '.' % user supplied without extension
% disp('No extension supplied');
if exist([fpath filename '.vol'],'file')
% 32 bit
fname.vol=[fpath filename '.vol'];
fname.xml=[fpath filename '.vol.xml'];
elseif exist([fpath filename '.raw'],'file')
fname.raw=[fpath filename '.raw'];
fname.info=[fpath filename '.info'];
else
error('No file found')
end
[tmp,fname.prefix]=fileparts(full_fname);
otherwise
error('Sorry- not understood')
end