Changeset 394
- Timestamp:
- Apr 24, 2012, 7:54:21 PM (13 years ago)
- Location:
- trunk/src/series
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/aver_stat.m
r392 r394 55 55 if test_object%isfield(Series,'sethandles') 56 56 hset_object=findobj(allchild(0),'tag','set_object'); 57 %ProjObject=read_set_object(guidata(hset_object));58 57 ProjObject=read_GUI(hset_object); 59 answeryes=msgbox_uvmat('INPUT_Y-N',['field series projected on ' ProjObject. Style ' before averaging']);58 answeryes=msgbox_uvmat('INPUT_Y-N',['field series projected on ' ProjObject.Type ' before averaging']); 60 59 if ~isequal(answeryes,'Yes') 61 60 return -
trunk/src/series/merge_proj.m
r381 r394 59 59 return 60 60 end 61 if ~isequal(ProjObject. Style,'plane')|| isequal(ProjObject.ProjMode,'projection')61 if ~isequal(ProjObject.Type,'plane')|| isequal(ProjObject.ProjMode,'projection') 62 62 msgbox_uvmat('ERROR','The projection object must be a plane with projection mode interp or filter') 63 63 return 64 64 end 65 answeryes=msgbox_uvmat('INPUT_Y-N',['field series projected on ' ProjObject. Style]);65 answeryes=msgbox_uvmat('INPUT_Y-N',['field series projected on ' ProjObject.Type]); 66 66 if ~isequal(answeryes,'Yes') 67 67 return -
trunk/src/series/sub_background.m
r374 r394 65 65 WaitbarPos=get(hseries.waitbar_frame,'Position'); 66 66 end 67 filebase=fullfile(Param.InputTable{1,1},Param.InputTable{1,3}); 68 dir_images=Param.InputTable{1,1}; 69 NomType=Param.InputTable{1,4}; 70 FileExt=Param.InputTable{1,5}; 67 71 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 68 72 if size(filecell,1)>1 69 msgbox_uvmat('ERROR','This function use only one input image series') 70 return 71 end 73 msgbox_uvmat('WARNING','This function uses only the first input image series') 74 return 75 end 76 72 77 %%% TODO: update with the new conventions%%%%%%%%%%%%%%%%% 73 78 %% determine input image type 74 79 FileType=[];%default 75 80 MovieObject=[]; 76 FileExt=Series.FileExt;81 %FileExt=Series.FileExt; 77 82 78 83 if isequal(lower(FileExt),'.avi') … … 86 91 elseif isequal(lower(FileExt),'.vol') 87 92 FileType='vol'; 88 else 89 form=imformats(FileExt(2:end));90 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab91 if isequal(Series.NomType,'*');92 FileType='multimage';93 else94 FileType='image';95 end96 end93 else 94 form=imformats(FileExt(2:end)); 95 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 96 if isequal(NomType,'*'); 97 FileType='multimage'; 98 else 99 FileType='image'; 100 end 101 end 97 102 end 98 103 if isempty(FileType) … … 101 106 end 102 107 103 nbslice_i= Series.NbSlice; %number of slices104 siz=size( num_i1);108 nbslice_i=Param.NbSlice; %number of slices 109 siz=size(i1_series{1}); 105 110 nbaver_init=23;%approximate number of images used for the sliding background: to be adjusted later to include an integer number of bursts 106 111 j1=[];%default 107 112 108 113 %% apply the image rescaling function 'level' (avoid the blinking effects of bright particles) … … 112 117 %% adjust the proposed number of images in the sliding average to include an integer number of bursts 113 118 if siz(2)~=1 114 nbaver=floor(nbaver_init/siz(1)); % number of bursts used for the sliding background, 119 nbaver=floor(nbaver_init/siz(1)); % number of bursts used for the sliding background, 115 120 if isequal(floor(nbaver/2),nbaver) 116 121 nbaver=nbaver+1;%put the number of burst to an odd number (so the middle burst is defined) … … 118 123 nbaver_init=nbaver*siz(1);%propose by default an integer number of bursts 119 124 end 120 121 filebase=fullfile(Series.RootPath,Series.RootFile);122 dir_images=Series.RootPath;123 nom_type=Series.NomType;124 125 125 126 %% create dir of the new images … … 130 131 term='_b'; 131 132 end 132 [pp,subdir_ima]=fileparts( Series.RootPath);133 [pp,subdir_ima]=fileparts(Param.InputTable{1,1}); 133 134 try 134 135 mkdir([dir_images term]); 135 136 catch ME 136 137 137 msgbox_uvmat('ERROR',ME.message); 138 return 138 139 end 139 140 [xx,msg2] = fileattrib([dir_images term],'+w','g'); %yield writing access (+w) to user group (g) … … 142 143 return 143 144 end 144 filebase_b=fullfile([dir_images term], Series.RootFile);145 filebase_b=fullfile([dir_images term],Param.InputTable{1,3}); 145 146 146 147 %% set processing parameters 147 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)';... 148 149 'the luminosity rank chosen to define the background (0.1=for dense particle seeding, 0.5 (median) for sparse particles'}; 149 150 dlg_title = ['get (slice by slice) a sliding background and substract to each image, result in subdir ' subdir_ima term]; 150 151 num_lines= 3; … … 157 158 nbaver=ceil(nbaver_ima/siz(1));%number of bursts for the sliding background 158 159 if isequal(floor(nbaver/2),nbaver) 159 nbaver=nbaver+1;%put the number of burst to an odd number (so the middle burst is defined)160 end 161 step=siz(1);%case of bursts: the sliding background is shifted by one burst 160 nbaver=nbaver+1;%put the number of burst to an odd number (so the middle burst is defined) 161 end 162 step=siz(1);%case of bursts: the sliding background is shifted by one burst 162 163 vol_test=answer{3}; 163 164 if isequal(vol_test,'Yes') 164 165 nbfield2=1;%case of volume: no consecutive series at a given level 165 nbslice_i=siz(1);%number of slices 166 nbslice_i=siz(1);%number of slices 166 167 else 167 168 nbfield2=siz(1); %nb of consecutive images at each level(burst) 168 169 if siz(2)>1 169 nbslice_i=str2num(answer{2})/(num_i1(1,2)-num_i1(1,1));% number of slices 170 % nbslice_i=str2num(answer{2})/(num_i1(1,2)-num_i1(1,1));% number of slices 171 nbslice_i=str2num(answer{2})/(i1_series{1}(1,2)-i1_series{1}(1,1));% number of slices 170 172 else 171 173 nbslice_i=1; … … 195 197 196 198 %% prealocate memory for the sliding background 197 first_image=name_generator(filebase,num_i1(1),num_j1(1),Series.FileExt,Series.NomType); 198 Afirst=read_image(first_image,FileType,num_i1(1),MovieObject); 199 % first_image=name_generator(filebase,num_i1(1),num_j1(1),FileExt,NomType); 200 % Afirst=read_image(first_image,FileType,num_i1(1),MovieObject); 201 Afirst=read_image(filecell{1,1},FileType,i1_series{1}(1),MovieObject); 199 202 [npy,npx]=size(Afirst); 200 try 201 Ak=zeros(npy,npx,nbaver_ima,'uint16'); %prealocate memory202 Asort=zeros(npy,npx,nbaver_ima,'uint16'); %prealocate memory203 try 204 Ak=zeros(npy,npx,nbaver_ima,'uint16'); %prealocate memory 205 Asort=zeros(npy,npx,nbaver_ima,'uint16'); %prealocate memory 203 206 catch ME 204 207 msgbox_uvmat('ERROR',ME.message) … … 215 218 if isempty(uid_Heading) 216 219 [t,uid_Heading]=add(t,1,'element','Heading'); 217 end 220 end 218 221 uid_ImageName=find(t,'ImaDoc/Heading/ImageName'); 219 ImageName=name_generator(filebase_b,num_i1(1),num_j1(1),'.png',Series.NomType); 222 if ~isempty(j1_series{1}) 223 j1=j1_series{1}(1); 224 end 225 ImageName=fullfile_uvmat([dir_images term],'',Param.InputTable{1,3},'.png',NomType,i1_series{1}(1),[],j1); 226 % ImageName=name_generator(filebase_b,num_i1(1),num_j1(1),'.png',NomType); 220 227 [pth,ImageName]=fileparts(ImageName); 221 228 ImageName=[ImageName '.png']; 222 229 if isempty(uid_ImageName) 223 [t,uid_ImageName]=add(t,uid_Heading,'element','ImageName');230 [t,uid_ImageName]=add(t,uid_Heading,'element','ImageName'); 224 231 end 225 232 uid_value=children(t,uid_ImageName); … … 228 235 else 229 236 t=set(t,uid_value(1),'value',ImageName);%indicate name of the first image, with ;png extension 230 end 231 237 end 238 232 239 %add information about image transform 233 240 [t,new_uid]=add(t,1,'element','ImageTransform'); 234 241 [t,NameFunction_uid]=add(t,new_uid,'element','NameFunction'); 235 [t]=add(t,NameFunction_uid,'chardata','sub_background'); 242 [t]=add(t,NameFunction_uid,'chardata','sub_background'); 236 243 if test_level 237 238 244 [t,NameFunction_uid]=add(t,new_uid,'element','NameFunction'); 245 [t]=add(t,NameFunction_uid,'chardata','levels'); 239 246 end 240 247 [t,NbSlice_uid]=add(t,new_uid,'element','NbSlice'); … … 243 250 [t]=add(t,NbSlidingImages_uid,'chardata',num2str(nbaver)); 244 251 [t,LuminosityRank_uid]=add(t,new_uid,'element','RankBackground'); 245 [t]=add(t,LuminosityRank_uid,'chardata',num2str(rank));% luminosity rank almong the nbaver sliding images 252 [t]=add(t,LuminosityRank_uid,'chardata',num2str(rank));% luminosity rank almong the nbaver sliding images 246 253 save(t,[filebase_b '.xml']) 247 254 elseif exist([filebase '.civ'],'file') … … 250 257 %copy the mask 251 258 if exist([filebase '_1mask_1'],'file') 252 259 copyfile([filebase '_1mask_1'],[filebase_b '_1mask_1']);% copy the mask file 253 260 end 254 261 … … 261 268 indselect(iburst,ifield)=((ifield-1)*nbslice_i+(islice-1))*nbfield2+iburst; 262 269 end 263 end 270 end 264 271 265 272 %% read the first series of nbaver_ima images and sort by luminosity at each pixel 266 273 for ifield = 1:nbaver_ima 267 274 ifile=indselect(ifield); 268 filename=name_generator(filebase,num_i1(ifile),num_j1(ifile),Series.FileExt,Series.NomType); 269 Aread=read_image(filename,FileType,num_i1(ifile),MovieObject); 270 Ak(:,:,ifield)=Aread; 275 filename=filecell{1,ifile}; 276 % filename=name_generator(filebase,num_i1(ifile),num_j1(ifile),FileExt,NomType); 277 Aread=read_image(filename,FileType,i1_series{1}(ifile),MovieObject); 278 Ak(:,:,ifield)=Aread; 271 279 end 272 280 Asort=sort(Ak,3);%sort the luminosity of images at each point 273 281 B=Asort(:,:,rank);%background image 274 display( 'first background image will be substracted')282 display( 'first background image will be substracted') 275 283 for ifield=1:nbfirst 276 Acor=double(Ak(:,:,ifield))-double(B);%substract background to the current image 277 Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor 278 C=uint16(Acor);% set to integer 16 bits 279 ifile=indselect(ifield); 280 newname=name_generator(filebase_b,num_i1(ifile),num_j1(ifile),'.png',nom_type)% makes the new file name 281 if test_level 282 C=levels(C); 283 imwrite(C,newname,'BitDepth',8); % save the new image 284 else 285 imwrite(C,newname,'BitDepth',16); % save the new image 286 end 284 Acor=double(Ak(:,:,ifield))-double(B);%substract background to the current image 285 Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor 286 C=uint16(Acor);% set to integer 16 bits 287 ifile=indselect(ifield); 288 % newname=name_generator(filebase_b,num_i1(ifile),num_j1(ifile),'.png',NomType)% makes the new file name 289 if ~isempty(j1_series{1}) 290 j1=j1_series{1}(ifile); 291 end 292 newname=fullfile_uvmat([dir_images term],'',Param.InputTable{1,3},'.png',NomType,i1_series{1}(ifile),[],j1); 293 %newname=name_generator(filebase_b,i1_series{1}(ifile),j1_series{1}(ifile),'.png',NomType);% makes the new file name 294 if test_level 295 C=levels(C); 296 imwrite(C,newname,'BitDepth',8); % save the new image 297 else 298 imwrite(C,newname,'BitDepth',16); % save the new image 299 end 287 300 end 288 301 … … 299 312 for iburst=1:step 300 313 ifile=indselect(ifield+step*floor(nbaver/2)+iburst-1); 301 filename=name_generator(filebase,num_i1(ifile),num_j1(ifile), Series.FileExt,Series.NomType);314 filename=name_generator(filebase,num_i1(ifile),num_j1(ifile),FileExt,NomType); 302 315 Aread=read_image(filename,FileType,num_i1(ifile),MovieObject); 303 316 Ak(:,:,nbaver_ima-step+iburst)=Aread; … … 311 324 C=uint16(Acor); 312 325 ifile=indselect(ifield+iburst-1); 313 [newname]=... 314 name_generator(filebase_b,num_i1(ifile),num_j1(ifile),'.png',Series.NomType) % makes the new file name 326 if ~isempty(j1_series{1}) 327 j1=j1_series{1}(ifile); 328 end 329 newname=fullfile_uvmat([dir_images term],'',Param.InputTable{1,3},'.png',NomType,i1_series{1}(ifile),[],j1); 330 %[newname]=name_generator(filebase_b,num_i1(ifile),num_j1(ifile),'.png',NomType) % makes the new file name 315 331 if test_level 316 332 C=levels(C); … … 325 341 end 326 342 end 327 328 %% substract the background from the last images343 344 %% substract the background from the last images 329 345 display('last background image will be substracted') 330 ifield=nbfield_slice-(step*ceil(nbaver/2))+1:nbfield_slice; 331 for ifield=nbfield_slice-(step*floor(nbaver/2))+1:nbfield_slice 332 index=ifield-nbfield_slice+step*(2*floor(nbaver/2)+1); 333 Acor=double(Ak(:,:,index))-double(B); 334 Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor 335 C=uint16(Acor); 336 ifile=indselect(ifield); 337 newname=name_generator(filebase_b,num_i1(ifile),num_j1(ifile),'.png',nom_type)% makes the new file name 338 if test_level 339 C=levels(C); 340 imwrite(C,newname,'BitDepth',8); % save the new image 341 else 342 imwrite(C,newname,'BitDepth',16); % save the new image 343 end 344 end 346 ifield=nbfield_slice-(step*ceil(nbaver/2))+1:nbfield_slice; 347 for ifield=nbfield_slice-(step*floor(nbaver/2))+1:nbfield_slice 348 index=ifield-nbfield_slice+step*(2*floor(nbaver/2)+1); 349 Acor=double(Ak(:,:,index))-double(B); 350 Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor 351 C=uint16(Acor); 352 ifile=indselect(ifield); 353 if ~isempty(j1_series{1}) 354 j1=j1_series{1}(ifile); 355 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 358 if test_level 359 C=levels(C); 360 imwrite(C,newname,'BitDepth',8); % save the new image 361 else 362 imwrite(C,newname,'BitDepth',16); % save the new image 363 end 364 end 345 365 end 346 366 -
trunk/src/series/time_series.m
r392 r394 53 53 if test_object 54 54 hset_object=findobj(allchild(0),'tag','set_object'); 55 % ProjObject=read_set_object(guidata(hset_object));56 55 ProjObject=read_GUI(hset_object); 57 answeryes=msgbox_uvmat('INPUT_Y-N',['field series projected on ' ProjObject. Style]);56 answeryes=msgbox_uvmat('INPUT_Y-N',['field series projected on ' ProjObject.Type]); 58 57 if ~isequal(answeryes,'Yes') 59 58 return … … 65 64 66 65 %% features of the input fields 67 68 69 70 71 72 ext=FileExt{1};73 form=imformats(ext(2:end));%test valid Matlab image formats66 RootPath=Param.InputTable(:,1); 67 RootFile=Param.InputTable(:,3); 68 % SubDir=Param.InputTable(:,2); 69 NomType=Param.InputTable(:,4); 70 FileExt=Param.InputTable(:,5); 71 % ext=FileExt{1}; 72 % form=imformats(ext(2:end));%test valid Matlab image formats 74 73 nbfield=size(i1_series{1},1)*size(i1_series{1},2); %number of fields in the time series 75 74
Note: See TracChangeset
for help on using the changeset viewer.