[376] | 1 | %'get_file_series': determine the list of file names and file indices for functions called by 'series'. |
---|
| 2 | %------------------------------------------------------------------------ |
---|
| 3 | % [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param) |
---|
| 4 | % |
---|
| 5 | % OUTPUT: |
---|
| 6 | % FileType: type of file |
---|
| 7 | % FileInfo: structure containing info on the file (case of images) |
---|
| 8 | % Object: in case of video |
---|
| 9 | % |
---|
| 10 | % INPUT: |
---|
| 11 | % fileinput: name, including path, of the file to analyse |
---|
| 12 | function [FileType,FileInfo,Object]=get_file_type(fileinput) |
---|
| 13 | FileType=''; |
---|
| 14 | FileInfo=[]; |
---|
| 15 | Object=[]; |
---|
| 16 | [tild,tild,FileExt]=fileparts(fileinput); |
---|
| 17 | |
---|
| 18 | switch FileExt |
---|
| 19 | case {'.civ','.log','.cmx','.cmx2','.txt','.bat'} |
---|
| 20 | FileType='txt'; |
---|
| 21 | case '.fig' |
---|
| 22 | FileType='figure'; |
---|
| 23 | case '.xml' |
---|
| 24 | FileType='xml'; |
---|
| 25 | case '.xls' |
---|
| 26 | FileType='xls'; |
---|
| 27 | otherwise |
---|
| 28 | if ~isempty(FileExt)&& ~isempty(imformats(FileExt(2:end))) |
---|
| 29 | try |
---|
| 30 | FileType='image'; |
---|
| 31 | imainfo=imfinfo(fileinput); |
---|
| 32 | if length(imainfo) >1 %case of image with multiple frames |
---|
| 33 | FileType='multimage'; |
---|
| 34 | FileInfo.NbFrame=length(imainfo); |
---|
| 35 | end |
---|
| 36 | end |
---|
| 37 | else |
---|
| 38 | try |
---|
| 39 | Data=nc2struct(fileinput,'ListGlobalAttribute','absolut_time_T0','Conventions',... |
---|
| 40 | 'CivStage','patch2','fix2','civ2','patch','fix'); |
---|
| 41 | if ~isempty(Data.absolut_time_T0') |
---|
| 42 | FileType='civx'; % test for civx velocity fields |
---|
| 43 | if ~isempty(Data.patch2) && isequal(Data.patch2,1) |
---|
| 44 | FileInfo.CivStage=6; |
---|
| 45 | elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) |
---|
| 46 | FileInfo.CivStage=5; |
---|
| 47 | elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); |
---|
| 48 | FileInfo.CivStage=4; |
---|
| 49 | elseif ~isempty(Data.patch) && isequal(Data.patch,1); |
---|
| 50 | FileInfo.CivStage=3; |
---|
| 51 | elseif ~isempty(Data.fix) && isequal(Data.fix,1); |
---|
| 52 | FileInfo.CivStage=2; |
---|
| 53 | elseif ~isempty(Data.absolut_time_T0) && ~isempty(Data.hart) |
---|
| 54 | FileInfo.CivStage=1; |
---|
| 55 | end |
---|
| 56 | elseif strcmp(Data.Conventions,'uvmat/civdata') |
---|
| 57 | FileType='civdata'; % test for civx velocity fields |
---|
| 58 | FileInfo.CivStage=Data.CivStage; |
---|
| 59 | else |
---|
| 60 | FileType='netcdf'; |
---|
| 61 | end |
---|
| 62 | end |
---|
| 63 | try |
---|
| 64 | if exist('VideoReader','file')%recent version of Matlab |
---|
| 65 | Object=VideoReader(fullfileinput); |
---|
| 66 | else |
---|
| 67 | Object=mmreader(fullfileinput);%older Matlab function for movies |
---|
| 68 | end |
---|
| 69 | FileType='video'; |
---|
| 70 | FileInfo.NbFrame=get(Object,'NumberOfFrames'); |
---|
| 71 | end |
---|
| 72 | end |
---|
| 73 | end |
---|