Ignore:
Timestamp:
Jun 5, 2014, 10:39:28 PM (10 years ago)
Author:
sommeria
Message:

-pb of mulitple tiff reading solved
-modif of output parma in get-file_type and find_file_series

  • introduction of transform/ima_noise_rms
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_file_series.m

    r667 r783  
    11%'find_file_series': check the content of an input file and find the corresponding file series
    22%--------------------------------------------------------------------------
    3 % function [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object,i1_input,i2_input,j1_input,j2_input]=find_file_series(fileinput)
     3% function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,Object,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput,checkxml)
    44%
    55% OUTPUT:
     6% RootPath: path to the dir containing the input file
     7% SubDir: data dir containing the input file series
    68% RootFile: root file detected in fileinput, possibly modified for movies (indexing is then done on image view, not file)
    79% i1_series(pair,ref_j+1, ref_i+1),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
    810%  (ref_i+1 is used to deal with the image index zero sometimes used)
    911% NomType: nomenclature type corrected after checking the first file (problem of 0 before the number string)
    10 % FileType: type of file, =
    11 %       = 'image', usual image as recognised by Matlab
    12 %       = 'multimage', image series stored in a single file
    13 %       = 'civx', netcdf file with civx convention
    14 %       = 'civdata', civ data with new convention
    15 %       = 'netcdf' other netcdf files
    16 %       = 'video': movie recognised by VideoReader (e;g. avi)
    17 % MovieObject: video object (=[] otherwise)
     12% FileInfo: structure containing info on the input files (assumed identical on the whole series)
     13    % FileInfo.FileType: type of file, =
     14    %       = 'image', usual image as recognised by Matlab
     15    %       = 'multimage', image series stored in a single file
     16    %       = 'civx', netcdf file with civx convention
     17    %       = 'civdata', civ data with new convention
     18    %       = 'netcdf' other netcdf files
     19    %       = 'video': movie recognised by VideoReader (e;g. avi)
     20% MovieObject: video object (=[] otherwise
     21% i1_input,i2_input,j1_input,j2_input: indices of the input file, or of the first file in the series if the input file does not exist
    1822%
    1923%INPUT
    20 % RootPath: path to the directory to be scanned
     24% FilePath: path to the directory to be scanned
    2125% fileinput: name (without path) of the input file sample
    2226% checkxml: =1(default) take into account xml file existence to possibly include indexes in RootFile
     
    3943%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    4044
    41 function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput,checkxml)
     45function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput,checkxml)
    4246%------------------------------------------------------------------------
    4347
     
    5256j1_series=zeros(1,1,1);
    5357j2_series=zeros(1,1,1);
    54 [FileType,FileInfo,MovieObject]=get_file_type(fullfileinput);
     58[FileInfo,MovieObject]=get_file_type(fullfileinput);
    5559if ~exist(FilePath,'dir')
    5660    return % don't go further if the dir path does not exist
     
    233237        NomType=regexprep(NomType,['^' NomTypePref],'');
    234238        %% update the file type if the input file does not exist (pb of 0001)
    235         if isempty(FileType)
    236             [FileType,FileInfo,MovieObject]=get_file_type(fullfile(FilePath,dirpair(ifile_min).name));
     239        if isempty(FileInfo.FileType)
     240            [FileInfo,MovieObject]=get_file_type(fullfile(FilePath,dirpair(ifile_min).name));
    237241        end
    238242    end
     
    247251%% introduce the frame index in case of movies or multimage type
    248252if isfield(FileInfo,'NumberOfFrames') && FileInfo.NumberOfFrames >1
    249     if isempty(i1_series)
     253    if isempty(i1_series)% if there is no file index, i denotes the frame index
    250254        i1_series=zeros(FileInfo.NumberOfFrames+1,2);% first column =0
    251255        i1_series(:,2)=(0:FileInfo.NumberOfFrames)'; % second column=frame index -1
    252256        i1_input=1;
    253257        NomType='*';
    254     else
    255         i1_series=i1_series(:,2)*ones(1,FileInfo.NumberOfFrames);
    256         i1_series=[zeros(size(i1_series,1),1) i1_series];
    257         j1_series=ones(size(i1_series,1),1)*(1:FileInfo.NumberOfFrames);
    258         j1_series=[zeros(size(i1_series,1),1) j1_series];
    259         %  include the first index in the root name
    260         r=regexp(NomType,'^(?<tiretnum>_?\d+)','names');%look for a number or _1 at the beginning of NomType
    261         if ~isempty(r)
    262             fileinput_end=regexprep(fileinput,['^' RootFile],'');%remove RootFile at the beginning of fileinput
    263             if isempty(regexp(r.tiretnum,'^_','once'))% if a separator '_' is not  detected
    264                 rr=regexp(fileinput_end,'^(?<i1>\d+)','names');
    265             else% if a separator '_' is  detected
    266                 rr=regexp(fileinput_end,'^(?<i1>_\d+)','names');
    267             end
    268             if ~isempty(rr)
    269 %                 RootFile=[RootFile rr.i1];% new root file
    270 %                 NomTypePref=r.tiretnum;
    271 %                 NomType=regexprep(NomType,['^'  NomTypePref],'');
    272               %  i1_input=j1_input;
    273               %  i2_input=j2_input;
    274                 j1_input=1;
    275                 j2_input=[];
     258    else  % if there is a file index, j denotes the frame index while i denotes the file index
     259        if strcmp(NomType(end-1:end),'ab')% recognized as a pair
     260            RootFile=fullfile_uvmat('','',RootFile,'',NomType,i1_input,i2_input,j1_input,j2_input);% restitute the root name without the detected indices       
     261            i1_series=zeros(FileInfo.NumberOfFrames+1,2);% first column =0
     262            i1_series(:,2)=(0:FileInfo.NumberOfFrames)'; % second column=frame index -1
     263            j1_series=[];
     264            i1_input=1;
     265            NomType='*';
     266        else
     267            i1_series=i1_series(:,2)*ones(1,FileInfo.NumberOfFrames);%
     268            i1_series=[zeros(size(i1_series,1),1) i1_series];
     269            j1_series=ones(size(i1_series,1),1)*(1:FileInfo.NumberOfFrames);%
     270            j1_series=[zeros(size(i1_series,1),1) j1_series];
     271            %  include the first index in the root name
     272            r=regexp(NomType,'^(?<tiretnum>_?\d+)','names');%look for a number or _1 at the beginning of NomType
     273            if ~isempty(r)
     274                fileinput_end=regexprep(fileinput,['^' RootFile],'');%remove RootFile at the beginning of fileinput
     275                if isempty(regexp(r.tiretnum,'^_','once'))% if a separator '_' is not  detected
     276                    rr=regexp(fileinput_end,'^(?<i1>\d+)','names');
     277                else% if a separator '_' is  detected
     278                    rr=regexp(fileinput_end,'^(?<i1>_\d+)','names');
     279                end
     280                if ~isempty(rr)
     281                    j1_input=1;
     282                    j2_input=[];
     283                end
    276284            end
    277285        end
Note: See TracChangeset for help on using the changeset viewer.