Ignore:
Timestamp:
Dec 11, 2014, 12:23:10 AM (10 years ago)
Author:
sommeria
Message:

extract_rdvision corrected

File:
1 edited

Legend:

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

    r840 r841  
    7878    check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
    7979    ListDir=ListCells(1,find(check_dir & ~check_bad));
    80     InputTable=cell(1,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};
    9493            RootFile=regexprep(ListCellSub{1,seq_index},'.seq$','');
    9594            InputTable{isel,3}=RootFile;
    96                     InputTable{isel,4}='*';
     95        end
     96        InputTable{isel,4}='*';
    9797        InputTable{isel,5}='.seq';
    98         end
    99 
    10098    end
    10199    hseries=findobj(allchild(0),'Tag','series');% find the parent GUI 'series'
     
    271269    [success,message]=copyfile(filexml,[filexml '~']);%make backup
    272270    if success~=1
    273         displ(['errror in xml file backup: ' message]);
     271        dips(['errror in xml file backup: ' message]);
    274272        return
    275273    end
     
    368366BitDepth=8*SeqData.bytesperpixel;%needed to write images (8 or 16 bits)
    369367binrepertoire=fullfile(PathDir,SeqData.binrepertoire);
    370 OutputDir=fullfile(PathDir,SeqData.sequencename);
     368tic
     369OutputDir=fullfile(PathDir,SeqData.sequencename)
    371370if exist(OutputDir,'dir')
    372371    errormsg=[OutputDir ' already exist, delete it first'];
     
    377376    return%not able to create new image dir
    378377end
    379 fid=0;
    380378for ii=1:SeqData.nb_frames
    381     OutputFile=fullfile_uvmat(PathDir,SeqData.sequencename,'img','.png',NomTypeNew,i1,[],j1);% TODO: set NomTypeNew from SeqData.mode
    382     if ~exist(OutputFile,'file')
    383         fname=fullfile(binrepertoire,sprintf('%s%.5d.bin',SeqData.binfile,SqbData(ii).file_idx));
    384         if fid==0 || ~strcmp(fname,fname_prev) % open the bin file if not in use
    385             if fid~=0
    386                 fclose(fid);%close the previous bin file
    387             end
    388             fid=fopen(fname,'rb');
    389             fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file
    390             NbBinFile=NbBinFile+1;%counter of binary files (for checking purpose)
    391             BinSize(NbBinFile)=0;% strat counter for new bin file
    392         else
    393             %
    394             %         fid=fopen(fname,'rb');% open the new bin file
    395 %             fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file
    396         end
     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');
    397383        fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file
    398         fname_prev=fname;
    399         A=reshape(fread(fid,SeqData.width*SeqData.height,classname),SeqData.width,SeqData.height);%read the current image
    400         A=A';
    401         BinSize(NbBinFile)=BinSize(NbBinFile)+SeqData.width*SeqData.height*SeqData.bytesperpixel*8; %record bits read
    402         j1=[];
    403         if ~isequal(nbfield2,1)
    404             j1=mod(ii-1,nbfield2)+1;
    405         end
    406         i1=floor((ii-1)/nbfield2)+1;
     384        NbBinFile=NbBinFile+1;%counter of binary files (for checking purpose)
    407385       
    408         try
    409             imwrite(A,OutputFile,'BitDepth',BitDepth) % case of 16 bit images
    410             disp([OutputFile ' written']);
    411             % [s,errormsg] = fileattrib(OutputFile,'-w','a'); %set images to read only '-w' for all users ('a')
    412             %         if ~s
    413             % %             disp_uvmat('ERROR',errormsg,checkrun);
    414             %             return
    415             %         end
    416         catch ME
    417             errormsg=ME.message;
    418             return
    419         end
     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
     396    j1=[];
     397    if ~isequal(nbfield2,1)
     398        j1=mod(ii-1,nbfield2)+1;
     399    end
     400    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
    420412    end
    421413end
    422414fclose(fid)
    423 
     415toc
    424416
    425417
Note: See TracChangeset for help on using the changeset viewer.