Changeset 394


Ignore:
Timestamp:
Apr 24, 2012, 7:54:21 PM (13 years ago)
Author:
sommeria
Message:

bugs corrected in series fct taking into account new conventions

Location:
trunk/src/series
Files:
4 edited

Legend:

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

    r392 r394  
    5555if test_object%isfield(Series,'sethandles')
    5656    hset_object=findobj(allchild(0),'tag','set_object');
    57     %ProjObject=read_set_object(guidata(hset_object));
    5857    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']);
    6059    if ~isequal(answeryes,'Yes')
    6160        return
  • trunk/src/series/merge_proj.m

    r381 r394  
    5959            return
    6060    end
    61     if ~isequal(ProjObject.Style,'plane')|| isequal(ProjObject.ProjMode,'projection')
     61    if ~isequal(ProjObject.Type,'plane')|| isequal(ProjObject.ProjMode,'projection')
    6262            msgbox_uvmat('ERROR','The projection object must be a plane with projection mode interp or filter')
    6363            return
    6464    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]);
    6666    if ~isequal(answeryes,'Yes')
    6767        return
  • trunk/src/series/sub_background.m

    r374 r394  
    6565    WaitbarPos=get(hseries.waitbar_frame,'Position');
    6666end
     67filebase=fullfile(Param.InputTable{1,1},Param.InputTable{1,3});
     68dir_images=Param.InputTable{1,1};
     69NomType=Param.InputTable{1,4};
     70FileExt=Param.InputTable{1,5};
    6771[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
    6872if 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
     75end
     76
    7277%%% TODO: update with the new conventions%%%%%%%%%%%%%%%%%
    7378%% determine input image type
    7479FileType=[];%default
    7580MovieObject=[];
    76 FileExt=Series.FileExt;
     81%FileExt=Series.FileExt;
    7782
    7883if isequal(lower(FileExt),'.avi')
     
    8691elseif isequal(lower(FileExt),'.vol')
    8792    FileType='vol';
    88 else 
    89    form=imformats(FileExt(2:end));
    90    if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    91        if isequal(Series.NomType,'*');
    92            FileType='multimage';
    93        else
    94            FileType='image';
    95        end
    96    end
     93else
     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
    97102end
    98103if isempty(FileType)
     
    101106end
    102107
    103 nbslice_i=Series.NbSlice; %number of slices
    104 siz=size(num_i1);
     108nbslice_i=Param.NbSlice; %number of slices
     109siz=size(i1_series{1});
    105110nbaver_init=23;%approximate number of images used for the sliding background: to be adjusted later to include an integer number of bursts
    106 
     111j1=[];%default
    107112
    108113%% apply the image rescaling function 'level' (avoid the blinking effects of bright particles)
     
    112117%% adjust the proposed number of images in the sliding average to include an integer number of bursts
    113118if 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,
    115120    if isequal(floor(nbaver/2),nbaver)
    116121        nbaver=nbaver+1;%put the number of burst to an odd number (so the middle burst is defined)
     
    118123    nbaver_init=nbaver*siz(1);%propose by default an integer number of bursts
    119124end
    120 
    121 filebase=fullfile(Series.RootPath,Series.RootFile);
    122 dir_images=Series.RootPath;
    123 nom_type=Series.NomType;
    124125
    125126%% create dir of the new images
     
    130131    term='_b';
    131132end
    132 [pp,subdir_ima]=fileparts(Series.RootPath);
     133[pp,subdir_ima]=fileparts(Param.InputTable{1,1});
    133134try
    134135    mkdir([dir_images term]);
    135136catch ME
    136             msgbox_uvmat('ERROR',ME.message);
    137             return
     137    msgbox_uvmat('ERROR',ME.message);
     138    return
    138139end
    139140[xx,msg2] = fileattrib([dir_images term],'+w','g'); %yield writing access (+w) to user group (g)
     
    142143    return
    143144end
    144 filebase_b=fullfile([dir_images term],Series.RootFile);
     145filebase_b=fullfile([dir_images term],Param.InputTable{1,3});
    145146
    146147%% set processing parameters
    147148prompt = {'Number of images for the sliding background (MUST FIT IN COMPUETER MEMORY)';'The number of positions (laser slices)';'volume scan mode (Yes/No)';...
    148         'the luminosity rank chosen to define the background (0.1=for dense particle seeding, 0.5 (median) for sparse particles'};
     149    'the luminosity rank chosen to define the background (0.1=for dense particle seeding, 0.5 (median) for sparse particles'};
    149150dlg_title = ['get (slice by slice) a sliding background and substract to each image, result in subdir ' subdir_ima term];
    150151num_lines= 3;
     
    157158nbaver=ceil(nbaver_ima/siz(1));%number of bursts for the sliding background
    158159if 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)
     161end
     162step=siz(1);%case of bursts: the sliding background is shifted by one burst
    162163vol_test=answer{3};
    163164if isequal(vol_test,'Yes')
    164165    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
    166167else
    167168    nbfield2=siz(1); %nb of consecutive images at each level(burst)
    168169    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
    170172    else
    171173        nbslice_i=1;
     
    195197
    196198%% 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);
     201Afirst=read_image(filecell{1,1},FileType,i1_series{1}(1),MovieObject);
    199202[npy,npx]=size(Afirst);
    200 try 
    201 Ak=zeros(npy,npx,nbaver_ima,'uint16'); %prealocate memory
    202 Asort=zeros(npy,npx,nbaver_ima,'uint16'); %prealocate memory
     203try
     204    Ak=zeros(npy,npx,nbaver_ima,'uint16'); %prealocate memory
     205    Asort=zeros(npy,npx,nbaver_ima,'uint16'); %prealocate memory
    203206catch ME
    204207    msgbox_uvmat('ERROR',ME.message)
     
    215218    if isempty(uid_Heading)
    216219        [t,uid_Heading]=add(t,1,'element','Heading');
    217     end   
     220    end
    218221    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);
    220227    [pth,ImageName]=fileparts(ImageName);
    221228    ImageName=[ImageName '.png'];
    222229    if isempty(uid_ImageName)
    223        [t,uid_ImageName]=add(t,uid_Heading,'element','ImageName');
     230        [t,uid_ImageName]=add(t,uid_Heading,'element','ImageName');
    224231    end
    225232    uid_value=children(t,uid_ImageName);
     
    228235    else
    229236        t=set(t,uid_value(1),'value',ImageName);%indicate  name of the first image, with ;png extension
    230     end 
    231 
     237    end
     238   
    232239    %add information about image transform
    233240    [t,new_uid]=add(t,1,'element','ImageTransform');
    234241    [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');
    236243    if test_level
    237             [t,NameFunction_uid]=add(t,new_uid,'element','NameFunction');
    238             [t]=add(t,NameFunction_uid,'chardata','levels');
     244        [t,NameFunction_uid]=add(t,new_uid,'element','NameFunction');
     245        [t]=add(t,NameFunction_uid,'chardata','levels');
    239246    end
    240247    [t,NbSlice_uid]=add(t,new_uid,'element','NbSlice');
     
    243250    [t]=add(t,NbSlidingImages_uid,'chardata',num2str(nbaver));
    244251    [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
    246253    save(t,[filebase_b '.xml'])
    247254elseif exist([filebase '.civ'],'file')
     
    250257%copy the mask
    251258if exist([filebase '_1mask_1'],'file')
    252      copyfile([filebase '_1mask_1'],[filebase_b '_1mask_1']);% copy the mask file
     259    copyfile([filebase '_1mask_1'],[filebase_b '_1mask_1']);% copy the mask file
    253260end
    254261
     
    261268            indselect(iburst,ifield)=((ifield-1)*nbslice_i+(islice-1))*nbfield2+iburst;
    262269        end
    263     end 
     270    end
    264271   
    265272    %% read the first series of nbaver_ima images and sort by luminosity at each pixel
    266273    for ifield = 1:nbaver_ima
    267274        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;
    271279    end
    272280    Asort=sort(Ak,3);%sort the luminosity of images at each point
    273281    B=Asort(:,:,rank);%background image
    274    display( 'first background image will be substracted')
     282    display( 'first background image will be substracted')
    275283    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
    287300    end
    288301   
     
    299312                for iburst=1:step
    300313                    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);
    302315                    Aread=read_image(filename,FileType,num_i1(ifile),MovieObject);
    303316                    Ak(:,:,nbaver_ima-step+iburst)=Aread;
     
    311324                    C=uint16(Acor);
    312325                    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
    315331                    if test_level
    316332                        C=levels(C);
     
    325341        end
    326342    end
    327 
    328 %% substract the background from the last images
     343   
     344    %% substract the background from the last images
    329345    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
    345365end
    346366
  • trunk/src/series/time_series.m

    r392 r394  
    5353if test_object
    5454    hset_object=findobj(allchild(0),'tag','set_object');
    55 %     ProjObject=read_set_object(guidata(hset_object));
    5655    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]);
    5857    if ~isequal(answeryes,'Yes')
    5958        return
     
    6564
    6665%% features of the input fields
    67     RootPath=Param.InputTable(:,1);
    68     RootFile=Param.InputTable(:,3);
    69     SubDir=Param.InputTable(:,2);
    70     NomType=Param.InputTable(:,4);
    71     FileExt=Param.InputTable(:,5);
    72 ext=FileExt{1};
    73 form=imformats(ext(2:end));%test valid Matlab image formats
     66RootPath=Param.InputTable(:,1);
     67RootFile=Param.InputTable(:,3);
     68% SubDir=Param.InputTable(:,2);
     69NomType=Param.InputTable(:,4);
     70FileExt=Param.InputTable(:,5);
     71% ext=FileExt{1};
     72% form=imformats(ext(2:end));%test valid Matlab image formats
    7473nbfield=size(i1_series{1},1)*size(i1_series{1},2); %number of fields in the time series
    7574
Note: See TracChangeset for help on using the changeset viewer.