[757] | 1 | %'get_file_series': determine the list of input file names and file indices for functions called by 'series'. |
---|
[376] | 2 | %------------------------------------------------------------------------ |
---|
| 3 | % [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param) |
---|
| 4 | % |
---|
| 5 | % OUTPUT: |
---|
[446] | 6 | % filecell{iview,fileindex}: cell array representing the list of file names |
---|
| 7 | % iview: line in the table corresponding to a given file series |
---|
| 8 | % fileindex: file index within the file series, |
---|
[453] | 9 | % i1_series{iview}(ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j |
---|
| 10 | % i1_series{iview}(fileindex) expresses the same indices as a 1D array in file indices |
---|
[809] | 11 | % |
---|
[376] | 12 | % INPUT: |
---|
| 13 | % Param: structure of input parameters as read from the GUI series (by the function read_GUI) |
---|
| 14 | |
---|
[809] | 15 | %======================================================================= |
---|
[924] | 16 | % Copyright 2008-2016, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France |
---|
[809] | 17 | % http://www.legi.grenoble-inp.fr |
---|
| 18 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr |
---|
| 19 | % |
---|
| 20 | % This file is part of the toolbox UVMAT. |
---|
| 21 | % |
---|
| 22 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 23 | % it under the terms of the GNU General Public License as published |
---|
| 24 | % by the Free Software Foundation; either version 2 of the license, |
---|
| 25 | % or (at your option) any later version. |
---|
| 26 | % |
---|
| 27 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 28 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 29 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 30 | % GNU General Public License (see LICENSE.txt) for more details. |
---|
| 31 | %======================================================================= |
---|
| 32 | |
---|
[373] | 33 | function [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param) |
---|
[376] | 34 | |
---|
[757] | 35 | filecell={}; |
---|
[373] | 36 | InputTable=Param.InputTable; |
---|
| 37 | first_i=Param.IndexRange.first_i; |
---|
| 38 | incr_i=Param.IndexRange.incr_i; |
---|
| 39 | last_i=Param.IndexRange.last_i; |
---|
[635] | 40 | first_j=[];last_j=[];incr_j=1;%default |
---|
[754] | 41 | if isfield(Param.IndexRange,'first_j')&& isfield(Param.IndexRange,'last_j') |
---|
[373] | 42 | first_j=Param.IndexRange.first_j; |
---|
| 43 | last_j=Param.IndexRange.last_j; |
---|
| 44 | end |
---|
[754] | 45 | if isfield(Param.IndexRange,'incr_j') |
---|
| 46 | incr_j=Param.IndexRange.incr_j; |
---|
| 47 | end |
---|
[391] | 48 | |
---|
[373] | 49 | %% determine the list of input file names |
---|
[757] | 50 | % nbmissing=0; |
---|
[635] | 51 | NbView=size(InputTable,1); |
---|
| 52 | i1_series=cell(NbView,1);% initiate index series with empty cells |
---|
| 53 | i2_series=cell(NbView,1); |
---|
| 54 | j1_series=cell(NbView,1); |
---|
| 55 | j2_series=cell(NbView,1); |
---|
| 56 | for iview=1:NbView |
---|
[408] | 57 | r.mode=''; |
---|
| 58 | if isfield (Param.IndexRange,'PairString') |
---|
[450] | 59 | if ischar(Param.IndexRange.PairString) |
---|
| 60 | Param.IndexRange.PairString={Param.IndexRange.PairString}; |
---|
| 61 | end |
---|
[871] | 62 | if size(Param.IndexRange.PairString,1)>=iview && ~isempty(Param.IndexRange.PairString{iview,1}) |
---|
| 63 | r=regexp(Param.IndexRange.PairString{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');%look for mode=Dj or Di |
---|
| 64 | if isempty(r) |
---|
| 65 | r=regexp(Param.IndexRange.PairString{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');%look for burst pairs |
---|
| 66 | end |
---|
[537] | 67 | end |
---|
[408] | 68 | % TODO case of free pairs: |
---|
| 69 | %r=regexp(pair_string,'.*\D(?<num1>[\d+|*])(?<delim>[-||])(?<num2>[\d+|*])','names'); |
---|
| 70 | end |
---|
[440] | 71 | if isempty(r)||isempty(r.mode) |
---|
| 72 | r(1).num1=''; |
---|
| 73 | r(1).num2=''; |
---|
[871] | 74 | if isfield (Param.IndexRange,'PairString') && size(Param.IndexRange.PairString,1)>=iview &&... |
---|
| 75 | strcmp(Param.IndexRange.PairString{iview,1},'j=*-*') |
---|
[537] | 76 | r(1).mode='*-*'; |
---|
| 77 | else |
---|
[635] | 78 | r(1).mode=''; |
---|
[537] | 79 | end |
---|
[408] | 80 | end |
---|
[639] | 81 | |
---|
| 82 | if isempty(incr_i) || isempty(incr_j) || isequal(r(1).mode,'*-*')|| isequal(r(1).mode,'*|*')% free pairs or increment |
---|
[537] | 83 | FilePath=fullfile(InputTable{iview,1},InputTable{iview,2}); |
---|
| 84 | fileinput=[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]; |
---|
[783] | 85 | [tild,tild,tild,i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview},NomType,FileInfo,MovieObject,... |
---|
[635] | 86 | i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput); |
---|
| 87 | i1_series{iview}=squeeze(i1_series{iview}(1,:,:)); %select first pair index as ordered by find_file_series |
---|
[639] | 88 | i2_series{iview}=squeeze(i2_series{iview}(1,:,:)); %select first pair index as ordered by find_file_series |
---|
[537] | 89 | j1_series{iview}=squeeze(j1_series{iview}(1,:,:)); %first pair index |
---|
[635] | 90 | j2_series{iview}=squeeze(j2_series{iview}(1,:,:)); %second pair index |
---|
| 91 | if isempty(incr_i) |
---|
[639] | 92 | if isempty(first_j) || isempty(incr_j) % no j index or no defined increment for j |
---|
[643] | 93 | ref_j=find(max(i1_series{iview},[],2)); |
---|
| 94 | ref_i=find(max(i1_series{iview},[],1)); |
---|
[635] | 95 | ref_i=ref_i-1; |
---|
| 96 | ref_j=ref_j-1; |
---|
| 97 | ref_i=ref_i(ref_i>=first_i & ref_i<=last_i); |
---|
| 98 | ref_j=ref_j(ref_j>=first_j & ref_j<=last_j); |
---|
| 99 | else |
---|
| 100 | ref_j=first_j:incr_j:last_j; |
---|
[643] | 101 | ref_i=find(max(i1_series{iview}(:,ref_j),[],1)); |
---|
[635] | 102 | ref_i=ref_i-1; |
---|
| 103 | ref_i=ref_i(ref_i>=first_i & ref_i<=last_i); |
---|
| 104 | end |
---|
| 105 | else |
---|
| 106 | ref_i=first_i:incr_i:last_i;%default |
---|
[639] | 107 | if isempty(first_j) ||isempty(incr_j)% no j index or no defined increment for j |
---|
[643] | 108 | ref_j=find(max(i1_series{iview},[],2)); |
---|
[635] | 109 | ref_j=ref_j-1; |
---|
| 110 | ref_j=ref_j(ref_j>=first_j & ref_j<=last_j); |
---|
| 111 | else |
---|
| 112 | ref_j=first_j:incr_j:last_j; |
---|
| 113 | end |
---|
| 114 | end |
---|
[639] | 115 | if isempty(ref_j) |
---|
| 116 | i1_series{iview}=i1_series{iview}(2,ref_i+1); |
---|
| 117 | if ~isempty(i2_series{iview}) |
---|
| 118 | i2_series{iview}=i2_series{iview}(2,ref_i+1); |
---|
| 119 | end |
---|
| 120 | else |
---|
| 121 | i1_series{iview}=i1_series{iview}(ref_j+1,ref_i+1); |
---|
| 122 | if ~isempty(i2_series{iview}) |
---|
| 123 | i2_series{iview}=i2_series{iview}(ref_j+1,ref_i+1); |
---|
| 124 | end |
---|
[635] | 125 | end |
---|
[639] | 126 | if ~isempty(j1_series{iview}) |
---|
| 127 | j1_series{iview}=j1_series{iview}(ref_j+1,ref_i+1); |
---|
| 128 | if ~isempty(j2_series{iview}) |
---|
| 129 | j2_series{iview}=j2_series{iview}(ref_j+1,ref_i+1); |
---|
| 130 | end |
---|
| 131 | end |
---|
[537] | 132 | else |
---|
[635] | 133 | ref_i=first_i:incr_i:last_i;%default |
---|
| 134 | ref_j=first_j:incr_j:last_j;%default |
---|
[537] | 135 | [i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview}]=find_file_indices(ref_i,ref_j,str2num(r.num1),str2num(r.num2),r.mode); |
---|
| 136 | end |
---|
[639] | 137 | % if ~isequal(r(1).mode,'*-*')% imposed pairs or single i and/or j index |
---|
| 138 | % [i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview}]=find_file_indices(ref_i,ref_j,str2num(r.num1),str2num(r.num2),r.mode); |
---|
| 139 | % end |
---|
[635] | 140 | |
---|
[639] | 141 | %list of files |
---|
[373] | 142 | i2=[];j1=[];j2=[]; |
---|
[453] | 143 | for ifile=1:numel(i1_series{iview}) |
---|
| 144 | i1=i1_series{iview}(ifile); |
---|
| 145 | if ~isempty(i2_series{iview}) |
---|
| 146 | i2=i2_series{iview}(ifile); |
---|
[373] | 147 | end |
---|
[453] | 148 | if ~isempty(j1_series{iview}) |
---|
| 149 | j1=j1_series{iview}(ifile); |
---|
[373] | 150 | end |
---|
[453] | 151 | if ~isempty(j2_series{iview}) |
---|
| 152 | j2=j2_series{iview}(ifile); |
---|
[373] | 153 | end |
---|
[635] | 154 | filecell{iview,ifile}=fullfile_uvmat(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,i2,j1,j2); |
---|
[373] | 155 | end |
---|
| 156 | end |
---|
| 157 | |
---|
| 158 | |
---|
| 159 | function [i1_series,i2_series,j1_series,j2_series]=find_file_indices(ref_i,ref_j,num1,num2,mode) |
---|
| 160 | i1_series=ref_i;%default |
---|
| 161 | j1_series=[]; |
---|
| 162 | if ~isempty(ref_j) |
---|
[400] | 163 | [i1_series,j1_series]=meshgrid(ref_i,ref_j); |
---|
[373] | 164 | end |
---|
[393] | 165 | i2_series=i1_series; |
---|
| 166 | j2_series=j1_series; |
---|
[391] | 167 | |
---|
[373] | 168 | switch mode |
---|
[393] | 169 | case 'Di=' % case 'series(Di)') |
---|
[373] | 170 | i1_series=i1_series-num1; |
---|
| 171 | i2_series=i2_series+num2; |
---|
[393] | 172 | case 'Dj=' % case 'series(Dj)' |
---|
| 173 | j1_series=j1_series-num1; |
---|
| 174 | j2_series=j2_series+num2; |
---|
| 175 | case '-' % case 'bursts' |
---|
| 176 | j1_series=num1*ones(size(i1_series)); |
---|
| 177 | j2_series=num2*ones(size(i1_series)); |
---|
[809] | 178 | end |
---|