Changeset 451 for trunk


Ignore:
Timestamp:
Jun 12, 2012, 12:29:19 AM (12 years ago)
Author:
sommeria
Message:

bugs repaired in aver_stat and check_data_file

sub_background largely modified. Tests needed
other functions not yet translated

Location:
trunk/src/series
Files:
3 edited

Legend:

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

    r449 r451  
    9797ImageTypeOptions={'image','multimage','mmreader','video'};
    9898NcTypeOptions={'netcdf','civx','civdata'};
     99   
    99100for iview=1:nbview
    100     [FileType{iview},FileInfo{iview},Object{iview}]=get_file_type(filecell{iview,1});
     101    if ~exist(filecell{iview,1}','file')
     102        msgbox_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist'])
     103        return
     104    end
     105    [FileType{iview},FileInfo{iview},MovieObject{iview}]=get_file_type(filecell{iview,1});
    101106    CheckImage{iview}=~isempty(find(strcmp(FileType{iview},ImageTypeOptions)));% =1 for images
    102107    CheckNc{iview}=~isempty(find(strcmp(FileType{iview},NcTypeOptions)));% =1 for netcdf files
    103108end
    104109
    105 %% Calibration data and timing: read the ImaDoc files
     110%% calibration data and timing: read the ImaDoc files
    106111mode=''; %default
    107112timecell={};
     
    321326                Field=Data{1};
    322327            end
     328           
     329            %field projection on an object
    323330            if Param.CheckObject
    324331                [Field,errormsg]=proj_field(Field,ProjObject);
     
    393400%%%%%%%%%%%%%%%% end loop on slices %%%%%%%%%%%%%%%%
    394401
    395 %% reproduce ImaDoc/GeometryCalib for image series
    396 % if isfield(XmlData{1},'GeometryCalib') && ~isempty(XmlData{1}.GeometryCalib)
    397 %     [tild,RootFile]=fileparts(filebase_out);
    398 %     outputxml=fullfile(pathdir,[RootFile '.xml']);
    399 %     errormsg=update_imadoc(XmlData{1}.GeometryCalib,outputxml);% introduce the calibration data in the xml file
    400 %     if strcmp(errormsg,'')
    401 %         display(['GeometryCalib transferred to ' outputxml])
    402 %     else
    403 %         msgbox_uvmat('ERROR',errormsg);
    404 %     end
    405 % end
    406 
    407 %% open the result file with uvmat
    408 hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI
    409 delete(hget_field)
    410 uvmat(OutputFile)% open the last result file with uvmat
     402%% open the result file with uvmat (in RUN mode)
     403if checkrun
     404    hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI
     405    delete(hget_field)
     406    uvmat(OutputFile)% open the last result file with uvmat
     407end
  • trunk/src/series/check_data_files.m

    r447 r451  
    114114        Tabchar=message;
    115115    else
    116         datnum=zeros(1,nbfield);
    117116        Tabchar={};
    118117        %LOOP ON SLICES
     
    120119            index_slice=i_slice:NbSlice:nbfield;
    121120            filefound={};
     121            datnum=zeros(1,nbfield_j);
    122122            for ifile=1:nbfield_i
    123 %                 index(ifile)=index_slice(ifile);
    124123                stopstate=get(hseries.RUN,'BusyAction');
    125124                if isequal(stopstate,'queue')% enable STOP command
     
    129128                    detect=exist(file,'file'); % check the existence of the file
    130129                    if detect==0
    131                         count=count+1;
     130%                         count=count+1;
    132131                        lastfield='not found';
    133132                    else
     
    135134                        if isfield(datfile,'datenum')
    136135                            datnum(ifile)=datfile.datenum;
    137                         end
    138                         filefound(ifile)={datfile.name};
     136                            filefound(ifile)={datfile.name};
     137                        end                     
    139138                        lastfield='';
    140139                        [FileType,FileInfo,Object]=get_file_type(file);
     
    152151            end
    153152        end
    154 %         if isempty(datnum)||isempty(filefound)
    155153        if isempty(filefound)
    156154            if NbSlice>1
     
    161159        else
    162160            datnum=datnum(find(datnum));%keep the non zero values corresponding to existing files
     161            filefound=filefound(find(datnum));
    163162            [first,ind]=min(datnum);
    164163            [last,indlast]=max(datnum);
    165             message={['oldest modification:  ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
    166                 ['latest modification:  ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
     164            message={['oldest modification:  ' filefound{ind} ' : ' datestr(first)];...
     165                ['latest modification:  ' filefound{indlast} ' : ' datestr(last)]};
    167166        end
    168167        if ~isempty(Tabchar)
  • trunk/src/series/sub_background.m

    r447 r451  
    11%'sub_background': substract background to an image series, used with series.fig
    22%------------------------------------------------------------------------
    3 % function GUI_input=sub_background(Param)
    4 %
    5 %OUTPUT
    6 % GUI_input=list of options in the GUI series.fig needed for the function
    7 %
    8 %INPUT:
    9 %num_i1: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)
    10 %num_i2: series of second indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)
    11 %num_j1: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ )
    12 %num_j2: series of second indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ)
    13 %Series: Matlab structure containing information set by the series interface
    14 %       .RootPath: path to the image series
    15 %       .RootFile: root file name
    16 %       .FileExt: image file extension
    17 %       .NomType: nomenclature type for file indexing
    18 %       .NbSlice: %number of slices defined on the interface
    19 %----------------------------------------------------------------------
    203% Method:
    214    %calculate the background image by sorting the luminosity of each point
     
    3114    % nbfield2 successive images for a given slice (mode 'multilevel')
    3215    % In the mode 'volume', nbfield2=1 (1 image at each level)
     16   
     17% function GUI_input=sub_background(Param)
    3318%
     19%%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%%
     20%OUTPUT
     21% GUI_input=list of options in the GUI series.fig needed for the function
     22%
     23%INPUT:
     24% In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series.
     25% In batch mode, Param is the name of the corresponding xml file containing the same information
     26% In the absence of input (as activated when the current Action is selected
     27% in series), the function ouput GUI_input set the activation of the needed GUI elements
     28%
     29% Param contains the elements:(use the menu bar command 'export/GUI config' in series to see the current structure Param)
     30%    .InputTable: cell of input file names, (several lines for multiple input)
     31%                      each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension}
     32%    .OutputSubDir: name of the subdirectory for data outputs
     33%    .OutputDir: directory for data outputs, including path
     34%    .Action: .ActionName: name of the current activated function
     35%             .ActionPath:   path of the current activated function
     36%    .IndexRange: set the file or frame indices on which the action must be performed
     37%    .FieldTransform: .TransformName: name of the selected transform function
     38%                     .TransformPath:   path  of the selected transform function
     39%                     .TransformHandle: corresponding function handle
     40%    .InputFields: sub structure describing the input fields withfields
     41%              .FieldName: name of the field
     42%              .VelType: velocity type
     43%              .FieldName_1: name of the second field in case of two input series
     44%              .VelType_1: velocity type of the second field in case of two input series
     45%    .ProjObject: %sub structure describing a projection object (read from ancillary GUI set_object)
     46%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     47
     48   
    3449function GUI_input=sub_background (Param)
    3550
    36 %------------------------------------------------------------------------
    37 %requests for the visibility of input windows in the GUI series  (activated directly by the selection in the menu ACTION)
    38 if ~exist('Param','var')
    39     GUI_input={'RootPath';'on';...
    40         'SubDir';'off';... % subdirectory of derived files (PIV fields), ('on' by default)
    41         'RootFile';'on';... %root input file name ('on' by default)
    42         'FileExt';'on';... %inputf file extension ('on' by default)
    43         'NomType';'on';...%type of file indexing ('on' by default)
     51%% set the input elements needed on the GUI series when the action is selected in the menu ActionName
     52if ~exist('Param','var') % case with no input parameter
     53    GUI_input={'NbViewMax';1;...% max nbre of input file series (default='' , no limitation)
     54        'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
    4455        'NbSlice';'on'; ...%nbre of slices ('off' by default)
    45         'OutputDirExt';'.sbk';...
    46         %'VelTypeMenu';'on';...% menu for selecting the velocity type (civ1,..)('off' by default)
    47         %'FieldMenu';'on';...% menu for selecting the velocity field (s) in the input file ('off' by default)
    48         %'VelTypeMenu_1';'on';...% menu for selecting the velocity type (civ1,..)('off' by default)
    49         %'FieldMenu_1';'on';...% menu for selecting the velocity field (s) in the input file ('off' by default)
    50         %'CoordType';...%can use a transform function
    51         %'GetObject';...;%can use projection object
    52         %'GetMask';...;%can use mask option 
    53         %'PARAMETER';'NbSliding';...
    54         %'PARAMETER';'VolumeScan';...
    55         %'PARAMETER';'RankBrightness';...
     56        'VelType';'off';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
     57        'FieldName';'off';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
     58        'FieldTransform'; 'off';...%can use a transform function
     59        'ProjObject';'off';...%can use projection object(option 'off'/'on',
     60        'Mask';'off';...%can use mask option   (option 'off'/'on', 'off' by default)
     61        'OutputDirExt';'.sbk';...%set the output dir extension
    5662               ''};
    57     return %exit the function
    58 end
    59 
    60 %% input parameters
    61 % read the xml file for batch case
    62 if ischar(Param) && ~isempty(find(regexp('Param','.xml$')))
     63        return
     64end
     65
     66%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
     67%% get input parameters, file names and indices
     68% BATCH  case: read the xml file for batch case
     69if ischar(Param) && ~isempty(find(regexp(Param,'.xml$')))
    6370    Param=xml2struct(Param);
    6471    checkrun=0;
    65 else %  RUN case: parameters introduced as the input structure Param
     72% RUN case: parameters introduced as the input structure Param 
     73else
    6674    hseries=guidata(Param.hseries);%handles of the GUI series
    67     WaitbarPos=get(hseries.waitbar_frame,'Position');
    68     checkrun=1;
    69 end
    70 filebase=fullfile(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3});
    71 dir_images=Param.InputTable{1,1};
    72 NomType=Param.InputTable{1,4};
    73 SubDir=Param.InputTable{1,2};
    74 FileExt=Param.InputTable{1,5};
    75 [filecell,i1_series,tild,j1_series]=get_file_series(Param);%generates the set of input file names
    76 if size(filecell,1)>1
    77     msgbox_uvmat('WARNING','This function uses only the first input image series')
     75    WaitbarPos=get(hseries.waitbar_frame,'Position');%position of the waitbar on the GUI series
     76    checkrun=1; % indicate the RUN option is used
     77end
     78% get the set of input file names (cell array filecell), and the lists of
     79% input file or frame indices i1_series,i2_series,j1_series,j2_series
     80[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
     81% filecell{iview,fileindex}: cell array representing the list of file names
     82%        iview: line in the table corresponding to a given file series
     83%        fileindex: file index within  the file series,
     84% 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
     85% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
     86% set of frame indices used for movie or multimage input
     87if ~isempty(j1_series)
     88    frame_index=j1_series;
     89else
     90    frame_index=i1_series;
     91end
     92
     93%% root input file(s) and type
     94RootPath=Param.InputTable(:,1);
     95RootFile=Param.InputTable(:,3);
     96SubDir=Param.InputTable(:,2);
     97NomType=Param.InputTable(:,4);
     98FileExt=Param.InputTable(:,5);
     99
     100% numbers of slices and file indices
     101NbSlice=1;%default
     102if isfield(Param.IndexRange,'NbSlice')
     103    NbSlice=Param.IndexRange.NbSlice;
     104end
     105nbview=size(i1_series,1);%number of input file series (lines in InputTable)
     106nbfield_j=size(i1_series,2); %nb of consecutive fields at each level(burst
     107nbfield=nbfield_j*size(i1_series,3); %total number of files or frames
     108nbfield_i=floor(nbfield/NbSlice);%total number of i indexes (adjusted to an integer number of slices)
     109nbfield=nbfield_i*nbfield_j; %total number of fields after adjustement
     110
     111%determine the file type on each line from the first input file
     112ImageTypeOptions={'image','multimage','mmreader','video'};
     113NcTypeOptions={'netcdf','civx','civdata'};
     114   
     115% % for iview=1:nbview
     116%     if ~exist(filecell{iview,1}','file')
     117%         msgbox_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist'])
     118%         return
     119%     end
     120%     [FileType{iview},FileInfo{iview},Object{iview}]=get_file_type(filecell{iview,1});
     121%     CheckImage{iview}=~isempty(find(strcmp(FileType{iview},ImageTypeOptions)));% =1 for images
     122%     CheckNc{iview}=~isempty(find(strcmp(FileType{iview},NcTypeOptions)));% =1 for netcdf files
     123% end
     124
     125[FileType,FileInfo,MovieObject]=get_file_type(filecell{1,1});
     126CheckImage=~isempty(find(strcmp(FileType,ImageTypeOptions)));% =1 for images
     127
     128%% calibration data and timing: read the ImaDoc files
     129%not relevant here
     130
     131%% check coincidence in time for several input file series
     132%not relevant here
     133
     134%% coordinate transform or other user defined transform
     135%not relevant here
     136
     137%%%%%%%%%%%% END STANDARD PART  %%%%%%%%%%%%
     138 % EDIT FROM HERE
     139
     140 %% check the validity of  input file types
     141if CheckImage
     142    FileExtOut='.png'; % write result as .png images for image inputs
     143    NomTypeOut='_1_1';
     144else
     145    msgbox_uvmat('ERROR',['invalid file type input: ' FileType{1} ' not an image'])
    78146    return
    79147end
    80 
    81 %% determine input image type
    82 FileType=[];%default
    83 MovieObject=[];
    84 %FileExt=Series.FileExt;
    85 
    86 if isequal(lower(FileExt),'.avi')
    87     hhh=which('mmreader');
    88     if ~isequal(hhh,'')&& mmreader.isPlatformSupported()
    89         MovieObject=mmreader(fullfile(RootPath,SubDir,[RootFile FileExt]));
    90         FileType='movie';
    91     else
    92         FileType='avi';
    93     end
    94 elseif isequal(lower(FileExt),'.vol')
    95     FileType='vol';
    96 else
    97     form=imformats(FileExt(2:end));
    98     if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    99         if isequal(NomType,'*');
    100             FileType='multimage';
    101         else
    102             FileType='image';
    103         end
    104     end
    105 end
    106 if isempty(FileType)
    107     msgbox_uvmat('ERROR',['invalid file extension ' FileExt ': this function only accepts image or movie input'])
    108     return
    109 end
    110 
    111 nbslice_i=Param.NbSlice; %number of slices
    112 siz=size(i1_series{1});
     148%
     149% NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series
     150% if NbSlice~=nbfield_j
     151%     answer=msgbox_uvmat('INPUT_Y-N',['will not average slice by slice: for so cancel and set NbSlice= ' num2str(nbfield_j)]);
     152%     if ~strcmp(answer,'Yes')
     153%         return
     154%     end
     155% end
     156
     157%% Set field names and velocity types
     158%not relevant here
     159
     160
     161%% Initiate output fields
     162%not relevant here
     163 
     164%%% SPECIFIC PART BEGINS HERE
     165NbSlice=Param.IndexRange.NbSlice; %number of slices
     166siz=size(i1_series);
    113167nbaver_init=23;%approximate number of images used for the sliding background: to be adjusted later to include an integer number of bursts
    114168j1=[];%default
     
    119173
    120174%% adjust the proposed number of images in the sliding average to include an integer number of bursts
    121 if siz(2)~=1
    122     nbaver=floor(nbaver_init/siz(1)); % number of bursts used for the sliding background,
     175if siz(3)~=1
     176    nbaver=floor(nbaver_init/siz(2)); % number of bursts used for the sliding background,
    123177    if isequal(floor(nbaver/2),nbaver)
    124178        nbaver=nbaver+1;%put the number of burst to an odd number (so the middle burst is defined)
    125179    end
    126     nbaver_init=nbaver*siz(1);%propose by default an integer number of bursts
    127 end
    128 
    129 %% create dir of the new images
    130 if test_level
    131     term='.sbk.lev';
    132 else
    133     term='.sbk';
    134 end
    135 SubdirResult=[Param.InputTable{1,2} term];
    136 try
    137     mkdir(fullfile(Param.InputTable{1,1},SubdirResult));
    138 catch ME
    139     msgbox_uvmat('ERROR',['error in creating result directory: ' ME.message]);
    140     return
    141 end
    142 [xx,msg2] = fileattrib(fullfile(Param.InputTable{1,1},SubdirResult),'+w','g'); %yield writing access (+w) to user group (g)
    143 if ~strcmp(msg2,'')
    144     msgbox_uvmat('ERROR',['pb of permission for ' fullfile(Param.InputTable{1,1},SubdirResult) ': ' msg2])%error message for directory creation
    145     return
     180    nbaver_init=nbaver*siz(2);%propose by default an integer number of bursts
    146181end
    147182
     
    149184prompt = {'Number of images for the sliding background (MUST FIT IN COMPUETER MEMORY)';'The number of positions (laser slices)';'volume scan mode (Yes/No)';...
    150185    'the luminosity rank chosen to define the background (0.1=for dense particle seeding, 0.5 (median) for sparse particles'};
    151 dlg_title = ['get (slice by slice) a sliding background and substract to each image, result in subdir ' SubdirResult];
     186dlg_title = ['get (slice by slice) a sliding background and substract to each image, result in subdir ' Param.OutputDir];
    152187num_lines= 3;
    153 def     = { num2str(nbaver_init);num2str(nbslice_i);'No';'0.1'};
     188def     = { num2str(nbaver_init);num2str(NbSlice);'No';'0.1'};
    154189answer = inputdlg(prompt,dlg_title,num_lines,def);
    155190set(hseries.ParamVal,'String',answer([1 [3:4]]))
     
    157192
    158193nbaver_ima=str2num(answer{1});%number of images for the sliding background
    159 nbaver=ceil(nbaver_ima/siz(1));%number of bursts for the sliding background
     194nbaver=ceil(nbaver_ima/siz(2));%number of bursts for the sliding background
    160195if isequal(floor(nbaver/2),nbaver)
    161196    nbaver=nbaver+1;%put the number of burst to an odd number (so the middle burst is defined)
    162197end
    163 step=siz(1);%case of bursts: the sliding background is shifted by one burst
     198step=siz(2);%case of bursts: the sliding background is shifted by one burst
    164199vol_test=answer{3};
    165200if isequal(vol_test,'Yes')
    166201    nbfield2=1;%case of volume: no consecutive series at a given level
    167     nbslice_i=siz(1);%number of slices
     202    NbSlice=siz(2);%number of slices
    168203else
    169     nbfield2=siz(1); %nb of consecutive images at each level(burst)
    170     if siz(2)>1
    171         % nbslice_i=str2num(answer{2})/(num_i1(1,2)-num_i1(1,1));% number of slices
    172         nbslice_i=str2num(answer{2})/(i1_series{1}(1,2)-i1_series{1}(1,1));% number of slices
     204    nbfield2=siz(2); %nb of consecutive images at each level(burst)
     205    if siz(3)>1
     206        % NbSlice=str2num(answer{2})/(num_i1(1,2)-num_i1(1,1));% number of slices
     207        NbSlice=str2num(answer{2})/(i1_series(1,1,2)-i1_series(1,1,1));% number of slices
    173208    else
    174         nbslice_i=1;
    175     end
    176     if ~isequal(floor(nbslice_i),nbslice_i)
     209        NbSlice=1;
     210    end
     211    if ~isequal(floor(NbSlice),NbSlice)
    177212        msgbox_uvmat('ERROR','the number of slices must be a multiple of the i increment')
    178213        return
     
    183218    rank=1;%rank selected in the sorted image series
    184219end
    185 lengthtot=siz(1)*siz(2);
    186 nbfield=floor(lengthtot/(nbfield2*nbslice_i));%total number of i indexes (adjusted to an integer number of slices)
     220lengthtot=siz(2)*siz(3);
     221nbfield=floor(lengthtot/(nbfield2*NbSlice));%total number of i indexes (adjusted to an integer number of slices)
    187222nbfield_slice=nbfield*nbfield2;% number of fields per slice
    188223if nbaver_ima > nbfield*nbfield2
     
    198233
    199234%% prealocate memory for the sliding background
    200 % first_image=name_generator(filebase,num_i1(1),num_j1(1),FileExt,NomType);
    201 % Afirst=read_image(first_image,FileType,num_i1(1),MovieObject);
    202 Afirst=read_image(filecell{1,1},FileType,i1_series{1}(1),MovieObject);
     235Afirst=read_image(filecell{1,1},FileType{1},MovieObject,i1_series(1,1));
    203236[npy,npx]=size(Afirst);
    204237try
     
    212245%% update the xml file
    213246SubDirBase=regexprep(Param.InputTable{1,2},'\..*','');%take the root part of SubDir, before the first dot '.'
    214 filexml=fullfile(Param.InputTable{1,1},[SubDirBase '.xml']);
     247filexml=fullfile(RootPath{1},[SubDirBase '.xml']);
    215248if ~exist(filexml,'file') && exist([filebase '.xml'],'file')% xml inside the image directory
    216249    copyfile([filebase '.xml'],filexml);% copy the .xml file
     
    227260        j1=j1_series{1}(1);
    228261    end
    229     ImageName=fullfile_uvmat([dir_images term],'',Param.InputTable{1,3},'.png',NomType,i1_series{1}(1),[],j1);
    230     %     ImageName=name_generator(filebase_b,num_i1(1),num_j1(1),'.png',NomType);
     262    ImageName=fullfile_uvmat([dir_images term],'',RootFile{1},'.png',NomType,i1_series(1,1),[],j1);
    231263    [pth,ImageName]=fileparts(ImageName);
    232264    ImageName=[ImageName '.png'];
     
    250282    end
    251283    [t,NbSlice_uid]=add(t,new_uid,'element','NbSlice');
    252     [t]=add(t,new_uid,'chardata',num2str(nbslice_i));
     284    [t]=add(t,new_uid,'chardata',num2str(NbSlice));
    253285    [t,NbSlidingImages_uid]=add(t,new_uid,'element','NbSlidingImages');
    254286    [t]=add(t,NbSlidingImages_uid,'chardata',num2str(nbaver));
     
    263295
    264296%MAIN LOOP ON SLICES
    265 for islice=1:nbslice_i
     297for islice=1:NbSlice
    266298    %% select the series of image indices at the level islice
    267299    for ifield=1:nbfield
    268300        for iburst=1:nbfield2
    269             indselect(iburst,ifield)=((ifield-1)*nbslice_i+(islice-1))*nbfield2+iburst;
     301            indselect(iburst,ifield)=((ifield-1)*NbSlice+(islice-1))*nbfield2+iburst;
    270302        end
    271303    end
     
    275307        ifile=indselect(ifield);
    276308        filename=filecell{1,ifile};
    277         % filename=name_generator(filebase,num_i1(ifile),num_j1(ifile),FileExt,NomType);
    278         Aread=read_image(filename,FileType,i1_series{1}(ifile),MovieObject);
     309        Aread=read_image(filename,FileType,MovieObject,i1_series{1}(ifile));
    279310        Ak(:,:,ifield)=Aread;
    280311    end
     
    291322            j1=j1_series{1}(ifile);
    292323        end
    293         newname=fullfile_uvmat(Param.InputTable{1,1},SubdirResult,Param.InputTable{1,3},'.png',NomType,i1_series{1}(ifile),[],j1);
     324        newname=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series(1,ifile),[],i_slice,[]);
     325%         newname=fullfile_uvmat(RootPath{1},SubdirResult,RootFile{1},'.png',NomType,i1_series{1}(ifile),[],j1);
    294326        %newname=name_generator(filebase_b,i1_series{1}(ifile),j1_series{1}(ifile),'.png',NomType);% makes the new file name
    295327        if test_level
     
    307339            if checkrun
    308340                stopstate=get(hseries.RUN,'BusyAction');
    309                 update_waitbar(hseries.waitbar_frame,WaitbarPos,(ifield+(islice-1)*nbfield_slice)/(nbfield_slice*nbslice_i))
     341                update_waitbar(hseries.waitbar_frame,WaitbarPos,(ifield+(islice-1)*nbfield_slice)/(nbfield_slice*NbSlice))
    310342            else
    311343                stopstate='queue';
     
    316348                for iburst=1:step
    317349                    ifile=indselect(ifield+step*floor(nbaver/2)+iburst-1);
    318                     filename=fullfile_uvmat(Param.InputTable{1,1},SubDir,Param.InputTable{1,3},FileExt,NomType,i1_series{1}(ifile),[],j1_series{1}(ifile));
     350                    filename=fullfile_uvmat(RootPath{1},SubDir,RootFile{1},FileExt,NomType,i1_series(1,ifile),[],j1_series(1,ifile));
    319351                    %filename=name_generator(filebase,num_i1(ifile),num_j1(ifile),FileExt,NomType);
    320                     Aread=read_image(filename,FileType,i1_series{1}(ifile),MovieObject);
     352                    Aread=read_image(filename,FileType,MovieObject,i1_series(1,ifile));
    321353                    Ak(:,:,nbaver_ima-step+iburst)=Aread;
    322354                end
     
    332364                        j1=j1_series{1}(ifile);
    333365                    end
    334                     newname=fullfile_uvmat(Param.InputTable{1,1},SubdirResult,Param.InputTable{1,3},'.png',NomType,i1_series{1}(ifile),[],j1);
     366                    newname=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series(1,1),[],i_slice,[]);
     367                   % newname=fullfile_uvmat(Param.InputTable{1,1},SubdirResult,Param.InputTable{1,3},'.png',NomType,i1_series{1}(ifile),[],j1);
    335368                    %[newname]=name_generator(filebase_b,num_i1(ifile),num_j1(ifile),'.png',NomType) % makes the new file name
    336369                    if test_level
     
    359392            j1=j1_series{1}(ifile);
    360393        end
    361         newname=fullfile_uvmat(Param.InputTable{1,1},SubdirResult,Param.InputTable{1,3},'.png',NomType,i1_series{1}(ifile),[],j1);
     394        newname=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series(1,ifile),[],j1);
     395%         newname=fullfile_uvmat(Param.InputTable{1,1},SubdirResult,Param.InputTable{1,3},'.png',NomType,i1_series{1}(ifile),[],j1);
    362396        if test_level
    363397            C=levels(C);
     
    376410%------------------------------------------------------------------------
    377411%--read images and convert them to the uint16 format used for PIV
    378 function A=read_image(filename,type_ima,num,MovieObject)
     412function A=read_image(FileName,FileType,VideoObject,num)
    379413%------------------------------------------------------------------------
    380414%num is the view number needed for an avi movie
    381 switch type_ima
    382     case 'movie'
    383         A=read(MovieObject,num);
    384     case 'avi'
    385         mov=aviread(filename,num);
    386         A=frame2im(mov(1));
     415switch FileType
     416    case {'video','mmreader'}
     417        A=read(VideoObject,num);
    387418    case 'multimage'
    388         A=imread(filename,num);
     419        A=imread(FileName,num);
    389420    case 'image'   
    390         A=imread(filename);
     421        A=imread(FileName);
    391422end
    392423siz=size(A);
    393424if length(siz)==3;%color images
    394     A=sum(double(A),3);
     425    A=sum(double(A),3);% take the sum of color components
    395426end
    396427   
Note: See TracChangeset for help on using the changeset viewer.