source: trunk/src/get_file_series.m @ 639

Last change on this file since 639 was 639, checked in by sommeria, 11 years ago

introduction of mask on projection: fct mask_proj

File size: 6.5 KB
RevLine 
[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:
[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
[446]11
[376]12% INPUT:
13% Param: structure of input parameters as read from the GUI series (by the function read_GUI)
14
[373]15function [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param)
[376]16
[591]17filecell={};i1_series={};i2_series={};j1_series={};j2_series={};
[373]18InputTable=Param.InputTable;
19first_i=Param.IndexRange.first_i;
20incr_i=Param.IndexRange.incr_i;
21last_i=Param.IndexRange.last_i;
[635]22% ref_i=first_i:incr_i:last_i;
23%ref_j=[];
24first_j=[];last_j=[];incr_j=1;%default
[400]25if isfield(Param.IndexRange,'first_j')
[373]26    first_j=Param.IndexRange.first_j;
27    incr_j=Param.IndexRange.incr_j;
28    last_j=Param.IndexRange.last_j;
29end
[391]30
[373]31%% determine the list of input file names
32nbmissing=0;
[635]33NbView=size(InputTable,1);
34i1_series=cell(NbView,1);% initiate index series with empty cells
35i2_series=cell(NbView,1);
36j1_series=cell(NbView,1);
37j2_series=cell(NbView,1);
38for iview=1:NbView
[408]39    r.mode='';
40    if isfield (Param.IndexRange,'PairString')
[450]41        if ischar(Param.IndexRange.PairString)
42            Param.IndexRange.PairString={Param.IndexRange.PairString};
43        end
[635]44        r=regexp(Param.IndexRange.PairString{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');%look for mode=Dj or Di
[408]45        if isempty(r)
[635]46            r=regexp(Param.IndexRange.PairString{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');%look for burst pairs
[537]47        end
[408]48        % TODO case of free pairs:
49        %r=regexp(pair_string,'.*\D(?<num1>[\d+|*])(?<delim>[-||])(?<num2>[\d+|*])','names');
50    end
[440]51    if isempty(r)||isempty(r.mode)
52        r(1).num1='';
53        r(1).num2='';
[540]54        if isfield (Param.IndexRange,'PairString') && strcmp(Param.IndexRange.PairString{iview,1},'j=*-*')
[537]55            r(1).mode='*-*';
56        else
[635]57            r(1).mode='';
[537]58        end
[408]59    end
[639]60   
61    if isempty(incr_i) || isempty(incr_j) || isequal(r(1).mode,'*-*')|| isequal(r(1).mode,'*|*')% free pairs or increment
[537]62        FilePath=fullfile(InputTable{iview,1},InputTable{iview,2});
63        fileinput=[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}];
[635]64        [tild,tild,tild,i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview},NomType,FileType,FileInfo,MovieObject,...
65            i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput);
66        i1_series{iview}=squeeze(i1_series{iview}(1,:,:)); %select first  pair index as ordered by find_file_series
[639]67        i2_series{iview}=squeeze(i2_series{iview}(1,:,:)); %select first  pair index as ordered by find_file_series
[537]68        j1_series{iview}=squeeze(j1_series{iview}(1,:,:)); %first  pair index
[635]69        j2_series{iview}=squeeze(j2_series{iview}(1,:,:)); %second  pair index
70        if isempty(incr_i)
[639]71            if isempty(first_j) || isempty(incr_j) % no j index or no defined increment for j
[635]72                [ref_j,ref_i]=find(i1_series{iview});
73                ref_i=ref_i-1;
74                ref_j=ref_j-1;
75                ref_i=ref_i(ref_i>=first_i & ref_i<=last_i);
76                ref_j=ref_j(ref_j>=first_j & ref_j<=last_j);
77            else
78                ref_j=first_j:incr_j:last_j;
79                [tild,ref_i]=find(i1_series{iview}(:,ref_j));
80                ref_i=ref_i-1;
81                ref_i=ref_i(ref_i>=first_i & ref_i<=last_i);
82            end
83        else
84            ref_i=first_i:incr_i:last_i;%default
[639]85            if isempty(first_j) ||isempty(incr_j)% no j index or no defined increment for j
[635]86                [ref_j,tild]=find(i1_series{iview});
87                ref_j=ref_j-1;
88                ref_j=ref_j(ref_j>=first_j & ref_j<=last_j);
89            else
90                ref_j=first_j:incr_j:last_j;
91            end
92        end
[639]93        if isempty(ref_j)
94            i1_series{iview}=i1_series{iview}(2,ref_i+1);
95            if ~isempty(i2_series{iview})
96                i2_series{iview}=i2_series{iview}(2,ref_i+1);
97            end
98        else
99            i1_series{iview}=i1_series{iview}(ref_j+1,ref_i+1);
100            if ~isempty(i2_series{iview})
101                i2_series{iview}=i2_series{iview}(ref_j+1,ref_i+1);
102            end
[635]103        end
[639]104        if ~isempty(j1_series{iview})
105            j1_series{iview}=j1_series{iview}(ref_j+1,ref_i+1);
106            if ~isempty(j2_series{iview})
107                j2_series{iview}=j2_series{iview}(ref_j+1,ref_i+1);
108            end
109        end
[537]110    else
[635]111        ref_i=first_i:incr_i:last_i;%default
112        ref_j=first_j:incr_j:last_j;%default
[537]113        [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);
114    end
[639]115    %     if ~isequal(r(1).mode,'*-*')% imposed pairs or single i and/or j index
116    %         [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);
117    %     end
[635]118   
[639]119    %list of files
[373]120    i2=[];j1=[];j2=[];
[453]121    for ifile=1:numel(i1_series{iview})
122        i1=i1_series{iview}(ifile);
123        if ~isempty(i2_series{iview})
124            i2=i2_series{iview}(ifile);
[373]125        end
[453]126        if ~isempty(j1_series{iview})
127            j1=j1_series{iview}(ifile);
[373]128        end
[453]129        if ~isempty(j2_series{iview})
130            j2=j2_series{iview}(ifile);
[373]131        end
[635]132        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]133    end
134end
135
136
137function [i1_series,i2_series,j1_series,j2_series]=find_file_indices(ref_i,ref_j,num1,num2,mode)
138i1_series=ref_i;%default
139j1_series=[];
140if ~isempty(ref_j)
[400]141    [i1_series,j1_series]=meshgrid(ref_i,ref_j);
[373]142end
[393]143i2_series=i1_series;
144j2_series=j1_series;
[391]145
[373]146switch mode
[393]147    case 'Di='  %  case 'series(Di)')
[373]148        i1_series=i1_series-num1;
149        i2_series=i2_series+num2;
[393]150    case 'Dj='  %  case 'series(Dj)'
151        j1_series=j1_series-num1;
152        j2_series=j2_series+num2;
153    case '-'  % case 'bursts'
154        j1_series=num1*ones(size(i1_series));
155        j2_series=num2*ones(size(i1_series));
[373]156end
Note: See TracBrowser for help on using the repository browser.