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

adapted to reading hdf5 data from fluidimage, extract_rdvision improved

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.