Changeset 951 for trunk/src


Ignore:
Timestamp:
Jun 12, 2016, 5:09:47 PM (8 years ago)
Author:
sommeria
Message:

bugs repaired

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series.m

    r950 r951  
    990990        Time=XmlData.Time;
    991991        TimeName='xml';
    992                         if XmlData.Time(1,:)==XmlData.Time(2,:)% case starting with index 1
    993                     sizDti=size(XmlData.Time,1)-1;%size of the time vector explicitly defined in the xml file
    994                     ind_start=1;
    995                 else
    996                     sizDti=size(XmlData.Time,1);% case starting with index 0
    997                     ind_start=0;
    998                 end
    999         % complement the input if the whole time series is not defined
    1000             if size(i1_series,3)>size(XmlData.Time,1)-ind_start %only the first time interval is defined, extrapolate to the whole series
    1001                 Dti_total=XmlData.Time(end)-XmlData.Time(1);%total time interval covered by the time vector
    1002                 missing_indices=sizDti+1+ind_start:size(i1_series,3)+1;% remaining set of frame indices for which time needs to be found
    1003                 repeat_nbre=1+floor((missing_indices-sizDti-ind_start)/(sizDti-1));% number of repetitions of Dti
    1004                 time_indices=1+mod(missing_indices-sizDti-1,sizDti-1);
    1005                 for j=1:size(XmlData.Time,2)
    1006                 Time(missing_indices,j)=XmlData.Time(time_indices,j)+repeat_nbre'*Dti_total;
    1007                 end
    1008                 % update the xml file with NbDti
    1009                 t=xmltree(XmlFileName);
    1010                 uid_NbDti=find(t,'ImaDoc/Camera/BurstTiming/NbDti')
    1011                 if isempty(uid_NbDti)
    1012                     uid_BurstTiming=find(t,'ImaDoc/Camera/BurstTiming')
    1013                     [t,uid_NbDti]=add(t,uid_BurstTiming,'element','NbDti');
    1014                 end
    1015                 [t,uid_NbDti]=add(t,uid_NbDti,'chardata',num2str(repeat_nbre(end)-1));
    1016                 save(t,XmlFileName)
    1017             end
     992%                         if XmlData.Time(1,:)==XmlData.Time(2,:)% case starting with index 1
     993%                     sizDti=size(XmlData.Time,1)-1;%size of the time vector explicitly defined in the xml file
     994%                     ind_start=1;
     995%                 else
     996%                     sizDti=size(XmlData.Time,1);% case starting with index 0
     997%                     ind_start=0;
     998%                 end
     999%         % complement the input if the whole time series is not defined
     1000%             if size(i1_series,3)>size(XmlData.Time,1)-ind_start %only the first time interval is defined, extrapolate to the whole series
     1001%                 Dti_total=XmlData.Time(end)-XmlData.Time(1);%total time interval covered by the time vector
     1002%                 missing_indices=sizDti+1+ind_start:size(i1_series,3)+1;% remaining set of frame indices for which time needs to be found
     1003%                 repeat_nbre=1+floor((missing_indices-sizDti-ind_start)/(sizDti-1));% number of repetitions of Dti
     1004%                 time_indices=1+mod(missing_indices-sizDti-1,sizDti-1);
     1005%                 for j=1:size(XmlData.Time,2)
     1006%                 Time(missing_indices,j)=XmlData.Time(time_indices,j)+repeat_nbre'*Dti_total;
     1007%                 end
     1008%                 % update the xml file with NbDti
     1009%                 t=xmltree(XmlFileName);
     1010%                 uid_NbDti=find(t,'ImaDoc/Camera/BurstTiming/NbDti')
     1011%                 if isempty(uid_NbDti)
     1012%                     uid_BurstTiming=find(t,'ImaDoc/Camera/BurstTiming')
     1013%                     [t,uid_NbDti]=add(t,uid_BurstTiming,'element','NbDti');
     1014%                 end
     1015%                 [t,uid_NbDti]=add(t,uid_NbDti,'chardata',num2str(repeat_nbre(end)-1));
     1016%                 save(t,XmlFileName)
     1017%             end
    10181018    end
    10191019    if isfield(XmlData,'Camera')
  • trunk/src/series/civ_input.m

    r932 r951  
    9797FileType='image';%fdefault
    9898FileInfo=[];
    99 if isfield(SeriesData,'FileType')&&isfield(SeriesData,'FileInfo')
     99if isfield(SeriesData,'FileType')&&isfield(SeriesData,'FileInfo')...
     100        &&numel(SeriesData.FileType)>=1&&numel(SeriesData.FileInfo)>=1
    100101    FileType=SeriesData.FileType{1};%type of the first input file series
    101102    FileInfo=SeriesData.FileInfo{1};% info on the first input file series
     
    214215CoordUnit='';%default
    215216pxcm_search=1;
    216 if isfield(SeriesData,'Time') && ~isempty(SeriesData.Time{1})
     217if isfield(SeriesData,'Time') &&numel(SeriesData.Time')>=1 && ~isempty(SeriesData.Time{1})
    217218    time=SeriesData.Time{1};
    218219end
  • trunk/src/series/sub_background.m

    r950 r951  
    150150    end
    151151   
    152     prompt = {'volume scan mode (Yes/No)';'Number of images for the sliding background (MUST FIT IN COMPUTER MEMORY)';...
    153         'the luminosity rank chosen to define the background (0.1=for dense particle seeding, 0.5 (median) for sparse particles'};
     152    prompt = {'volume scan mode (Yes/No)';...
     153        'Number of images for the sliding background (MUST FIT IN COMPUTER MEMORY)';...
     154        'the luminosity rank chosen to define the background (0.1=for dense particle seeding, 0.5 (median) for sparse particles';...
     155        'set to 0 image levels below median(Yes/No)';...
     156        'image rescaling coefficient(high values reduce the influence of bright particles), =0 for no rescaling' };
    154157    dlg_title = 'get (slice by slice) a sliding background and substract to each image';
    155     num_lines= 3;
    156     def     = { 'No';num2str(nbaver_init);'0.1'};
     158    num_lines= 5;
     159    def     = { 'No';num2str(nbaver_init);'0.1';'No';'2'};
    157160    answer = inputdlg(prompt,dlg_title,num_lines,def);
    158161    if isempty(answer)
     
    181184    ParamOut.ActionInput.SlidingSequenceLength=nbaver_ima;
    182185    ParamOut.ActionInput.BrightnessRankThreshold=str2double(answer{3});
    183    
     186    ParamOut.ActionInput.CheckSubmedian=strcmp(answer{4},'Yes');
     187    ParamOut.ActionInput.SaturationCoeff=str2double(answer{5});
    184188    % apply the image rescaling function 'level' (avoid the blinking effects of bright particles)
    185     answer=msgbox_uvmat('INPUT_Y-N','apply image rescaling function levels.m after sub_background');
    186     ParamOut.ActionInput.CheckLevelTransform=strcmp(answer,'Yes');
     189%     answer=msgbox_uvmat('INPUT_Y-N','apply image rescaling function levels.m after sub_background');
     190%     ParamOut.ActionInput.CheckLevelTransform=strcmp(answer,'Yes');
    187191    return
    188192end
     
    233237
    234238%% output file naming
    235 FileExtOut='.png'; % write result as .png images for image inputs
    236 if strcmp(lower(NomType{1}(end)),'a')
    237     NomTypeOut=NomType{1};%case of letter appendix
     239FileExtOut='.png'; % write result as .png images for image inputsFileInfo.FileType='image'
     240if strcmp(FileInfo{1}.FileType,'image')
     241    NomTypeOut=NomType{1};
     242% if strcmp(lower(NomType{1}(end)),'a')
     243%     NomTypeOut=NomType{1};%case of letter appendix
    238244elseif isempty(j1_series{1})
    239245    NomTypeOut='_1';
     
    338344       
    339345        %write result file
    340         if Param.ActionInput.CheckLevelTransform
    341             C=levels(Acor);
     346        if ~isequal(Param.ActionInput.SaturationCoeff,0)
     347            C=levels(Acor,Param.ActionInput.CheckSubmedian,Param.ActionInput.SaturationCoeff);
    342348            imwrite(C,newname,'BitDepth',16); % save the new image
    343349        else
     
    391397                newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);
    392398                %write result file
    393                 if Param.ActionInput.CheckLevelTransform
    394                     C=levels(Acor);
     399                if ~isequal(Param.ActionInput.SaturationCoeff,0)
     400                    C=levels(Acor,Param.ActionInput.CheckSubmedian,Param.ActionInput.SaturationCoeff);
    395401                    imwrite(C,newname,'BitDepth',16); % save the new image
    396402                else
     
    419425        newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);
    420426        %write result file
    421         if Param.ActionInput.CheckLevelTransform
    422             C=levels(Acor);
     427        if ~isequal(Param.ActionInput.SaturationCoeff,0)
     428            C=levels(Acor,Param.ActionInput.CheckSubmedian,Param.ActionInput.SaturationCoeff);
    423429            imwrite(C,newname,'BitDepth',16); % save the new image
    424430        else
     
    435441end
    436442
    437 function C=levels(A)
     443function C=levels(A,CheckSubmedian,Coeff)
    438444
    439445nblock_y=100;%2*Param.TransformInput.BlockSize;
     
    446452%Amin=A.*Aflagmin;%values of A at local minima
    447453% local background: find all the local minima in image subblocks
    448 fctblock= inline('median(x(:))');
    449 Backg=blkproc(A,[nblock_y nblock_x],fctblock);% take the median in  blocks
     454if CheckSubmedian
     455    fctblock= inline('median(x(:))');
     456    Backg=blkproc(A,[nblock_y nblock_x],fctblock);% take the median in  blocks
     457    %B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image
     458    A=A-imresize(Backg,size(A),'bilinear');% substract background interpolated to the initial size image
     459end
    450460fctblock= inline('mean(x(:))');
    451 B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image
    452 A=(A-B);%substract background
    453461AMean=blkproc(A,[nblock_y nblock_x],fctblock);% take the mean in  blocks
    454462fctblock= inline('var(x(:))');
    455463AVar=blkproc(A,[nblock_y nblock_x],fctblock);% take the mean in  blocks
    456 Avalue=AVar./AMean% typical value of particle luminosity
     464Avalue=AVar./AMean;% typical value of particle luminosity
    457465Avalue=imresize(Avalue,size(A),'bilinear');% interpolate to the initial size image
    458 C=uint16(1000*tanh(A./(2*Avalue)));
    459 %Bmin=blkproc(Aflagmin,[nblock_y nblock_x],sumblock);% find the number of minima in blocks
    460 %Backg=Backg./Bmin; % find the average of minima in blocks
    461 % function C=levels(A)
    462 % %whos A;
    463 % B=double(A(:,:,1));
    464 % windowsize=round(min(size(B,1),size(B,2))/20);
    465 % windowsize=floor(windowsize/2)*2+1;
    466 % ix=1/2-windowsize/2:-1/2+windowsize/2;%
    467 % %del=np/3;
    468 % %fct=exp(-(ix/del).^2);
    469 % fct2=cos(ix/(windowsize-1)/2*pi/2);
    470 % %Mfiltre=(ones(5,5)/5^2);
    471 % %Mfiltre=fct2';
    472 % Mfiltre=fct2'*fct2;
    473 % Mfiltre=Mfiltre/(sum(sum(Mfiltre)));
    474 %
    475 % C=filter2(Mfiltre,B);
    476 % C(:,1:windowsize)=C(:,windowsize)*ones(1,windowsize);
    477 % C(:,end-windowsize+1:end)=C(:,end-windowsize+1)*ones(1,windowsize);
    478 % C(1:windowsize,:)=ones(windowsize,1)*C(windowsize,:);
    479 % C(end-windowsize+1:end,:)=ones(windowsize,1)*C(end-windowsize,:);
    480 % C=tanh(B./(2*C));
    481 % [n,c]=hist(reshape(C,1,[]),100);
    482 % % figure;plot(c,n);
    483 %
    484 % [m,i]=max(n);
    485 % c_max=c(i);
    486 % [dummy,index]=sort(abs(c-c(i)));
    487 % n=n(index);
    488 % c=c(index);
    489 % i_select = find(cumsum(n)<0.95*sum(n));
    490 % if isempty(i_select)
    491 %     i_select = 1:length(c);
    492 % end
    493 % c_select=c(i_select);
    494 % n_select=n(i_select);
    495 % cmin=min(c_select);
    496 % cmax=max(c_select);
    497 % C=(C-cmin)/(cmax-cmin)*256;
    498 % C=uint8(C);
     466C=uint16(1000*tanh(A./(Coeff*Avalue)));
  • trunk/src/uvmat.m

    r950 r951  
    20392039        end
    20402040            % complement the input if the whole time series is not defined
    2041             if size(i1_series,3)>size(XmlDataRead.Time,1)-ind_start %only the first time interval is defined, extrapolate to the whole series           
    2042                 Dti_total=XmlDataRead.Time(end)-XmlDataRead.Time(1);%total time interval covered by the time vector
    2043                 missing_indices=sizDti+1+ind_start:size(i1_series,3)+1;% remaining set of frame indices for which time needs to be found
    2044                 repeat_nbre=1+floor((missing_indices-sizDti-ind_start)/(sizDti-1));% number of repetitions of Dti
    2045                 time_indices=1+mod(missing_indices-sizDti-1,sizDti-1);
    2046                 for j=1:size(XmlDataRead.Time,2)
    2047                     XmlData.Time(missing_indices,j)=XmlDataRead.Time(time_indices,j)+repeat_nbre'*Dti_total;
    2048                 end
    2049                 % update the xml file with NbDti
    2050                 t=xmltree(XmlFileName);
    2051                 uid_NbDti=find(t,'ImaDoc/Camera/BurstTiming/NbDti')
    2052                 if isempty(uid_NbDti)
    2053                     uid_BurstTiming=find(t,'ImaDoc/Camera/BurstTiming')
    2054                     [t,uid_NbDti]=add(t,uid_BurstTiming,'element','NbDti');
    2055                 end
    2056                 [t,uid_NbDti]=add(t,uid_NbDti,'chardata',num2str(repeat_nbre(end)-1));
    2057                 save(t,XmlFileName)
    2058             end
     2041%             if size(i1_series,3)>size(XmlDataRead.Time,1)-ind_start %only the first time interval is defined, extrapolate to the whole series           
     2042%                 Dti_total=XmlDataRead.Time(end)-XmlDataRead.Time(1);%total time interval covered by the time vector
     2043%                 missing_indices=sizDti+1+ind_start:size(i1_series,3)+1;% remaining set of frame indices for which time needs to be found
     2044%                 repeat_nbre=1+floor((missing_indices-sizDti-ind_start)/(sizDti-1));% number of repetitions of Dti
     2045%                 time_indices=1+mod(missing_indices-sizDti-1,sizDti-1);
     2046%                 for j=1:size(XmlDataRead.Time,2)
     2047%                     XmlData.Time(missing_indices,j)=XmlDataRead.Time(time_indices,j)+repeat_nbre'*Dti_total;
     2048%                 end
     2049%                 % update the xml file with NbDti
     2050%                 t=xmltree(XmlFileName);
     2051%                 uid_NbDti=find(t,'ImaDoc/Camera/BurstTiming/NbDti')
     2052%                 if isempty(uid_NbDti)
     2053%                     uid_BurstTiming=find(t,'ImaDoc/Camera/BurstTiming')
     2054%                     [t,uid_NbDti]=add(t,uid_BurstTiming,'element','NbDti');
     2055%                 end
     2056%                 [t,uid_NbDti]=add(t,uid_NbDti,'chardata',num2str(repeat_nbre(end)-1));
     2057%                 save(t,XmlFileName)
     2058%             end
    20592059        end
    20602060        set(handles.view_xml,'BackgroundColor',[1 1 1])% paint back to white
Note: See TracChangeset for help on using the changeset viewer.