Changeset 843 for trunk/src/series/extract_rdvision.m
- Timestamp:
- Dec 12, 2014, 1:21:45 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/extract_rdvision.m
r841 r843 78 78 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 79 79 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'; 82 82 isel=0; 83 83 for ilist=1:numel(ListDir) … … 91 91 isel=isel+1; 92 92 InputTable{isel,1}=RootPath; 93 InputTable{isel,2}=ListDir{ilist}; 93 94 RootFile=regexprep(ListCellSub{1,seq_index},'.seq$',''); 94 95 InputTable{isel,3}=RootFile; 95 end96 96 InputTable{isel,4}='*'; 97 97 InputTable{isel,5}='.seq'; 98 end 98 99 end 99 100 hseries=findobj(allchild(0),'Tag','series');% find the parent GUI 'series' … … 267 268 268 269 %% backup the previous xml file and save the corrected one 269 [success,message]=copyfile(filexml,[filexml '~']);%make backup270 if success~=1271 dips(['errror in xml file backup: ' message]);272 return273 end270 % [success,message]=copyfile(filexml,[filexml '~']);%make backup 271 % if success~=1 272 % disp(['errror in xml file backup: ' message]); 273 % return 274 % end 274 275 save(t,filexml) 275 276 nbfield2=1; … … 338 339 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 339 340 function [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 du341 % fichier seq associ é.341 % BINREAD_RDV Permet de lire les fichiers bin gï¿œnï¿œrï¿œs par Hiris ï¿œ partir du 342 % fichier seq associï¿œ. 342 343 % [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 ées344 % l'image d'indice FRAME_IDX de la sï¿œquence FILENAME. 345 % 346 % Entrï¿œes 346 347 % ------- 347 % FILENAME : Nom du fichier s équence (.seq).348 % FRAME_IDX : Indice de l'image àlire. Si FRAME_IDX vaut -1 alors la349 % s équence est entièrement lue. Si FRAME_IDX est un tableau d'indices348 % 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 350 351 % alors toutes les images d'incides correspondant sont lues. Si FRAME_IDX 351 352 % 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. 354 355 % 355 356 % Sorties … … 357 358 % IMGS : Images de sortie. 358 359 % 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. 360 361 NbBinFile=0; 361 362 BinSize=0; … … 366 367 BitDepth=8*SeqData.bytesperpixel;%needed to write images (8 or 16 bits) 367 368 binrepertoire=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 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 376 if s==0 377 disp(errormsg) 378 return%not able to create new image dir 379 end 377 380 end 378 381 for ii=1:SeqData.nb_frames 379 OutputFile=fullfile_uvmat(PathDir,SeqData.sequencename,'img','.png',NomTypeNew,i1,[],j1);% TODO: set NomTypeNew from SeqData.mode380 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 use382 fid=fopen(fname,'rb');383 fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file384 NbBinFile=NbBinFile+1;%counter of binary files (for checking purpose)385 386 BinSize(NbBinFile)=0;% strat counter for new bin file387 else388 fclose(fid);%close the previous bin file389 fid=fopen(fname,'rb');% open the new bin file390 fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file391 end392 fname_prev=fname;393 A=reshape(fread(fid,SeqData.width*SeqData.height,classname),SeqData.width,SeqData.height);%read the current image394 A=A';395 BinSize(NbBinFile)=BinSize(NbBinFile)+SeqData.width*SeqData.height*SeqData.bytesperpixel*8; %record bits read396 382 j1=[]; 397 383 if ~isequal(nbfield2,1) … … 399 385 end 400 386 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 427 end 428 if fid~=0 414 429 fclose(fid) 415 toc 430 end 431 416 432 417 433 … … 450 466 % return 451 467 % end 452 % 468 % 453 469 % end 454 470 455 %'imadoc2struct_special': reads the xml file for image documentation 471 %'imadoc2struct_special': reads the xml file for image documentation 456 472 %------------------------------------------------------------------------ 457 % function [s,errormsg]=imadoc2struct_special(ImaDoc,option) 473 % function [s,errormsg]=imadoc2struct_special(ImaDoc,option) 458 474 % 459 475 % OUTPUT:
Note: See TracChangeset
for help on using the changeset viewer.