Changeset 592 for trunk/src


Ignore:
Timestamp:
Mar 25, 2013, 6:34:00 PM (12 years ago)
Author:
sommeria
Message:

commit the series fcts with the new form

Location:
trunk/src/series
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series/aver_stat.m

    r585 r592  
    4848
    4949%% set the input elements needed on the GUI series when the action is selected in the menu ActionName
    50 if ~exist('Param','var') % case with no input parameter
    51     ParamOut={'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
    52         'WholeIndexRange';'off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
    53         'NbSlice';'on'; ...%nbre of slices ('off' by default)
    54         'VelType';'two';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    55         'FieldName';'two';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
    56         'FieldTransform'; 'on';...%can use a transform function
    57         'ProjObject';'on';...%can use projection object(option 'off'/'on',
    58         'Mask';'off';...%can use mask option   (option 'off'/'on', 'off' by default)
    59         'OutputDirExt';'.stat';...%set the output dir extension
    60                ''};
    61         return
     50if isstruct(Param) && isequal(Param.Action.RUN,0)
     51    ParamOut.AllowInputSort='off';...% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
     52    ParamOut.WholeIndexRange='off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
     53    ParamOut.NbSlice='on'; ...%nbre of slices ('off' by default)
     54    ParamOut.VelType='two';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
     55    ParamOut.FieldName='two';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
     56    ParamOut.FieldTransform = 'on';...%can use a transform function
     57    ParamOut.ProjObject='on';...%can use projection object(option 'off'/'on',
     58    ParamOut.Mask='off';...%can use mask option   (option 'off'/'on', 'off' by default)
     59    ParamOut.OutputDirExt='.stat';%set the output dir extension
     60return
    6261end
    6362
    6463%%%%%%%%%%%%  STANDARD PART  %%%%%%%%%%%%
    65 %% select different modes,  RUN, parameter input, BATCH
    66 % BATCH  case: read the xml file for batch case
     64%% read input parameters from an xml file if input is a file name (batch mode)
     65checkrun=1;
    6766if ischar(Param)
    68         Param=xml2struct(Param);
    69         checkrun=0;
    70 % RUN case: parameters introduced as the input structure Param
    71 else
    72     if isfield(Param,'Specific')&& strcmp(Param.Specific,'?')
    73         checkrun=1;% will only search interactive input parameters (preparation of BATCH mode)
    74     else
    75         checkrun=2; % indicate the RUN option is used
    76     end
    77     hseries=guidata(Param.hseries);%handles of the GUI series
    78 end
     67    Param=xml2struct(Param);% read Param as input file (batch case)
     68    checkrun=0;
     69end
     70
     71
    7972ParamOut=Param; %default output
    8073OutputDir=[Param.OutputSubDir Param.OutputDirExt];
     
    158151end
    159152NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series
    160 if checkrun==1
    161     return % stop here for input checks
    162 end
     153
    163154
    164155%% Set field names and velocity types
     
    188179    %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
    189180    for index=index_slice
    190         if checkrun
    191             update_waitbar(hseries.Waitbar,index/(nbfield))
    192             stopstate=get(hseries.RUN,'BusyAction');
    193         else
    194             stopstate='queue';
    195         end
     181          if checkrun
     182                stopstate=get(Param.RUNHandle,'BusyAction');
     183                update_waitbar(Param.WaitbarHandle,index/nbfield)
     184          else
     185                stopstate='queue';
     186          end
    196187        if isequal(stopstate,'queue')% enable STOP command
    197188           
     
    240231           
    241232            %% calculate tps coefficients if needed
    242             if isfield(Param.ProjObject,'ProjMode')&& strcmp(Param.ProjObject.ProjMode,'interp_tps')
     233            if isfield(Param,'ProjObject')&&isfield(Param.ProjObject,'ProjMode')&& strcmp(Param.ProjObject.ProjMode,'interp_tps')
    243234                Field=tps_coeff_field(Field,check_proj_tps);
    244235            end
  • trunk/src/series/check_data_files.m

    r573 r592  
    3434function ParamOut=check_data_files(Param)
    3535
    36 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName
    37 if ~exist('Param','var') % case with no input parameter
    38     ParamOut={'NbViewMax';'';...% max nbre of input file series (default='' , no limitation)
    39         'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
    40         'NbSlice';'on'; ...%nbre of slices ('off' by default)
    41         'VelType';'off';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    42         'FieldName';'off';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
    43         'FieldTransform'; 'off';...%can use a transform function
    44         'ProjObject';'off';...%can use projection object(option 'off'/'on',
    45         'Mask';'off';...%can use mask option   (option 'off'/'on', 'off' by default)
    46         'OutputDirExt';'';...%set the output dir extension
    47                ''};
    48         return
     36% %% set the input elements needed on the GUI series when the action is selected in the menu ActionName
     37% if ~exist('Param','var') % case with no input parameter
     38%     ParamOut={'NbViewMax';'';...% max nbre of input file series (default='' , no limitation)
     39%         'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
     40%         'NbSlice';'on'; ...%nbre of slices ('off' by default)
     41%         'VelType';'off';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
     42%         'FieldName';'off';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
     43%         'FieldTransform'; 'off';...%can use a transform function
     44%         'ProjObject';'off';...%can use projection object(option 'off'/'on',
     45%         'Mask';'off';...%can use mask option   (option 'off'/'on', 'off' by default)
     46%         'OutputDirExt';'';...%set the output dir extension
     47%                ''};
     48%         return
     49% end
     50%% input preparation mode (no RUN)
     51if isstruct(Param) && isequal(Param.Action.RUN,0)
     52    ParamOut.AllowInputSort='off';...% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
     53    ParamOut.WholeIndexRange='off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
     54    ParamOut.NbSlice='on'; ...%nbre of slices ('off' by default)
     55    ParamOut.VelType='off';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
     56    ParamOut.FieldName='off';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
     57    ParamOut.FieldTransform = 'off';...%can use a transform function
     58    ParamOut.ProjObject='off';...%can use projection object(option 'off'/'on',
     59    ParamOut.Mask='off';...%can use mask option   (option 'off'/'on', 'off' by default)
     60    ParamOut.OutputDirExt='';%set the output dir extension (blank=no output dir)
     61return
    4962end
    50 
    5163%%%%%%%%%%%%  STANDARD PART  %%%%%%%%%%%%
    5264%% select different modes,  RUN, parameter input, BATCH
     
    7486FileExt=Param.InputTable(:,5);
    7587[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
     88if isempty(i1_series)
     89    return
     90end
    7691%%%%%%%%%%%%
    7792% The cell array filecell is the list of input file names, while
  • trunk/src/series/check_peaklock.m

    r590 r592  
    192192                break
    193193            end
    194             if ~isempty(NbSlice_calib)
    195                 Data{iview}.ZIndex=mod(i1_series{iview}(index)-1,NbSlice_calib{iview})+1;%Zindex for phys transform
    196             end
    197194        end
    198195        if isempty(errormsg)
     
    209206                end
    210207            end
    211             nbfile=nbfile+1;
    212208           
    213209            % initiate the time series at the first iteration
    214             if nbfile==1
     210            if index==1
    215211                % stop program if the first field reading is in error
    216212                if ~isempty(errormsg)
     
    287283                end
    288284            end
    289            
    290             % record the time:
    291             if isempty(time)% time not set by xml filer(s)
    292                 if isfield(Data{1},'Time')
    293                     DataOut.Time(nbfile,1)=Field.Time;
    294                 else
    295                     DataOut.Time(nbfile,1)=index;%default
    296                 end
    297             else % time from ImaDoc prevails  TODO: correct
    298                 DataOut.Time(nbfile,1)=time(index);%
    299             end
    300            
    301             % record the number of missing input fields
    302             if ~isempty(errormsg)
    303                 nbmissing=nbmissing+1;
    304                 display(['index=' num2str(index) ':' errormsg])
    305             end
     285
    306286        end
    307287    end
  • trunk/src/series/ima_levels.m

    r590 r592  
    4040%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    4141 
    42 function GUI_input=ima_levels (Param)
     42function ParamOut=ima_levels (Param)
    4343
    4444%% set the input elements needed on the GUI series when the action is selected in the menu ActionName
    45 if ~exist('Param','var') % case with no input parameter
    46     GUI_input={'NbViewMax';1;...% max nbre of input file series (default='' , no limitation)
    47         'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
    48         'NbSlice';'off'; ...%nbre of slices ('off' by default)
    49         'VelType';'off';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    50         'FieldName';'off';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
    51         'FieldTransform'; 'off';...%can use a transform function
    52         'ProjObject';'off';...%can use projection object(option 'off'/'on',
    53         'Mask';'off';...%can use mask option   (option 'off'/'on', 'off' by default)
    54         'OutputDirExt';'.lev';...%set the output dir extension
    55                ''};
    56         return
     45if isstruct(Param) && isequal(Param.Action.RUN,0)
     46    ParamOut.NbViewMax=1;% max nbre of input file series (default='' , no limitation)
     47    ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
     48    ParamOut.WholeIndexRange='off';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
     49    ParamOut.NbSlice='off'; %nbre of slices ('off' by default)
     50    ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default)
     51    ParamOut.FieldName='one';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
     52    ParamOut.FieldTransform = 'off';%can use a transform function
     53    ParamOut.ProjObject='off';%can use projection object(option 'off'/'on',
     54    ParamOut.Mask='off';%can use mask option   (option 'off'/'on', 'off' by default)
     55    ParamOut.OutputDirExt='.lev';%set the output dir extension
     56return
    5757end
    5858
    5959%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
    60 %% select different modes,  RUN, parameter input, BATCH
    61 % BATCH  case: read the xml file for batch case
     60%% read input parameters from an xml file if input is a file name (batch mode)
     61checkrun=1;
    6262if ischar(Param)
    63     if strcmp(Param,'input?')
    64         checkrun=1;% will inly search input parameters (preparation of BATCH mode)
    65     else
    66         Param=xml2struct(Param);
    67         checkrun=0;
    68     end
    69 % RUN case: parameters introduced as the input structure Param
    70 else
    71     hseries=guidata(Param.hseries);%handles of the GUI series
    72     checkrun=2; % indicate the RUN option is used
    73 end
     63    Param=xml2struct(Param);% read Param as input file (batch case)
     64    checkrun=0;
     65end
     66
     67ParamOut=Param; %default output
     68if ~isfield(Param,'InputFields')
     69    Param.InputFields.FieldName='';
     70end
     71OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files
    7472
    7573%% root input file(s) and type
     
    154152j1=[];%default
    155153for ifile=1:nbfield
    156     if checkrun
    157         update_waitbar(hseries.Waitbar,ifile/nbfield)
    158         stopstate=get(hseries.RUN,'BusyAction');
    159     else
    160         stopstate='queue';
    161     end
     154          if checkrun
     155                stopstate=get(Param.RUNHandle,'BusyAction');
     156                update_waitbar(Param.WaitbarHandle,ifile/nbfield)
     157          else
     158                stopstate='queue';
     159          end
    162160    if isequal(stopstate,'queue') % enable STOP command
    163161        if ~isempty(j1_series)&&~isequal(j1_series,{[]})
  • trunk/src/series/merge_proj.m

    r585 r592  
    4949
    5050%% set the input elements needed on the GUI series when the action is selected in the menu ActionName
    51 if ~exist('Param','var') % case with no input parameter
    52     ParamOut={'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
    53         'WholeIndexRange';'off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
    54         'NbSlice';'on'; ...%nbre of slices ('off' by default)
    55         'VelType';'one';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    56         'FieldName';'one';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
    57         'FieldTransform'; 'on';...%can use a transform function
    58         'ProjObject';'on';...%can use projection object(option 'off'/'on',
    59         'Mask';'off';...%can use mask option   (option 'off'/'on', 'off' by default)
    60         'OutputDirExt';'.mproj';...%set the output dir extension
    61                ''};
    62         return
     51if isstruct(Param) && isequal(Param.Action.RUN,0)
     52    ParamOut.AllowInputSort='off';...% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
     53    ParamOut.WholeIndexRange='on';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
     54    ParamOut.NbSlice='off'; ...%nbre of slices ('off' by default)
     55    ParamOut.VelType='one';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
     56    ParamOut.FieldName='one';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
     57    ParamOut.FieldTransform = 'on';...%can use a transform function
     58    ParamOut.ProjObject='on';...%can use projection object(option 'off'/'on',
     59    ParamOut.Mask='off';...%can use mask option   (option 'off'/'on', 'off' by default)
     60    ParamOut.OutputDirExt='.mproj';%set the output dir extension
     61return
    6362end
    6463
    6564%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
    66 %% select different modes,  RUN, parameter input, BATCH
    67 % BATCH  case: read the xml file for batch case
     65%% read input parameters from an xml file if input is a file name (batch mode)
     66checkrun=1;
    6867if ischar(Param)
    69         Param=xml2struct(Param);
    70         checkrun=0;
    71 % RUN case: parameters introduced as the input structure Param
    72 else
    73     hseries=guidata(Param.hseries);%handles of the GUI series
    74     if isfield(Param,'Specific')&& strcmp(Param.Specific,'?')
    75         checkrun=1;% will only search interactive input parameters (preparation of BATCH mode)
    76     else
    77         checkrun=2; % indicate the RUN option is used
    78     end
    79 end
     68    Param=xml2struct(Param);% read Param as input file (batch case)
     69    checkrun=0;
     70end
     71
    8072ParamOut=Param; %default output
    8173if ~isfield(Param,'InputFields')
    8274    Param.InputFields.FieldName='';
    8375end
     76OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files
    8477
    8578%% root input file type
     
    8982NomType=Param.InputTable(:,4);
    9083FileExt=Param.InputTable(:,5);
    91 OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files
    9284[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
    9385%%%%%%%%%%%%
  • trunk/src/series/sub_background.m

    r573 r592  
    5555function ParamOut=sub_background (Param)
    5656
    57 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName
    58 if ~exist('Param','var') % case with no input parameter
    59     ParamOut={'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
    60         'WholeIndexRange';'on';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
    61         'NbSlice';'on'; ...%nbre of slices ('off' by default)
    62         'VelType';'off';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    63         'FieldName';'off';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
    64         'FieldTransform'; 'off';...%can use a transform function
    65         'ProjObject';'off';...%can use projection object(option 'off'/'on',
    66         'Mask';'off';...%can use mask option   (option 'off'/'on', 'off' by default)
    67         'OutputDirExt';'.sback';...%set the output dir extension
    68                ''};
     57%% input preparation mode (no RUN)
     58if isstruct(Param) && isequal(Param.Action.RUN,0)
     59    ParamOut.AllowInputSort='off';...% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
     60    ParamOut.WholeIndexRange='on';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
     61    ParamOut.NbSlice='on'; ...%nbre of slices ('off' by default)
     62    ParamOut.VelType='off';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
     63    ParamOut.FieldName='off';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
     64    ParamOut.FieldTransform = 'off';...%can use a transform function
     65    ParamOut.ProjObject='off';...%can use projection object(option 'off'/'on',
     66    ParamOut.Mask='off';...%can use mask option   (option 'off'/'on', 'off' by default)
     67    ParamOut.OutputDirExt='.sback';%set the output dir extension
     68   
     69    %%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
     70   
     71    %% root input file(s) and type
     72%     RootPath=Param.InputTable(:,1);
     73%     RootFile=Param.InputTable(:,3);
     74%     SubDir=Param.InputTable(:,2);
     75%     NomType=Param.InputTable(:,4);
     76%     FileExt=Param.InputTable(:,5);
     77    [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
     78    %%%%%%%%%%%%
     79    % The cell array filecell is the list of input file names, while
     80    % filecell{iview,fileindex}:
     81    %        iview: line in the table corresponding to a given file series
     82    %        fileindex: file index within  the file series,
     83    % 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
     84    % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
     85    %%%%%%%%%%%%
     86    NbSlice=1;%default
     87    if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
     88        NbSlice=Param.IndexRange.NbSlice;
     89    end
     90    nbview=numel(i1_series);%number of input file series (lines in InputTable)
     91    nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
     92    nbfield_i=size(i1_series{1},2); %nb of fields for the i index
     93    nbfield=nbfield_j*nbfield_i; %total number of fields
     94    nbfield_i=floor(nbfield/NbSlice);%total number of  indexes in a slice (adjusted to an integer number of slices)
     95    nbfield=nbfield_i*NbSlice; %total number of fields after adjustement
     96   
     97    %determine the file type on each line from the first input file
     98
     99   
     100    %% calibration data and timing: read the ImaDoc files
     101    %not relevant here
     102   
     103    %% check coincidence in time for several input file series
     104    %not relevant here
     105   
     106    %% coordinate transform or other user defined transform
     107    %not relevant here
     108   
     109    %%%%%%%%%%%% END STANDARD PART  %%%%%%%%%%%%
     110    % EDIT FROM HERE
     111   
     112    %% check the validity of  input file types
     113    ImageTypeOptions={'image','multimage','mmreader','video'};%allowed input file types(images)
     114    FileType=get_file_type(filecell{1,1});
     115    CheckImage=~isempty(find(strcmp(FileType,ImageTypeOptions), 1));% =1 for images
     116    if ~CheckImage
     117        msgbox_uvmat('ERROR',['invalid file type input: ' FileType{1} ' not an image'])
    69118        return
    70 end
    71 
    72 %%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
    73 %% select different modes,  RUN, parameter input, BATCH
    74 % BATCH  case: read the xml file for batch case
     119    end
     120   
     121    %% Set field names and velocity types
     122    %not relevant here
     123   
     124    %% Initiate output fields
     125    %not relevant here
     126   
     127    %%% SPECIFIC PART BEGINS HERE
     128    NbSlice=1;
     129    if isfield(Param.IndexRange,'NbSlice')
     130        NbSlice=Param.IndexRange.NbSlice; %number of slices
     131    end
     132    %siz=size(i1_series);
     133    nbaver_init=23;%approximate number of images used for the sliding background: to be adjusted later to include an integer number of bursts
     134    j1=[];%default
     135   
     136    %% adjust the proposed number of images in the sliding average to include an integer number of bursts
     137    if nbfield_i~=1
     138        nbaver=floor(nbaver_init/nbfield_j); % number of bursts used for the sliding background,
     139        if isequal(floor(nbaver/2),nbaver)
     140            nbaver=nbaver+1;%put the number of burst to an odd number (so the middle burst is defined)
     141        end
     142        nbaver_init=nbaver*nbfield_j;%propose by default an integer number of bursts
     143    end
     144   
     145    %% input of specific parameters
     146    %if checkrun %get specific parameters interactively
     147    if isequal(Param.Action.RUN,0)
     148        prompt = {'volume scan mode (Yes/No)';'Number of images for the sliding background (MUST FIT IN COMPUTER MEMORY)';...
     149            'the luminosity rank chosen to define the background (0.1=for dense particle seeding, 0.5 (median) for sparse particles'};
     150        dlg_title = 'get (slice by slice) a sliding background and substract to each image';
     151        num_lines= 3;
     152        def     = { 'No';num2str(nbaver_init);'0.1'};
     153        answer = inputdlg(prompt,dlg_title,num_lines,def);
     154       
     155        %check input consistency
     156        if strcmp(answer{1},'No') && ~isequal(NbSlice,1)
     157            check=msgbox_uvmat('INPUT_Y-N',['confirm the multi-level splitting into ' num2str(NbSlice) ' slices']);
     158            if ~strcmp(check,'Yes')
     159                return
     160            end
     161        end
     162        if strcmp(answer{1},'Yes')
     163            step=1;
     164        else
     165            step=nbfield_j;%case of bursts: the sliding background is shifted by the length of one burst
     166        end
     167        nbaver_ima=str2num(answer{2});%number of images for the sliding background
     168        nbaver=ceil(nbaver_ima/step);%number of bursts for the sliding background
     169        if isequal(floor(nbaver/2),nbaver)
     170            nbaver=nbaver+1;%set the number of bursts to an odd number (so the middle burst is defined)
     171        end
     172        nbaver_ima=nbaver*step;
     173    end
     174    ParamOut.InputGUI.CheckVolume=strcmp(answer{1},'Yes');
     175    ParamOut.InputGUI.SlidingSequenceLength=nbaver_ima;
     176    ParamOut.InputGUI.BrightnessRankThreshold=str2num(answer{3});
     177   
     178    % apply the image rescaling function 'level' (avoid the blinking effects of bright particles)
     179    answer=msgbox_uvmat('INPUT_Y-N','apply image rescaling function levels.m after sub_background');
     180    ParamOut.InputGUI.CheckLevelTransform=strcmp(answer,'Yes');
     181    return
     182end
     183%%%%%%%%%%%%%%%%%%%%%%  STOP HERE FOR PAMETER INPUT MODE  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     184
     185%% read input parameters from an xml file if input is a file name (batch mode)
     186checkrun=1;
    75187if ischar(Param)
    76         Param=xml2struct(Param);
    77         checkrun=0;
    78 % RUN case: parameters introduced as the input structure Param
    79 else
    80     hseries=guidata(Param.hseries);%handles of the GUI series
    81     if isfield(Param,'Specific')&& strcmp(Param.Specific,'?')
    82         checkrun=1;% will search input parameters (preparation of BATCH mode)
    83     else
    84         checkrun=2; % indicate the RUN option is used
    85     end
    86 end
    87 ParamOut=Param; %default output
    88 OutputDir=[Param.OutputSubDir Param.OutputDirExt];
    89 
    90 %% root input file(s) and type
     188    Param=xml2struct(Param);% read Param as input file (batch case)
     189    checkrun=0;
     190end
     191
     192%% Input preparation
     193nbaver_ima=Param.InputGUI.SlidingSequenceLength;
     194NbSlice=Param.IndexRange.NbSlice;
     195if ~isequal(NbSlice,1)
     196    display(['multi-level splitting into ' num2str(NbSlice) ' slices']);
     197end
    91198RootPath=Param.InputTable(:,1);
    92199RootFile=Param.InputTable(:,3);
     
    95202FileExt=Param.InputTable(:,5);
    96203[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
    97 %%%%%%%%%%%%
    98 % The cell array filecell is the list of input file names, while
    99 % filecell{iview,fileindex}:
    100 %        iview: line in the table corresponding to a given file series
    101 %        fileindex: file index within  the file series,
    102 % 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
    103 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
    104 %%%%%%%%%%%%
    105 NbSlice=1;%default
    106 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
    107     NbSlice=Param.IndexRange.NbSlice;
    108 end
    109 nbview=numel(i1_series);%number of input file series (lines in InputTable)
     204[FileType{1},FileInfo{1},MovieObject{1}]=get_file_type(filecell{1,1});
     205    if ~isempty(j1_series{1})
     206        frame_index{1}=j1_series{1};
     207    else
     208        frame_index{1}=i1_series{1};
     209    end
    110210nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
    111211nbfield_i=size(i1_series{1},2); %nb of fields for the i index
    112212nbfield=nbfield_j*nbfield_i; %total number of fields
    113 nbfield_i=floor(nbfield/NbSlice);%total number of  indexes in a slice (adjusted to an integer number of slices) 
     213nbfield_i=floor(nbfield/NbSlice);%total number of  indexes in a slice (adjusted to an integer number of slices)
    114214nbfield=nbfield_i*NbSlice; %total number of fields after adjustement
    115215
    116 %determine the file type on each line from the first input file
    117 ImageTypeOptions={'image','multimage','mmreader','video'};%allowed input file types(images)
    118 
    119 [FileType{1},FileInfo{1},MovieObject{1}]=get_file_type(filecell{1,1});
    120 CheckImage{1}=~isempty(find(strcmp(FileType,ImageTypeOptions)));% =1 for images
    121 if ~isempty(j1_series{1})
    122     frame_index{1}=j1_series{1};
     216%% Output
     217FileExtOut='.png'; % write result as .png images for image inputs
     218if strcmp(lower(NomType{1}(end)),'a')
     219    NomTypeOut=NomType{1};%case of letter appendix
     220elseif isempty(j1_series)
     221    NomTypeOut='_1';
    123222else
    124     frame_index{1}=i1_series{1};
    125 end
    126 
    127 %% calibration data and timing: read the ImaDoc files
    128 %not relevant here
    129 
    130 %% check coincidence in time for several input file series
    131 %not relevant here
    132 
    133 %% coordinate transform or other user defined transform
    134 %not relevant here
    135 
    136 %%%%%%%%%%%% END STANDARD PART  %%%%%%%%%%%%
    137  % EDIT FROM HERE
    138 
    139  %% check the validity of  input file types
    140 if CheckImage{1}
    141     FileExtOut='.png'; % write result as .png images for image inputs
    142     if strcmp(lower(NomType{1}(end)),'a')
    143         NomTypeOut=NomType{1};%case of letter appendix
    144     elseif isempty(j1_series)
    145         NomTypeOut='_1';
    146     else
    147         NomTypeOut='_1_1';% caseof purely numerical indexing
    148     end
    149 else
    150     msgbox_uvmat('ERROR',['invalid file type input: ' FileType{1} ' not an image'])
     223    NomTypeOut='_1_1';% caseof purely numerical indexing
     224end
     225
     226OutputDir=[Param.OutputSubDir Param.OutputDirExt];
     227
     228if isequal(Param.InputGUI.CheckVolume,1)
     229    step=1;
     230else
     231    step=nbfield_j;%case of bursts: the sliding background is shifted by the length of one burst
     232end
     233nbaver_ima=Param.InputGUI.SlidingSequenceLength;%number of images for the sliding background
     234nbaver=ceil(nbaver_ima/step);%number of bursts for the sliding background
     235if isequal(floor(nbaver/2),nbaver)
     236    nbaver=nbaver+1;%set the number of bursts to an odd number (so the middle burst is defined)
     237end
     238nbaver_ima=nbaver*step;
     239if nbaver_ima > nbfield
     240    display('number of images in a slice smaller than the proposed number of images for the sliding average')
    151241    return
    152242end
    153243
    154 %% Set field names and velocity types
    155 %not relevant here
    156 
    157 %% Initiate output fields
    158 %not relevant here
    159  
    160 %%% SPECIFIC PART BEGINS HERE
    161 NbSlice=Param.IndexRange.NbSlice; %number of slices
    162 %siz=size(i1_series);
    163 nbaver_init=23;%approximate number of images used for the sliding background: to be adjusted later to include an integer number of bursts
    164 j1=[];%default
    165 
    166 %% adjust the proposed number of images in the sliding average to include an integer number of bursts
    167 if nbfield_i~=1
    168     nbaver=floor(nbaver_init/nbfield_j); % number of bursts used for the sliding background,
    169     if isequal(floor(nbaver/2),nbaver)
    170         nbaver=nbaver+1;%put the number of burst to an odd number (so the middle burst is defined)
    171     end
    172     nbaver_init=nbaver*nbfield_j;%propose by default an integer number of bursts
    173 end
    174 
    175 %% input of specific parameters
    176 if checkrun %get specific parameters interactively
    177     prompt = {'volume scan mode (Yes/No)';'Number of images for the sliding background (MUST FIT IN COMPUTER MEMORY)';...
    178         'the luminosity rank chosen to define the background (0.1=for dense particle seeding, 0.5 (median) for sparse particles'};
    179     dlg_title = ['get (slice by slice) a sliding background and substract to each image, result in subdir ' OutputDir];
    180     num_lines= 3;
    181     def     = { 'No';num2str(nbaver_init);'0.1'};
    182     answer = inputdlg(prompt,dlg_title,num_lines,def);
    183    
    184     %check input consistency
    185     if strcmp(answer{1},'No') && ~isequal(NbSlice,1)
    186         check=msgbox_uvmat('INPUT_Y-N',['confirm the multi-level splitting into ' num2str(NbSlice) ' slices']);
    187         if ~strcmp(check,'Yes')
    188             return
    189         end
    190     end
    191     if strcmp(answer{1},'Yes')
    192         step=1;
    193     else
    194         step=nbfield_j;%case of bursts: the sliding background is shifted by the length of one burst
    195     end
    196     nbaver_ima=str2num(answer{2});%number of images for the sliding background
    197     nbaver=ceil(nbaver_ima/step);%number of bursts for the sliding background
    198     if isequal(floor(nbaver/2),nbaver)
    199         nbaver=nbaver+1;%set the number of bursts to an odd number (so the middle burst is defined)
    200     end
    201     nbaver_ima=nbaver*step;
    202     if nbaver_ima > nbfield
    203         msgbox_uvmat('ERROR','number of images in a slice smaller than the proposed number of images for the sliding average')
    204         return
    205     end
    206     ParamOut.Specific.CheckVolume=strcmp(answer{1},'Yes');
    207     ParamOut.Specific.SlidingSequenceSize=nbaver_ima;
    208     ParamOut.Specific.BrightnessRankThreshold=str2num(answer{3});
    209    
    210     % apply the image rescaling function 'level' (avoid the blinking effects of bright particles)
    211     answer=msgbox_uvmat('INPUT_Y-N','apply image rescaling function levels.m after sub_background');
    212     ParamOut.Specific.CheckLevelTransform=strcmp(answer,'Yes');
    213     if checkrun==1
    214          return
    215     end
    216     %%%%%%%%%%%%%%%%%%%%%%  STOP HERE FOR PAMETER INPUT MODE  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    217 else
    218     if isequal(Param.Specific.CheckVolume,1)
    219         step=1;
    220     else
    221         step=nbfield_j;%case of bursts: the sliding background is shifted by the length of one burst
    222     end
    223     nbaver_ima=Param.Specific.SlidingSequenceSize;%number of images for the sliding background
    224     nbaver=ceil(nbaver_ima/step);%number of bursts for the sliding background
    225     if isequal(floor(nbaver/2),nbaver)
    226         nbaver=nbaver+1;%set the number of bursts to an odd number (so the middle burst is defined)
    227     end
    228     nbaver_ima=nbaver*step;
    229     if nbaver_ima > nbfield
    230         msgbox_uvmat('ERROR','number of images in a slice smaller than the proposed number of images for the sliding average')
    231         return
    232     end
    233 end
    234 
    235244% calculate absolute brightness rank
    236 rank=floor(ParamOut.Specific.BrightnessRankThreshold*nbaver_ima);
     245rank=floor(Param.InputGUI.BrightnessRankThreshold*nbaver_ima);
    237246if rank==0
    238247    rank=1;%rank selected in the sorted image series
     
    251260    end
    252261catch ME
    253     msgbox_uvmat('ERROR',ME.message)
     262    msgbox_uvmat('ERROR',['sub_background/read_image/' ME.message])
    254263    return
    255264end
     
    338347       
    339348        %write result file
    340         if ParamOut.Specific.CheckLevelTransform
     349        if Param.InputGUI.CheckLevelTransform
    341350            C=levels(Acor);
    342351            imwrite(C,newname,'BitDepth',8); % save the new image
     
    358367        for ifield = step*ceil(nbaver/2)+1:step:nbfield_i-step*floor(nbaver/2)
    359368            if checkrun
    360                 stopstate=get(hseries.RUN,'BusyAction');
    361                 update_waitbar(hseries.Waitbar,(ifield+(islice-1)*nbfield_i)/(nbfield_i*NbSlice))
     369                stopstate=get(Param.RUNHandle,'BusyAction');
     370                update_waitbar(Param.WaitbarHandle,(ifield+(islice-1)*nbfield_i)/(nbfield_i*NbSlice))
    362371            else
    363372                stopstate='queue';
     
    387396                    newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);
    388397                    %write result file
    389                     if ParamOut.Specific.CheckLevelTransform
     398                    if Param.InputGUI.CheckLevelTransform
    390399                        C=levels(Acor);
    391400                        imwrite(C,newname,'BitDepth',8); % save the new image
     
    422431       
    423432        %write result file
    424         if ParamOut.Specific.CheckLevelTransform
     433        if Param.InputGUI.CheckLevelTransform
    425434            C=levels(Acor);
    426435            imwrite(C,newname,'BitDepth',8); % save the new image
  • trunk/src/series/time_series.m

    r585 r592  
    4949
    5050%% set the input elements needed on the GUI series when the action is selected in the menu ActionName
    51 if ~exist('Param','var') % case with no input parameter
    52     ParamOut={'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
    53         'WholeIndexRange';'off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
    54         'NbSlice';'on'; ...%nbre of slices ('off' by default)
    55         'VelType';'two';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    56         'FieldName';'two';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
    57         'FieldTransform'; 'on';...%can use a transform function
    58         'ProjObject';'on';...%can use projection object(option 'off'/'on',
    59         'Mask';'off';...%can use mask option   (option 'off'/'on', 'off' by default)
    60         'OutputDirExt';'.tseries';...%set the output dir extension
    61                ''};
    62         return
     51if isstruct(Param) && isequal(Param.Action.RUN,0)
     52    ParamOut.AllowInputSort='off';...% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
     53    ParamOut.WholeIndexRange='off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
     54    ParamOut.NbSlice='on'; ...%nbre of slices ('off' by default)
     55    ParamOut.VelType='two';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
     56    ParamOut.FieldName='two';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
     57    ParamOut.FieldTransform = 'on';...%can use a transform function
     58    ParamOut.ProjObject='on';...%can use projection object(option 'off'/'on',
     59    ParamOut.Mask='off';...%can use mask option   (option 'off'/'on', 'off' by default)
     60    ParamOut.OutputDirExt='.tseries';%set the output dir extension
     61return
    6362end
    6463
    6564%%%%%%%%%%%% STANDARD PART  %%%%%%%%%%%%
    66 %% select different modes,  RUN, parameter input, BATCH
    67 % BATCH  case: read the xml file for batch case
     65%% read input parameters from an xml file if input is a file name (batch mode)
     66checkrun=1;
    6867if ischar(Param)
    69         Param=xml2struct(Param);
    70         checkrun=0;
    71 % RUN case: parameters introduced as the input structure Param
    72 else
    73     hseries=guidata(Param.hseries);%handles of the GUI series
    74     if isfield(Param,'Specific')&& strcmp(Param.Specific,'?')
    75         checkrun=1;% will only search interactive input parameters (preparation of BATCH mode)
    76     else
    77         checkrun=2; % indicate the RUN option is used
    78     end
    79 end
     68    Param=xml2struct(Param);% read Param as input file (batch case)
     69    checkrun=0;
     70end
     71
    8072ParamOut=Param; %default output
    8173OutputDir=[Param.OutputSubDir Param.OutputDirExt];
     
    218210   
    219211    %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
    220     for index=index_slice       
     212    for index=index_slice 
    221213        if checkrun
    222             update_waitbar(hseries.Waitbar,index/(nbfield))
    223             stopstate=get(hseries.RUN,'BusyAction');
     214            stopstate=get(Param.RUNHandle,'BusyAction');
     215            update_waitbar(Param.WaitbarHandle,index/nbfield)
    224216        else
    225217            stopstate='queue';
Note: See TracChangeset for help on using the changeset viewer.