Changeset 442 for trunk/src/series/sub_background.m
- Timestamp:
- Jun 6, 2012, 2:46:15 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 %------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.