Changeset 1134


Ignore:
Timestamp:
Apr 19, 2024, 8:21:23 PM (2 months ago)
Author:
sommeria
Message:

adapted to reading hdf5 data from fluidimage, extract_rdvision improved

Location:
trunk/src
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/get_file_info.m

    r1127 r1134  
    6262end
    6363% check the existence (not possible for OpenDAP data)
    64 if ~isempty(regexp(fileinput,'^http://'))|| exist(fileinput,'file')
     64if ~isempty(regexp(fileinput,'^http://','once'))|| exist(fileinput,'file')
    6565    FileInfo.FileName=fileinput;
    6666    FileInfo.FileType='txt'; %default
    67 % else
    68 %     return %input file does not exist.
     67 else
     68     return %input file does not exist.
    6969end
    7070[tild,tild,FileExt]=fileparts(fileinput);%get the file extension FileExt
     
    101101        end
    102102    case '.h5'
    103         hinfo=hdf5info(fileinput);
    104         if strcmp(hinfo.GroupHierarchy.Attributes(1).Value.Data,'MultipassPIVResults')
     103        hinfo=h5info(fileinput);
     104        FileInfo.CivStage=0;
     105        for igroup=1:numel(hinfo.Groups)
     106            if strcmp(hinfo.Groups(igroup).Name,'/piv0')
     107                FileInfo.CivStage=3;
     108            end
     109            if strcmp(hinfo.Groups(igroup).Name,'/piv1')
     110                FileInfo.CivStage=6;
     111                break
     112            end
     113        end
     114        if FileInfo.CivStage~=0
    105115            FileInfo.FileType='pivdata_fluidimage';
    106             FileInfo.CivStage=6; % A MODIFIER
     116        else
     117            FileInfo.FileType='h5';
    107118        end
    108119    case '.cine'
  • trunk/src/get_file_series.m

    r1127 r1134  
    4848
    4949%% determine the list of input file names
    50 % nbmissing=0;
    5150NbView=size(InputTable,1);
    5251i1_series=cell(NbView,1);% initiate index series with empty cells
     
    5453j1_series=cell(NbView,1);
    5554j2_series=cell(NbView,1);
     55
     56%LOOP ON INPUT FILE SERIES
    5657for iview=1:NbView
    5758    r.mode='';
     
    7980        end
    8081    end
    81    
     82    % case of free pairs or increment
    8283    if isempty(incr_i) || isempty(incr_j) || isequal(r(1).mode,'*-*')|| isequal(r(1).mode,'*|*')% free pairs or increment
    8384        FilePath=fullfile(InputTable{iview,1},InputTable{iview,2});
     
    130131            end
    131132        end
     133    % case of imposed file index increment
    132134    else
    133135        ref_i=first_i:incr_i:last_i;%default
  • trunk/src/read_field.m

    r1127 r1134  
    8686        ParamOut.CivStage=Field.CivStage;
    8787    case 'pivdata_fluidimage'
     88        if ~isfield(ParamIn,'VelType')
     89            ParamIn.VelType='';
     90        end
    8891        [Field,ParamOut.VelType,errormsg]=read_pivdata_fluidimage(FileName,InputField,ParamIn.VelType);
    8992        ParamOut.CivStage=Field.CivStage;
  • trunk/src/read_pivdata_fluidimage.m

    r1131 r1134  
    7777    FieldNames=[]; %default
    7878end
     79if isempty(FieldNames)||isempty(FieldNames{1})
     80    FieldNames={'vec(U,V)'};
     81end
    7982Field=[];
    8083VelTypeOut=VelType;
     
    8487    return
    8588end
    86 if ischar(FieldNames), FieldNames={FieldNames}; end;
     89if ischar(FieldNames), FieldNames={FieldNames}; end
    8790ProjModeRequest='';
    8891for ilist=1:length(FieldNames)
     
    119122Field.ListVarName={'X'  'Y'  'U'  'V'  'C'  'F'  'FF'};
    120123Field.VarDimName={'nb_vec' 'nb_vec' 'nb_vec' 'nb_vec' 'nb_vec' 'nb_vec' 'nb_vec'};
     124% Field.VarAttribute{1}.Role='coord_x';
     125% Field.VarAttribute{2}.Role='coord_y';
     126% Field.VarAttribute{3}.Role='vector_x';
     127% Field.VarAttribute{3}.FieldName={'vec(U,V)'};
     128
    121129VelTypeOut=VelType;
    122130switch VelType
  • trunk/src/series.m

    r1133 r1134  
    654654        i1=str2num(get(handles.num_first_i,'String'));
    655655        j1=str2num(get(handles.num_first_j,'String'));
    656         InputFile=fullfile_uvmat('','',InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,[],j1,[])
     656        InputFile=fullfile_uvmat('','',InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,[],j1,[]);
    657657            [RootPath,~,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileInfo,MovieObject]=...
    658658                find_file_series(fullfile(InputTable{iview,1},InputTable{iview,2}),InputFile);
     
    725725[FilePath,FileName,FileExt]=fileparts(fileinput);
    726726%%%%%%%%%%%%%%%%%%
    727 %TODO: case of input by uvmat: do not check agai the input seies %%%%%%%
     727%TODO: case of input by uvmat: do not check agai the input series %%%%%%%
    728728%%%%%%%%%%%%%%%%%%%
    729729% detect the file type, get the movie object if relevant, and look for the corresponding file series:
     
    20462046        end
    20472047       
    2048         %create the executable file
     2048        %create the executable and log file names
    20492049        file_exe_global=fullfile_uvmat('','',Param.InputTable{1,3},ExeExt,OutputNomType,...
    20502050            first_i,last_i,first_j,last_j);
     
    20552055       
    20562056        for iprocess=1:NbProcess
    2057             %create the executable file
    2058             batch_file_list{iprocess}=fullfile(OutputDir,'0_EXE',regexprep(extxml{iprocess},'.xml$',ExeExt));
    2059            
    2060             % set the log file name
    2061             filelog{iprocess}=fullfile(OutputDir,'0_LOG',regexprep(extxml{iprocess},'.xml$','.log'));
     2057            batch_file_list{iprocess}=fullfile(OutputDir,'0_EXE',regexprep(extxml{iprocess},'.xml$',ExeExt)); % executable file names
     2058            filelog{iprocess}=fullfile(OutputDir,'0_LOG',regexprep(extxml{iprocess},'.xml$','.log'));% corresponding log file names
    20622059        end
    20632060    end
     
    20772074                    switch computer
    20782075                        case {'GLNX86','GLNXA64','MACI64'}
    2079                             matlab_ver = ver('MATLAB');
    2080                             matlab_version = matlab_ver.Version;
    2081                             cmd=[...
    2082                                 '#!/bin/bash\n'...
    2083                                 'source /etc/profile\n'...
    2084                                 'module purge\n'...
    2085                                 'module load matlab/' matlab_version '\n'...% CHOICE OF MATLAB VERSION
    2086                                 'time_start=$(date +%%s)\n'...
    2087                                 'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog_global ''' <<END_MATLAB\n'...
    2088                                 'addpath(''' path_series ''');\n'...
    2089                                 'addpath(''' Param.Action.ActionPath ''');\n'];
    2090                             for iprocess=1:NbProcess
    2091                                 cmd=[cmd '' Param.Action.ActionName  '(''' filexml{iprocess} ''');\n'];
    2092                             end
    2093                             cmd=[cmd  'exit\n' 'END_MATLAB\n'...
    2094                                 'time_end=$(date +%%s)\n'...
    2095                                 'echo "global time = " $(($time_end - $time_start)) >> ''' filelog_global '''\n'];
     2076                            cmd=command_launch_matlab(filelog_global,path_series,Param.Action.ActionPath,Param.Action.ActionName,filexml,'background');
    20962077                            fprintf(fid,cmd); % fill the executable file with the  char string cmd
    20972078                            fclose(fid); % close the executable filefilelog_global
     
    21502131                        ActionFullName ' ' RunTime ' ' filexml{iprocess}]; % allow writting access to created files for user group
    21512132                else
    2152                     matlab_ver = ver('MATLAB');
    2153                     matlab_version = matlab_ver.Version;
    2154                     cmd=[...
    2155                         '#!/bin/bash\n'...
    2156                         'source /etc/profile\n'...
    2157                         'module purge\n'...
    2158                         'module load matlab/' matlab_version '\n'...% CHOICE OF CURRENT MATLAB VERSION
    2159                         'matlab -nodisplay -nosplash -nojvm -singleCompThread -logfile ''' filelog{iprocess} ''' <<END_MATLAB\n'...% open a new Matlab session without display
    2160                         'addpath(''' path_series ''');\n'...
    2161                         'addpath(''' Param.Action.ActionPath ''');\n'...
    2162                         '' Param.Action.ActionName  '(''' filexml{iprocess} ''');\n'...% launch the Matlab function selected by the GUI 'series'
    2163                         'exit\n'...
    2164                         'END_MATLAB\n'];
     2133                    cmd=command_launch_matlab(filelog_global,path_series,Param.Action.ActionPath,Param.Action.ActionName,filexml{iprocess},'cluster');
     2134                    % matlab_ver = ver('MATLAB');
     2135                    % matlab_version = matlab_ver.Version;
     2136                    % cmd=[...
     2137                    %     '#!/bin/bash\n'...
     2138                    %     'source /etc/profile\n'...
     2139                    %     'module purge\n'...
     2140                    %     'module load matlab/' matlab_version '\n'...% CHOICE OF CURRENT MATLAB VERSION
     2141                    %     'matlab -nodisplay -nosplash -nojvm -singleCompThread -logfile ''' filelog{iprocess} ''' <<END_MATLAB\n'...% open a new Matlab session without display
     2142                    %     'addpath(''' path_series ''');\n'...
     2143                    %     'addpath(''' Param.Action.ActionPath ''');\n'...
     2144                    %     '' Param.Action.ActionName  '(''' filexml{iprocess} ''');\n'...% launch the Matlab function selected by the GUI 'series'
     2145                    %     'exit\n'...
     2146                    %     'END_MATLAB\n'];
    21652147                end
    21662148                fprintf(fid,cmd); % fill the executable file with the  char string cmd
     
    30062988[i1,i2,j1,j2] = get_file_index(ref_i,ref_j,PairString);
    30072989FileName=fullfile_uvmat(InputTable{1},InputTable{2},InputTable{3},InputTable{5},InputTable{4},i1,i2,j1,j2);
    3008 Data=nc2struct(FileName,[]);
     2990%Data=nc2struct(FileName,[]);
    30092991TimeValue=[];
    30102992DtValue=[];
    3011 if isequal(FileInfo.FileType,'civdata')
     2993switch FileInfo.FileType
     2994    case 'civdata'
     2995    Data=nc2struct(FileName,[]);
    30122996    if ismember(TimeName,{'civ1','filter1'})
    30132997        if isfield(Data,'Civ1_Time')
     
    30253009        end
    30263010    end
    3027 else
     3011    case 'pivdata_fluidimage'
     3012      TimeValue=ref_i;%default
     3013      DtValue=1;%default
     3014    case 'netcdf'
     3015        Data=nc2struct(FileName,[]);
    30283016    if ~isempty(TimeName)&& isfield(Data,TimeName)
    30293017        TimeValue=Data.(TimeName);
  • trunk/src/series/extract_rdvision.m

    r1127 r1134  
    6666        ParamOut.WholeIndexRange='on';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
    6767        ParamOut.NbSlice='off';%1; ...%nbre of slices, 1 prevents splitting in several processes, ('off' by default)
    68         ParamOut.VelType='off';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
     68    ParamOut.VelType='off';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    6969        ParamOut.FieldName='off';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
    7070        ParamOut.FieldTransform = 'off';...%can use a transform function
     
    7272        ParamOut.Mask='off';...%can use mask option   (option 'off'/'on', 'off' by default)
    7373        ParamOut.CPUTime=0.1;% expected time for writting one image ( in minute)
    74         ParamOut.OutputDirExt='.extract';%set the output dir extensionextract_rdvision.m
     74    ParamOut.OutputDirExt='.extract';%set the output dir extension
    7575    ParamOut.OutputSubDirMode='one'; %output folder given by the folder name of the first input line
    7676    % detect the set of image folder
     
    102102    set(hhseries.InputTable,'Data',InputTable)
    103103    ParamOut.ActionInput.LogPath=RootPath;% indicate the path for the output info: 0_LOG ....
     104
     105    % check the names of .seq and .sqb files
     106    iview=1;
     107    switch Param.InputTable{iview,5}
     108        case {'.seq','.sqb'}
     109            filename_seq=fullfile(RootPath,Param.InputTable{iview,2},[Param.InputTable{iview,3} '.seq']);
     110            filename_sqb=fullfile(RootPath,Param.InputTable{iview,2},[Param.InputTable{iview,3} '.sqb']);
     111            if ~exist(filename_seq,'file')
     112                msgbox_uvmat('ERROR',[filename_seq ' missing']);
     113            end
     114            if ~exist(filename_sqb,'file')
     115                msgbox_uvmat('ERROR',[filename_sqb ' missing']);
     116            end
     117            filexml=[fullfile(RootPath,Param.InputTable{iview,2},Param.InputTable{iview,3}) '.xml'];%xml at the level of the image folder
     118            if ~exist(filexml,'file')
     119                msgbox_uvmat('ERROR',[filexml ' missing: needed to get the image organisation and timing ']);
     120                return
     121            end
     122            [XmlData,errormsg]=imadoc2struct(filexml);
     123            if ~isempty(errormsg)
     124                msgbox_uvmat('ERROR',errormsg);
     125                return
     126            end
     127            timexml=reshape(XmlData.Time(2:end,2:end)',1,[]);
     128        otherwise
     129            msgbox_uvmat('ERROR','bad input file : select .seq or .sqb for image extraction');
     130            return
     131    end
     132    % get data from .seq file
     133    s=ini2struct(filename_seq);
     134    SeqData=s.sequenceSettings;
     135    SeqData.nb_frames=str2double(s.sequenceSettings.numberoffiles);
     136% reading the .sqb file
     137    m = memmapfile(filename_sqb,'Format', { 'uint32' [1 1] 'offset'; ...
     138        'uint32' [1 1] 'garbage1';...
     139        'double' [1 1] 'timestamp';...
     140        'uint32' [1 1] 'file_idx';...
     141        'uint32' [1 1] 'garbage2' },'Repeat',SeqData.nb_frames);
     142   
     143        timestamp=zeros(1,numel(m.Data));
     144        for ii=1: numel(m.Data)
     145            timestamp(ii)=m.Data(ii).timestamp;
     146        end
     147        if numel(timestamp)<= numel(timexml)
     148            timexml=timexml(1:numel(timestamp));
     149        else
     150            msgbox_uvmat('ERROR','time sequence defined by the xml file too small')
     151            return
     152        end
     153        difftime=timestamp-timexml;
     154        if max(difftime)>0.01
     155        figure
     156        plot(timestamp,difftime)
     157        xlabel('timestamps(s)')
     158        ylabel('time difference(s)')
     159        title('discrepency timestamps-timexml')
     160        end
    104161    return
    105162end
    106163
     164
     165%%%%%%%%%%%% STANDARD PART  %%%%%%%%%%%%
    107166ParamOut=[];
    108 %%%%%%%%%%%% STANDARD PART  %%%%%%%%%%%%
    109167%% read input parameters from an xml file if input is a file name (batch mode)
    110168
     
    128186% input file or frame indices i1_series,i2_series,j1_series,j2_series
    129187[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
    130 
    131 %OutputDir=[Param.OutputSubDir Param.OutputDirExt];
    132188 
    133189% numbers of slices and file indices
     
    137193
    138194%determine the file type on each line from the first input file
    139 
    140195FileInfo=get_file_info(filecell{1,1});
    141196if strcmp(FileInfo.FileType,'rdvision')
    142 %     if ~isequal(FileInfo.NumberOfFrames,nbfield)
    143 %         disp_uvmat('WARNING',['the whole series of ' num2str(FileInfo.NumberOfextract_rdvision.mFrames) ' images must be extracted at once'],checkrun)
    144 %         %rmfield(OutputDir)
    145 % %         return
    146 %     end
     197
    147198    %% interactive input of specific parameters (for RDvision system)
    148199    display('converting images from RDvision system...')
     
    166217%%%  loop on the cameras ( #iview)
    167218%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    168 % RootPath=Param.InputTable(:,1);
    169 % RootFile=Param.InputTable(:,3);
    170 % SubDir=Param.InputTable(:,2);
    171 % NomType=Param.InputTable(:,4);
    172 % FileExt=Param.InputTable(:,5);
    173 
    174 % [XmlData,NbSlice_calib,time,errormsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series);
    175 % if size(time,1)>1
    176 %     diff_time=max(max(diff(time)));
    177 %     if diff_time>0
    178 %         disp_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)],checkrun)
    179 %     end
    180 % end
    181 %
    182 %      nbfield2=size(time,1);
    183 checkpreserve=0;% if =1, will npreserve the original images, else it erases them at the end
    184219
    185220for iview=1:size(Param.InputTable,1)
     
    196231    newxml=[newxml '.xml'];
    197232   
    198     %% get the names of .seq and .sqb files
     233    %% get the names of .seq and .sqb files and save them to the log output folder .extract
    199234    switch Param.InputTable{iview,5}
    200235        case {'.seq','.sqb'}
     
    202237            filename_sqb=fullfile(RootPath,Param.InputTable{iview,2},[Param.InputTable{iview,3} '.sqb']);
    203238            errormsg='';
    204             if isequal(Param.IndexRange.first_i,1)
    205                
     239            % backup of the seq, sqb and xml files for the first frame index
     240            if isequal(Param.IndexRange.first_i,1)% backup of the seq, sqb and xml files for the first frame index
    206241                logdir=[Param.OutputSubDir Param.OutputDirExt];
    207242                [success,errormsg] = copyfile(filename_seq,[fullfile(RootPath,logdir,Param.InputTable{iview,3}) '.seq']); %copy the seq file in the upper folder
     
    215250                if check_xml
    216251                    [success,errormsg] = copyfile(filexml,[fullfile(RootPath,logdir,Param.InputTable{iview,3}) '.xml']); %copy the original xml file in the upper folder
    217                 if ~success
    218                     disp(errormsg)
    219                 end
     252                    if ~success
     253                        disp(errormsg)
     254                    end
    220255                else
    221256                    disp(['error:' filexml ' missing']);
     
    310345        return
    311346    end
    312    
    313     % check the existence of the expected output image files (from the xml)
    314    
    315     FileDir=SeqData.sequencename;
    316      FileDir=regexprep(FileDir,'_Master_Dalsa_4M180$','');%suppress '_Master_Dalsa_4M180'
    317 %     for i1=1:numel(timestamp)/nbfield2
    318 %         for j1=1:nbfield2
    319 %             OutputFile=fullfile_uvmat(RootPath,FileDir,'img','.png',NomTypeNew,i1,[],j1);% TODO: set NomTypeNew from SeqData.mode
    320 %             try
    321 %             A=imread(OutputFile);% check image reading (stop if error)
    322 %             catch ME
    323 %                 disp(['checking ' OutputFile])
    324 %                 disp(ME.message)
    325 %             end
    326 %         end
    327 %     end
     347
    328348end
    329349
  • trunk/src/series/merge_proj.m

    r1127 r1134  
    6767    ParamOut.FieldName='one';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
    6868    ParamOut.FieldTransform = 'on';%can use a transform function
    69     ParamOut.TransformPath=fullfile(fileparts(which('uvmat')),'transform_field');% path to transform functions (needed for compilation only)
     69    %%%%% list of possible transform functions (needed only for compilation)
     70        ListTransform={'phys','phys_polar','sub_field'};%list of possible transform functions (needed only for compilation)
     71        if 0==1 %never satisfied but trigger compilation with the appropriate transform functions
     72            for ilist=1:numel(ListTransform)
     73                eval(ListTransform)
     74            end
     75        end
     76    ParamOut.TransformPath=fullfile(fileparts(which('uvmat')),'transform_field');% path to transform functions
     77    %%%%%%%%
    7078    ParamOut.ProjObject='on';%can use projection object(option 'off'/'on',
    7179    ParamOut.Mask='on';%can use mask option   (option 'off'/'on', 'off' by default)
     
    8694    return
    8795end
    88 if 0==1
    89     phys; % used to include phys when compiling is done
    90 end
     96
    9197%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
    9298ParamOut=[]; %default output
     
    115121RootFile=Param.InputTable(:,3);
    116122SubDir=Param.InputTable(:,2);
    117 % NomType=Param.InputTable(:,4);
    118123FileExt=Param.InputTable(:,5);
    119124
     
    126131% 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
    127132% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
    128 if ~isempty(hdisp),delete(hdisp),end;%end the waiting display
     133if ~isempty(hdisp),delete(hdisp),end %end the waiting display
    129134
    130135NbView=numel(i1_series);%number of input file series (lines in InputTable)
     
    134139
    135140%% determine the file type on each line from the first input file
    136 NcTypeOptions={'netcdf','civx','civdata'};
     141NcTypeOptions={'netcdf','civx','civdata','pivdata_fluidimage'};
    137142for iview=1:NbView
    138143    if ~exist(filecell{iview,1}','file')
     
    178183%% coordinate transform or other user defined transform
    179184transform_fct='';%default fct handle
     185 checksub=0;
    180186if isfield(Param,'FieldTransform')&&~isempty(Param.FieldTransform.TransformName)
    181187    currentdir=pwd;
     
    187193            XmlData{iview}.TransformInput=Param.TransformInput;
    188194        end
    189     end       
     195    end
     196    checksub=nargin(transform_fct);% number of input arguments for the selected transform fct
     197    if checksub>2 && NbView>2
     198        disp_uvmat('WARNING',['only the two first input file series will be combined by ' Param.FieldTransform.TransformName],checkrun)
     199    end
    190200end
    191201%%%%%%%%%%%% END STANDARD PART  %%%%%%%%%%%%
     
    305315        end
    306316       
    307         %% transform the input field (e.g; phys) if requested (no transform involving two input fields)
     317        %% transform the input field iview (e.g; phys) if requested (no transform involving two input fields at this stage)
     318        checksub=0;
    308319        if ~isempty(transform_fct)
    309             if nargin(transform_fct)>=2
     320            checksub=nargin(transform_fct);
     321            if checksub==2
    310322                Data{iview}=transform_fct(Data{iview},XmlData{iview});
    311             else
     323            elseif checksub==1
    312324                Data{iview}=transform_fct(Data{iview});
    313325            end
     
    338350    %%%%%%%%%%%%%%%% END LOOP ON VIEWS %%%%%%%%%%%%%%%%
    339351
    340     %% merge the NbView fields
    341     [MergeData,errormsg]=merge_field(Data);
     352    %% merge the NbView fields
     353    if checksub<=2
     354        [MergeData,errormsg]=merge_field(Data);%concatene all the input field series by fct merge_data
     355    elseif checksub==3
     356        MergeData=transform_fct(Data{1},XmlData{1},Data{2}); %combine the two input file series
     357    else
     358        MergeData=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2});%combine the two input file series with calibration parameters
     359    end
    342360    if ~isempty(errormsg)
    343361        disp_uvmat('ERROR',errormsg,checkrun);
Note: See TracChangeset for help on using the changeset viewer.