Ignore:
Timestamp:
Jan 14, 2012, 1:44:13 PM (12 years ago)
Author:
sommeria
Message:

various bug fixes with file indexing. mode displacement from a fixed image introduced.
PIV stereo suppressed (todo: introduce in the GUI series).
find_file_series cleaned, with a change in the function arguments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_file_series.m

    r365 r371  
    44%
    55% OUTPUT:
    6 % RootPath,RootFile: root path and root name detected in fileinput, possibly modified for movies (indexing is then done on image view, not file)
     6% RootFile: root file detected in fileinput, possibly modified for movies (indexing is then done on image view, not file)
    77% i1_series(ref_i+1, ref_j+1,pair),i2_series,j1_series,j2_series: set of indices (i1,i2,j1,j2) sorted by ref index ref_i, ref_j, and pairindex in case of multiple pairs with the same ref
    88%  (ref_i+1 is used to deal with the image index zero sometimes used)
     
    1818%
    1919%INPUT
    20 % fileinput: name (including path)  of the input file
     20% RootPath: path to the directory to be scanned
     21% fileinput: name (without path) of the input file sample
    2122%
    2223%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
     
    3637%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    3738
    38 function [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(fileinput)
     39function [RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(RootPath,fileinput)
    3940%------------------------------------------------------------------------
    4041
    4142%% get input root name and nomenclature type
    42 [RootPath,SubDir,RootFile,tild,i2_input,j1_input,j2_input,FileExt,NomType]=fileparts_uvmat(fileinput);
     43[tild,tild,RootFile,tild,i2_input,j1_input,j2_input,FileExt,NomType]=fileparts_uvmat(fileinput);
     44fullfileinput=fullfile(RootPath,fileinput);
    4345
    4446%% check for particular file types: images, movies, civ data
     
    4951j1_series=zeros(1,1,1);
    5052j2_series=zeros(1,1,1);
     53
    5154switch FileExt
    5255    % ancillary files, no field indexing
     
    6467        NomType='';
    6568    otherwise
     69     
    6670        if ~isempty(FileExt)&& ~isempty(imformats(FileExt(2:end)))
    6771            try
    68                 imainfo=imfinfo(fileinput);
     72                imainfo=imfinfo(fullfileinput);
    6973                FileType='image';
    7074                if length(imainfo) >1 %case of image with multiple frames
     
    7276                    FileType='multimage';
    7377                    i1_series=(1:length(imainfo))';
    74                     [RootPath,RootFile]=fileparts(fileinput);
     78                    [RootPath,RootFile]=fileparts(fullfileinput);
    7579                end
    7680            end
    7781        else
    7882            try
    79                 Data=nc2struct(fileinput,'ListGlobalAttribute','absolut_time_T0','Conventions');
     83                Data=nc2struct(fullfileinput,'ListGlobalAttribute','absolut_time_T0','Conventions');
    8084                if ~isempty(Data.absolut_time_T0')
    8185                    FileType='civx'; % test for civx velocity fields
     
    8892            try
    8993                if exist('VideoReader','file')%recent version of Matlab
    90                     Object=VideoReader(fileinput);
     94                    Object=VideoReader(fullfileinput);
    9195                else
    92                     Object=mmreader(fileinput);%older Matlab function for movies
     96                    Object=mmreader(fullfileinput);%older Matlab function for movies
    9397                end
    9498                NomType='*';
     
    100104
    101105if strcmp(NomType,'')||strcmp(NomType,'*')
    102     if exist(fileinput,'file')
    103         [RootPath,RootFile]=fileparts(fileinput);% case of constant name (no indexing)
    104     else
    105         RootPath='';
     106    if exist(fullfileinput,'file')
     107        [tild,RootFile]=fileparts(fileinput);% case of constant name (no indexing)
     108    else     
    106109        RootFile='';
    107110    end
     
    163166        end
    164167    end
    165     detect_string=[sep1 i1_str sep2 i2_str sep3 j1_str sep4 j2_str];%string used in regexp to detect file indices
     168    detect_string=['^' RootFile sep1 i1_str sep2 i2_str sep3 j1_str sep4 j2_str FileExt '$'];%string used in regexp to detect file indices
    166169    %find the string used to extract the relevant files with the command dir
    167     star_string=['*' sep1 i1_star sep2 i2_star sep3 j1_star sep4 j2_star '*'];
     170    star_string=[RootFile sep1 i1_star sep2 i2_star sep3 j1_star sep4 j2_star '*'];
    168171    wd=pwd;%current working directory
    169     RR=fullfile(RootPath,SubDir);
    170     cd (RR)% move to the local dir to save time in the operation dir.
    171     dirpair=dir([RootFile star_string FileExt]);% look for relevant files in the file directory
     172    %RR=fullfile(RootPath,SubDir);
     173    cd (RootPath)% move to the local dir to save time in the operation dir.
     174    dirpair=dir([star_string FileExt]);% look for relevant files in the file directory
    172175    cd(wd)
    173176    nbpair=numel(dirpair);
Note: See TracChangeset for help on using the changeset viewer.