Changeset 843 for trunk


Ignore:
Timestamp:
Dec 12, 2014, 1:21:45 PM (9 years ago)
Author:
sommeria
Message:
 
File:
1 edited

Legend:

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

    r841 r843  
    7878    check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
    7979    ListDir=ListCells(1,find(check_dir & ~check_bad));
    80     InputTable=cell(numel(ListDir),5);
    81     InputTable(:,2)=ListDir';
     80%     InputTable=cell(numel(ListDir),5);
     81%     InputTable(:,2)=ListDir';
    8282    isel=0;
    8383    for ilist=1:numel(ListDir)
     
    9191           isel=isel+1;
    9292           InputTable{isel,1}=RootPath;
     93           InputTable{isel,2}=ListDir{ilist};
    9394            RootFile=regexprep(ListCellSub{1,seq_index},'.seq$','');
    9495            InputTable{isel,3}=RootFile;
    95         end
    9696        InputTable{isel,4}='*';
    9797        InputTable{isel,5}='.seq';
     98    end
    9899    end
    99100    hseries=findobj(allchild(0),'Tag','series');% find the parent GUI 'series'
     
    267268   
    268269    %% backup the previous xml file and save the corrected one
    269     [success,message]=copyfile(filexml,[filexml '~']);%make backup
    270     if success~=1
    271         dips(['errror in xml file backup: ' message]);
    272         return
    273     end
     270%    [success,message]=copyfile(filexml,[filexml '~']);%make backup
     271%     if success~=1
     272%         disp(['errror in xml file backup: ' message]);
     273%         return
     274%     end
    274275    save(t,filexml)
    275276    nbfield2=1;
     
    338339%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    339340function [BinSize,errormsg]=binread_rdv_series(PathDir,SeqData,SqbData,nbfield2,NomTypeNew)
    340 % BINREAD_RDV Permet de lire les fichiers bin générés par Hiris à partir du
    341 % fichier seq associé.
     341% BINREAD_RDV Permet de lire les fichiers bin gï¿œnï¿œrï¿œs par Hiris ï¿œ partir du
     342% fichier seq associï¿œ.
    342343%   [IMGS,TIMESTAMPS,NB_FRAMES] = BINREAD_RDV(FILENAME,FRAME_IDX) lit
    343 %   l'image d'indice FRAME_IDX de la séquence FILENAME.
    344 %
    345 %   Entrées
     344%   l'image d'indice FRAME_IDX de la sï¿œquence FILENAME.
     345%
     346%   Entrï¿œes
    346347%   -------
    347 %   FILENAME  : Nom du fichier séquence (.seq).
    348 %   FRAME_IDX : Indice de l'image à lire. Si FRAME_IDX vaut -1 alors la
    349 %   séquence est entièrement lue. Si FRAME_IDX est un tableau d'indices
     348%   FILENAME  : Nom du fichier sï¿œquence (.seq).
     349%   FRAME_IDX : Indice de l'image ï¿œ lire. Si FRAME_IDX vaut -1 alors la
     350%   sï¿œquence est entiï¿œrement lue. Si FRAME_IDX est un tableau d'indices
    350351%   alors toutes les images d'incides correspondant sont lues. Si FRAME_IDX
    351352%   est un tableau vide alors aucune image n'est lue mais le nombre
    352 %   d'images et tous les timestamps sont renvoyés. Les indices commencent à
    353 %   1 et se termines à NB_FRAMES.
     353%   d'images et tous les timestamps sont renvoyï¿œs. Les indices commencent ï¿œ
     354%   1 et se termines ï¿œ NB_FRAMES.
    354355%
    355356%   Sorties
     
    357358%   IMGS        : Images de sortie.
    358359%   TIMESTAMPS  : Timestaps des images lues.
    359 %   NB_FRAMES   : Nombres d'images dans la séquence.
     360%   NB_FRAMES   : Nombres d'images dans la sï¿œquence.
    360361NbBinFile=0;
    361362BinSize=0;
     
    366367BitDepth=8*SeqData.bytesperpixel;%needed to write images (8 or 16 bits)
    367368binrepertoire=fullfile(PathDir,SeqData.binrepertoire);
    368 tic
    369 OutputDir=fullfile(PathDir,SeqData.sequencename)
    370 if exist(OutputDir,'dir')
    371     errormsg=[OutputDir ' already exist, delete it first'];
    372     return
    373 end
    374 [s,errormsg]=mkdir(OutputDir);
    375 if s==0
    376     return%not able to create new image dir
     369OutputDir=fullfile(PathDir,SeqData.sequencename);
     370if ~exist(OutputDir,'dir')
     371    %     errormsg=[OutputDir ' already exist, delete it first'];
     372    %     return
     373    % end
     374    [s,errormsg]=mkdir(OutputDir);
     375   
     376    if s==0
     377        disp(errormsg)
     378        return%not able to create new image dir
     379    end
    377380end
    378381for ii=1:SeqData.nb_frames
    379     OutputFile=fullfile_uvmat(PathDir,SeqData.sequencename,'img','.png',NomTypeNew,i1,[],j1);% TODO: set NomTypeNew from SeqData.mode
    380     fname=fullfile(binrepertoire,sprintf('%s%.5d.bin',SeqData.binfile,SqbData(ii).file_idx));
    381     if ii==1 || ~strcmp(fname,fname_prev) % open the bin file if not in use
    382         fid=fopen(fname,'rb');
    383         fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file
    384         NbBinFile=NbBinFile+1;%counter of binary files (for checking purpose)
    385        
    386         BinSize(NbBinFile)=0;% strat counter for new bin file
    387     else
    388         fclose(fid);%close the previous bin file
    389         fid=fopen(fname,'rb');% open the new bin file
    390         fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file
    391     end
    392     fname_prev=fname;
    393     A=reshape(fread(fid,SeqData.width*SeqData.height,classname),SeqData.width,SeqData.height);%read the current image
    394     A=A';
    395     BinSize(NbBinFile)=BinSize(NbBinFile)+SeqData.width*SeqData.height*SeqData.bytesperpixel*8; %record bits read
    396382    j1=[];
    397383    if ~isequal(nbfield2,1)
     
    399385    end
    400386    i1=floor((ii-1)/nbfield2)+1;
    401     try
    402         imwrite(A,OutputFile,'BitDepth',BitDepth) % case of 16 bit images
    403         disp([OutputFile ' written']);
    404        % [s,errormsg] = fileattrib(OutputFile,'-w','a'); %set images to read only '-w' for all users ('a')
    405 %         if ~s
    406 % %             disp_uvmat('ERROR',errormsg,checkrun);
    407 %             return
    408 %         end
    409     catch ME
    410         errormsg=ME.message;
    411         return
    412     end
    413 end
     387    OutputFile=fullfile_uvmat(PathDir,SeqData.sequencename,'img','.png',NomTypeNew,i1,[],j1);% TODO: set NomTypeNew from SeqData.mode
     388    fname=fullfile(binrepertoire,sprintf('%s%.5d.bin',SeqData.binfile,SqbData(ii).file_idx));
     389    if exist(OutputFile,'file')
     390        fid=0;
     391    else
     392        if fid==0 || ~strcmp(fname,fname_prev) % open the bin file if not in use
     393            if fid~=0
     394                fclose(fid);%close the previous bin file if relevant
     395            end
     396            [fid,msg]=fopen(fname,'rb');
     397            if isequal(fid,-1)
     398                disp(['error in opening ' fname ': ' msg])
     399            else
     400                disp([fname ' opened for reading'])
     401            end
     402            fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file
     403            NbBinFile=NbBinFile+1;%counter of binary files (for checking purpose)
     404            BinSize(NbBinFile)=0;% strat counter for new bin file
     405        else
     406            %             fclose(fid);%close the previous bin file
     407            %             fid=fopen(fname,'rb');% open the new bin file
     408            fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file
     409        end
     410        fname_prev=fname;
     411        A=reshape(fread(fid,SeqData.width*SeqData.height,classname),SeqData.width,SeqData.height);%read the current image
     412        A=A';
     413        BinSize(NbBinFile)=BinSize(NbBinFile)+SeqData.width*SeqData.height*SeqData.bytesperpixel*8; %record bits read
     414        try
     415            imwrite(A,OutputFile,'BitDepth',BitDepth) % case of 16 bit images
     416            disp([OutputFile ' written']);
     417            % [s,errormsg] = fileattrib(OutputFile,'-w','a'); %set images to read only '-w' for all users ('a')
     418            %         if ~s
     419            % %             disp_uvmat('ERROR',errormsg,checkrun);
     420            %             return
     421            %         end
     422        catch ME
     423            errormsg=ME.message;
     424            return
     425        end
     426    end
     427end
     428if fid~=0
    414429fclose(fid)
    415 toc
     430end
     431
    416432
    417433
     
    450466%         return
    451467%     end
    452 %     
     468%
    453469% end
    454470
    455 %'imadoc2struct_special': reads the xml file for image documentation 
     471%'imadoc2struct_special': reads the xml file for image documentation
    456472%------------------------------------------------------------------------
    457 % function [s,errormsg]=imadoc2struct_special(ImaDoc,option) 
     473% function [s,errormsg]=imadoc2struct_special(ImaDoc,option)
    458474%
    459475% OUTPUT:
Note: See TracChangeset for help on using the changeset viewer.