- Timestamp:
- Jun 6, 2012, 2:46:15 PM (13 years ago)
- Location:
- trunk/src/series
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/aver_stat.m
r420 r442 45 45 if ischar(Param) && ~isempty(find(regexp('Param','.xml$'))) 46 46 Param=xml2struct(Param); 47 checkrun=0; 47 48 else % RUN case: parameters introduced as the input structure Param 48 49 hseries=guidata(Param.hseries);%handles of the GUI series 49 50 WaitbarPos=get(hseries.waitbar_frame,'Position'); 51 checkrun=1; 50 52 end 51 53 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); … … 250 252 ext_out='.nc'; 251 253 end 252 subdir_result='aver_stat';%subdirectory for the results 253 pathdir=fullfile(RootPath{1},subdir_result);% full subdirectory name, including path 254 testexist=1; 255 while testexist 256 pathdir=fullfile(RootPath{1},subdir_result);% full subdirectory name, including path 257 if NbSlice==1% keep track of the first and lsat indices of the input files 258 %NomTypeOut=nomtype2pair(Param.InputTable{1,4},i2_series{end}(end)-i1_series{1}(1),j2_series{end}(end)-j1_series{1}(1)); 259 NomTypeOut='_1-2'; 260 fileresult{1}=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},ext_out,NomTypeOut,i1_series{1}(1),i1_series{1}(end),[],[]); 261 testexist=exist(fileresult{1},'file'); 262 else % simplified indexing with i_slice for multiple slices 263 testexist=0; 264 for i_slice=1:NbSlice 265 fileresult{1}=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},ext_out,NomTypeOut,i_slice,[],[],[]); 266 if exist(fileresult{i_slice},'file') 267 testexist=1; 268 break 269 end 270 end 271 end 272 if testexist 273 subdir_result=[subdir_result '.0']; 274 end 275 end 254 subdir_result=[SubDir{1} '.stat'];%subdirectory for the results 255 pathdir=RootPath{1};% full subdirectory name, including path 256 checkdetect=1; 257 while checkdetect %create a new subdir if the netcdf files already exist 258 checkdetect=exist(fullfile(pathdir,subdir_result)); 259 if checkdetect% if a nesult dir already exists 260 r=regexp(subdir_result,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number 261 if isempty(r) 262 r(1).root=[subdir_result '_']; 263 r(1).num1='0'; 264 end 265 subdir_result=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1 266 end 267 end 268 NomTypeOut='_1-2'; 269 fileresult{1}=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},ext_out,NomTypeOut,i1_series{1}(1),i1_series{1}(end),[],[]); 270 271 % A REPRNDRE CAS MULTI-NIVEAU: 272 % pathdir=fullfile(RootPath{1},subdir_result);% full subdirectory name, including path 273 % if NbSlice==1% keep track of the first and lsat indices of the input files 274 % %NomTypeOut=nomtype2pair(Param.InputTable{1,4},i2_series{end}(end)-i1_series{1}(1),j2_series{end}(end)-j1_series{1}(1)); 275 % NomTypeOut='_1-2'; 276 % fileresult{1}=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},ext_out,NomTypeOut,i1_series{1}(1),i1_series{1}(end),[],[]); 277 % testexist=exist(fileresult{1},'file'); 278 % else % simplified indexing with i_slice for multiple slices 279 % testexist=0; 280 % for i_slice=1:NbSlice 281 % fileresult{1}=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},ext_out,NomTypeOut,i_slice,[],[],[]); 282 % if exist(fileresult{i_slice},'file') 283 % testexist=1; 284 % break 285 % end 286 % end 287 % end 288 % if testexist 289 % subdir_result=[subdir_result '.0']; 290 % end 291 % end 276 292 % create result directory if needed 277 if ~exist( pathdir,'dir')278 [m1,m2,m3]=mkdir( pathdir);293 if ~exist(fullfile(RootPath{1},subdir_result),'dir') 294 [m1,m2,m3]=mkdir(fullfile(RootPath{1},subdir_result)); 279 295 if ~isequal(m2,'') 280 296 msgbox_uvmat('CONFIRMATION',m2);%error message for directory creation 281 297 end 282 298 end 283 [xx,msg2] = fileattrib( pathdir,'+w','g'); %yield writing access (+w) to user group (g)299 [xx,msg2] = fileattrib(fullfile(RootPath{1},subdir_result),'+w','g'); %yield writing access (+w) to user group (g) 284 300 if ~strcmp(msg2,'') 285 msgbox_uvmat('ERROR',['pb of permission for ' pathdir': ' msg2])%error message for writting access301 msgbox_uvmat('ERROR',['pb of permission for ' fullfile(RootPath{1},subdir_result) ': ' msg2])%error message for writting access 286 302 return 287 303 end … … 312 328 % if isequal(stopstate,'queue') % enable STOP command 313 329 % update_waitbar(hseries.waitbar,WaitbarPos,index/(nbfield*nbfield2)) 330 if checkrun 331 update_waitbar(hseries.waitbar_frame,WaitbarPos,index/(nbfield*nbfield2)) 332 stopstate=get(hseries.RUN,'BusyAction'); 333 else 334 stopstate='queue'; 335 end 314 336 ifile=indselect(index); 315 337 % reading input file(s) -
trunk/src/series/ima_levels.m
r349 r442 13 13 %Series: Matlab structure containing information set by the series interface% relabel_i_j: relabel an image series with two indices, according to the time matrix given by ImaDoc 14 14 %---------------------------------------------------------------------- 15 function GUI_input=ima_levels( num_i1,num_i2,num_j1,num_j2,Series)15 function GUI_input=ima_levels(Param) 16 16 %requests for the visibility of input windows in the GUI series (activated directly by the selection in the menu ACTION) 17 if ~exist(' num_i1','var')17 if ~exist('Param','var') 18 18 GUI_input={}; 19 19 return %exit the function 20 20 end 21 21 22 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%enable waitbar 23 hseries=guidata(Series.hseries);%handles of the GUI series 24 WaitbarPos=get(hseries.waitbar_frame,'Position'); 25 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 27 basename=fullfile(Series.RootPath,Series.RootFile) ; 28 29 %create dir of the new images 30 [dir_images,namebase]=fileparts(basename); 31 [path,subdir_ima]=fileparts(dir_images); 32 dircur=pwd; 33 cd(path); 34 mkdir([subdir_ima '_levels']); 35 [xx,msg2] = fileattrib([subdir_ima '_levels'],'+w','g') %yield writing access (+w) to user group (g) 36 if ~strcmp(msg2,'') 37 msgbox_uvmat('ERROR',['pb of permission for ' subdir_ima ': ' msg2])%error message for directory creation 38 cd(dircur) 22 %% input parameters 23 % read the xml file for batch case 24 if ischar(Param) && ~isempty(find(regexp('Param','.xml$'))) 25 Param=xml2struct(Param); 26 checkrun=0; 27 else % RUN case: parameters introduced as the input structure Param 28 hseries=guidata(Param.hseries);%handles of the GUI series 29 WaitbarPos=get(hseries.waitbar_frame,'Position'); 30 checkrun=1; 31 end 32 %filebase=fullfile(Param.InputTable{1,1},Param.InputTable{1,3}); 33 RootPath=Param.InputTable{1,1}; 34 Subdir=Param.InputTable{1,2}; 35 RootFile=Param.InputTable{1,3}; 36 NomType=Param.InputTable{1,4}; 37 FileExt=Param.InputTable{1,5}; 38 [filecell,i1_series,i2_series,j1_series]=get_file_series(Param);% list of input files and indices 39 if size(filecell,1)>1 40 msgbox_uvmat('WARNING','This function uses only the first input image series') 39 41 return 40 42 end 41 cd(dircur);42 basename_new=fullfile(path,[subdir_ima '_levels'],namebase);43 43 44 % read imadoc 45 %[XmlData,warntext]=imadoc2struct([basename '.xml']); 46 % nbfield1=size(XmlData.Time,1); 47 % nbfield2=size(XmlData.Time,2); 44 %% determine input image type 45 [FileType,FileInfo,MovieObject]=get_file_type(filecell{1,1}); 46 ListTypes={'image','multimage','mmreader','video'}; 48 47 48 if isempty(strcmp(FileType,ListTypes))% if the detected FileType is not in the list for images 49 msgbox_uvmat('ERROR',['invalid file extension ' FileExt ': this function only accepts image or movie input']) 50 return 51 end 52 53 %% create dir of the new images 54 SubdirResult=[Param.InputTable{1,2} '.lev'];% add the suffix '.lev' to the name of the image folder 55 try 56 mkdir(fullfile(Param.InputTable{1,1},SubdirResult)); 57 catch ME 58 msgbox_uvmat('ERROR',['error in creating result directory: ' ME.message]);%display error msg for directory creation if fails 59 return 60 end 61 [xx,msg2] = fileattrib(fullfile(Param.InputTable{1,1},SubdirResult),'+w','g'); %yield writing access (+w) to user group (g) 62 if ~strcmp(msg2,'') 63 msgbox_uvmat('ERROR',['pb of permission for ' fullfile(Param.InputTable{1,1},SubdirResult) ': ' msg2])%error message for directory creation 64 return 65 end 49 66 msgbox_uvmat('CONFIRMATION','apply image rescaling function levels.m '); 50 67 51 68 %copy the xml file 52 if exist([basename '.xml'],'file')53 copyfile([basename '.xml'],[basename_new '.xml']);% copy the .civ file54 end69 % if exist([basename '.xml'],'file') 70 % copyfile([basename '.xml'],[basename_new '.xml']);% copy the .civ file 71 % end 55 72 56 % main loop57 nbfield=size( num_i1,2);58 nbfield2=size( num_i1,1);73 %% main loop 74 nbfield=size(i1_series{1},2); 75 nbfield2=size(i1_series{1},1); 59 76 for ifile=1:nbfield 60 update_waitbar(hseries.waitbar,WaitbarPos,ifile/nbfield) 61 stopstate=get(hseries.RUN,'BusyAction'); 77 if checkrun 78 % update_waitbar(hseries.waitbar,WaitbarPos,ifile/nbfield) 79 update_waitbar(hseries.waitbar_frame,WaitbarPos,ifile/nbfield) 80 stopstate=get(hseries.RUN,'BusyAction'); 81 else 82 stopstate='queue'; 83 end 62 84 if isequal(stopstate,'queue') % enable STOP command 63 85 for jfile=1:nbfield2 64 filename=name_generator(basename,num_i1(jfile,ifile),num_j1(jfile,ifile),Series.FileExt,Series.NomType); 65 filename_new=name_generator(basename_new,num_i1(jfile,ifile),num_j1(jfile,ifile),'.png',Series.NomType); 66 A=imread(filename); 86 %filename=name_generator(basename,num_i1(jfile,ifile),num_j1(jfile,ifile),Series.FileExt,Series.NomType); 87 %filename_new=name_generator(basename_new,num_i1(jfile,ifile),num_j1(jfile,ifile),'.png',Series.NomType); 88 filename=fullfile_uvmat(RootPath,Subdir,RootFile,FileExt,NomType,i1_series{1}(jfile,ifile),[],j1_series{1}(jfile,ifile)); 89 switch FileType 90 case {'video','mmreader'} 91 A=read(MovieObject,i1_series{1}(jfile,ifile)); 92 case {'vol','image'} 93 A=imread(filename); 94 case 'multimage' 95 A=imread(filename,i1_series{1}(jfile,ifile)); 96 end 67 97 C=levels(A); 98 filename_new=fullfile_uvmat(RootPath,SubdirResult,RootFile,'.png',NomType,i1_series{1}(jfile,ifile),[],j1_series{1}(jfile,ifile)); 68 99 imwrite(C,filename_new) 100 display([filename_new ' written']) 69 101 end 70 102 end 71 103 end 72 73 104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 74 105 75 106 function C=levels(A) -
trunk/src/series/sub_background.m
r394 r442 61 61 if ischar(Param) && ~isempty(find(regexp('Param','.xml$'))) 62 62 Param=xml2struct(Param); 63 checkrun=0; 63 64 else % RUN case: parameters introduced as the input structure Param 64 65 hseries=guidata(Param.hseries);%handles of the GUI series 65 66 WaitbarPos=get(hseries.waitbar_frame,'Position'); 66 end 67 filebase=fullfile(Param.InputTable{1,1},Param.InputTable{1,3}); 67 checkrun=1; 68 end 69 filebase=fullfile(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3}); 68 70 dir_images=Param.InputTable{1,1}; 69 71 NomType=Param.InputTable{1,4}; 70 72 FileExt=Param.InputTable{1,5}; 71 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 73 [filecell,i1_series,tild,j1_series]=get_file_series(Param);%generates the set 74 of input file names 72 75 if size(filecell,1)>1 73 76 msgbox_uvmat('WARNING','This function uses only the first input image series') … … 75 78 end 76 79 77 %%% TODO: update with the new conventions%%%%%%%%%%%%%%%%%78 80 %% determine input image type 79 81 FileType=[];%default … … 84 86 hhh=which('mmreader'); 85 87 if ~isequal(hhh,'')&& mmreader.isPlatformSupported() 86 MovieObject=mmreader(fullfile(RootPath, [RootFile FileExt]));88 MovieObject=mmreader(fullfile(RootPath,SubDir,[RootFile FileExt])); 87 89 FileType='movie'; 88 90 else … … 125 127 126 128 %% create dir of the new images 127 % [dir_images,namebase]=fileparts(filebase);128 129 if test_level 129 term=' _b_levels';130 term='.sbk.lev'; 130 131 else 131 term=' _b';132 end 133 [pp,subdir_ima]=fileparts(Param.InputTable{1,1});132 term='.sbk'; 133 end 134 SubdirResult=[Param.InputTable{1,2} term]; 134 135 try 135 mkdir( [dir_images term]);136 mkdir(fullfile(Param.InputTable{1,1},SubdirResult)); 136 137 catch ME 137 msgbox_uvmat('ERROR', ME.message);138 return 139 end 140 [xx,msg2] = fileattrib( [dir_images term],'+w','g'); %yield writing access (+w) to user group (g)138 msgbox_uvmat('ERROR',['error in creating result directory: ' ME.message]); 139 return 140 end 141 [xx,msg2] = fileattrib(fullfile(Param.InputTable{1,1},SubdirResult),'+w','g'); %yield writing access (+w) to user group (g) 141 142 if ~strcmp(msg2,'') 142 msgbox_uvmat('ERROR',['pb of permission for ' subdir_ima term ': ' msg2])%error message for directory creation 143 return 144 end 145 filebase_b=fullfile([dir_images term],Param.InputTable{1,3}); 143 msgbox_uvmat('ERROR',['pb of permission for ' fullfile(Param.InputTable{1,1},SubdirResult) ': ' msg2])%error message for directory creation 144 return 145 end 146 146 147 147 %% set processing parameters 148 148 prompt = {'Number of images for the sliding background (MUST FIT IN COMPUETER MEMORY)';'The number of positions (laser slices)';'volume scan mode (Yes/No)';... 149 149 'the luminosity rank chosen to define the background (0.1=for dense particle seeding, 0.5 (median) for sparse particles'}; 150 dlg_title = ['get (slice by slice) a sliding background and substract to each image, result in subdir ' subdir_ima term];150 dlg_title = ['get (slice by slice) a sliding background and substract to each image, result in subdir ' SubdirResult]; 151 151 num_lines= 3; 152 152 def = { num2str(nbaver_init);num2str(nbslice_i);'No';'0.1'}; … … 209 209 end 210 210 211 %% copy the xml file 212 if exist([filebase '.xml'],'file') 213 copyfile([filebase '.xml'],[filebase_b '.xml']);% copy the .civ file 214 t=xmltree([filebase_b '.xml']); 215 211 %% update the xml file 212 SubDirBase=regexprep(Param.InputTable{1,2},'\..*','');%take the root part of SubDir, before the first dot '.' 213 filexml=fulfille(Param.InputTable{1,1},[SubDirBase '.xml']); 214 if ~exist(filexml,'file') && exist([filebase '.xml'],'file')% xml inside the image directory 215 copyfile([filebase '.xml'],filexml);% copy the .xml file 216 end 217 if exist(filexml,'file') 218 t=xmltree([filexml '.xml']); 216 219 %update information on the first image name in the series 217 220 uid_Heading=find(t,'ImaDoc/Heading'); … … 251 254 [t,LuminosityRank_uid]=add(t,new_uid,'element','RankBackground'); 252 255 [t]=add(t,LuminosityRank_uid,'chardata',num2str(rank));% luminosity rank almong the nbaver sliding images 253 save(t,[filebase_b '.xml']) 254 elseif exist([filebase '.civ'],'file') 255 copyfile([filebase '.civ'],[filebase_b '.civ']);% copy the .civ file 256 save(t,filexml) 256 257 end 257 258 %copy the mask 258 if exist([filebase '_1mask_1'],'file')259 copyfile([filebase '_1mask_1'],[filebase_b '_1mask_1']);% copy the mask file260 end259 % if exist([filebase '_1mask_1'],'file') 260 % copyfile([filebase '_1mask_1'],[filebase_b '_1mask_1']);% copy the mask file 261 % end 261 262 262 263 %MAIN LOOP ON SLICES 263 264 264 for islice=1:nbslice_i 265 265 %% select the series of image indices at the level islice … … 290 290 j1=j1_series{1}(ifile); 291 291 end 292 newname=fullfile_uvmat( [dir_images term],'',Param.InputTable{1,3},'.png',NomType,i1_series{1}(ifile),[],j1);292 newname=fullfile_uvmat(Param.InputTable{1,1},SubdirResult,Param.InputTable{1,3},'.png',NomType,i1_series{1}(ifile),[],j1); 293 293 %newname=name_generator(filebase_b,i1_series{1}(ifile),j1_series{1}(ifile),'.png',NomType);% makes the new file name 294 294 if test_level … … 304 304 if nbfield_slice > nbaver_ima 305 305 for ifield = step*ceil(nbaver/2)+1:step:nbfield_slice-step*floor(nbaver/2) 306 stopstate=get(hseries.RUN,'BusyAction');307 if isequal(stopstate,'queue')% enable STOP command306 if checkrun 307 stopstate=get(hseries.RUN,'BusyAction'); 308 308 update_waitbar(hseries.waitbar,WaitbarPos,(ifield+(islice-1)*nbfield_slice)/(nbfield_slice*nbslice_i)) 309 309 display((ifield+(islice-1)*nbfield_slice)/(nbfield_slice*nbslice_i)) 310 else 311 stopstate='queue'; 312 end 313 if isequal(stopstate,'queue')% enable STOP command 310 314 Ak(:,:,1:nbaver_ima-step)=Ak(:,:,1+step:nbaver_ima);% shift the current image series by one burst (step) 311 315 %incorporate next burst in the current image series 312 316 for iburst=1:step 313 317 ifile=indselect(ifield+step*floor(nbaver/2)+iburst-1); 314 filename=name_generator(filebase,num_i1(ifile),num_j1(ifile),FileExt,NomType); 318 filename=fullfile_uvmat(Param.InputTable{1,1},Subdir,Param.InputTable{1,3},FileExt,NomType,num_i1(ifile),[],num_j1(ifile)); 319 %filename=name_generator(filebase,num_i1(ifile),num_j1(ifile),FileExt,NomType); 315 320 Aread=read_image(filename,FileType,num_i1(ifile),MovieObject); 316 321 Ak(:,:,nbaver_ima-step+iburst)=Aread; … … 327 332 j1=j1_series{1}(ifile); 328 333 end 329 newname=fullfile_uvmat( [dir_images term],'',Param.InputTable{1,3},'.png',NomType,i1_series{1}(ifile),[],j1);334 newname=fullfile_uvmat(Param.InputTable{1,1},SubdirResult,Param.InputTable{1,3},'.png',NomType,i1_series{1}(ifile),[],j1); 330 335 %[newname]=name_generator(filebase_b,num_i1(ifile),num_j1(ifile),'.png',NomType) % makes the new file name 331 336 if test_level … … 354 359 j1=j1_series{1}(ifile); 355 360 end 356 newname=fullfile_uvmat([dir_images term],'',Param.InputTable{1,3},'.png',NomType,i1_series{1}(ifile),[],j1); 357 %newname=name_generator(filebase_b,num_i1(ifile),num_j1(ifile),'.png',NomType);% makes the new file name 361 newname=fullfile_uvmat(Param.InputTable{1,1},SubdirResult,Param.InputTable{1,3},'.png',NomType,i1_series{1}(ifile),[],j1); 358 362 if test_level 359 363 C=levels(C); … … 366 370 367 371 %finish the waitbar 368 update_waitbar(hseries.waitbar,WaitbarPos,1) 369 372 if checkrun 373 update_waitbar(hseries.waitbar,WaitbarPos,1) 374 end 370 375 371 376 %------------------------------------------------------------------------ -
trunk/src/series/time_series.m
r422 r442 37 37 if ischar(Param) && ~isempty(find(regexp('Param','.xml$'))) 38 38 Param=xml2struct(Param); 39 checkrun=0; 39 40 else % RUN case: parameters introduced as the input structure Param 40 41 hseries=guidata(Param.hseries);%handles of the GUI series 41 42 WaitbarPos=get(hseries.waitbar_frame,'Position'); 43 checkrun=1; 42 44 end 43 45 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); … … 273 275 filecounter=0; 274 276 for ifile=i_slice:NbSlice:nbfield 275 stopstate=get(hseries.RUN,'BusyAction'); 277 if checkrun 278 update_waitbar(hseries.waitbar_frame,WaitbarPos,ifile/nbfield) 279 stopstate=get(hseries.RUN,'BusyAction'); 280 else 281 stopstate='queue'; 282 end 276 283 errormsg=''; 277 284 if isequal(stopstate,'queue')% enable STOP command 278 update_waitbar(hseries.waitbar,WaitbarPos,ifile/nbfield) % update the waitbar279 285 % loop on views (in case of multiple input series) 280 286 for iview=1:nbview
Note: See TracChangeset
for help on using the changeset viewer.