Changeset 906 for trunk/src


Ignore:
Timestamp:
May 31, 2015, 7:49:31 PM (9 years ago)
Author:
sommeria
Message:

various bgu repairs and ima_remove_partices and ima_remove_background updated

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series.m

    r905 r906  
    17191719end
    17201720CPUTime=5;% job time estimated at 5 min per iteration (on index i and j) by default
    1721 if isfield(Param, 'CPUTime') && ~isempty(Param.CPUTime)
    1722     CPUTime=Param.CPUTime;%Note: CpUTime for one iteration ref_i has to be multiplied by the number of j indices nbfield_j
     1721if isfield(Param.Action, 'CPUTime') && ~isempty(Param.Action.CPUTime)
     1722    CPUTime=Param.Action.CPUTime;%Note: CpUTime for one iteration ref_i has to be multiplied by the number of j indices nbfield_j
    17231723end
    17241724nbfield_j=numel(ref_j); % number of j indices
     
    18531853        t=set(t,1,'name','Series');
    18541854        filexml=fullfile_uvmat(DirXml,'',Param.InputTable{1,3},'.xml',OutputNomType,...
    1855             Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j)
     1855            Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j);
    18561856        save(t,filexml);% save the parameter file
    18571857       
     
    19391939%         end
    19401940        filename_joblist=fullfile(DirExe,'0_job_list.txt');%create name of the global executable file
    1941         filename_log=fullfile(DirLog,'0_job_list.stdout');%file for output messages of the master oar process
    1942         filename_errors=fullfile(DirLog,'0_job_list.stderr');%file for error messages of the master oar process
     1941        filename_log=fullfile(DirLog,'job_list.stdout');%file for output messages of the master oar process
     1942        filename_errors=fullfile(DirLog,'job_list.stderr');%file for error messages of the master oar process
    19431943       
    19441944        fid=fopen(filename_joblist,'w');
     
    19661966            '-t idempotent --checkpoint ' num2str(WallTimeOneJob*60) ' '...
    19671967            '-l /core=' num2str(NbCore) ','...
    1968             'walltime=' datestr(WallTimeOneJob/24,13) ' '...
     1968            'walltime=' datestr(WallTimeTotal/24,13) ' '...
    19691969            '-E ' filename_errors ' '...
    19701970            '-O ' filename_log ' '...
  • trunk/src/sub_field.m

    r876 r906  
    9898%% field request
    9999ProjModeRequest=cell(size(Field.ListVarName));
     100if isfield(Field,'VarAttribute')
    100101for ilist=1:numel(Field.VarAttribute)
    101102    if isfield(Field.VarAttribute{ilist},'ProjModeRequest')
     
    103104    end
    104105end
     106end
    105107ProjModeRequest_1=cell(size(Field_1.ListVarName));
     108if isfield(Field_1,'VarAttribute')
    106109for ilist=1:numel(Field_1.VarAttribute)
    107110    if isfield(Field_1.VarAttribute{ilist},'ProjModeRequest')
     
    109112    end
    110113end
    111 
     114end
    112115
    113116%% rename the dimensions of the second field if identical to those of the first
     
    162165check_rename=zeros(size(ListVarNameSub));
    163166check_remove=zeros(size(ListVarNameSub));
    164 for ilist=1:numel(ListVarNameSub)
    165     ind_prev=find(strcmp(ListVarNameSub{ilist},Field.ListVarName),1);% look for duplicated variable name
    166     if ~isempty(ind_prev)% variable name exists in Field
    167         if isfield(Field_1.VarAttribute{ilist},'Role')&&...
    168             ismember(Field_1.VarAttribute{ilist}.Role,{'coord_x','coord_y','scalar','vector_x','vector_y','errorflag'})
    169             ListVarNameNew{ilist}=[ListVarNameSub{ilist} '_1'];%modify the name of the second variable
    170             check_rename(ilist)=1;
    171         else
    172             check_remove(ilist)=1;% variable will be removed
    173         end
    174     end
    175 end
    176 ListVarNameSub=ListVarNameSub(~check_remove); %eliminate removed variables from the list of the second field
    177 ListVarNameNew=ListVarNameNew(~check_remove); % %list of renaimed varaibles corresponding to ListVarNameSub
    178 VarDimNameSub=Field_1.VarDimName(~check_remove);
    179 if numel(Field_1.VarAttribute)<max(find(~check_remove))
    180     for ilist=numel(Field_1.VarAttribute)+1:max(find(~check_remove))
    181         Field_1.VarAttribute{ilist}={};
    182     end
    183 end
    184 VarAttributeSub=Field_1.VarAttribute(~check_remove);
    185 check_rename=check_rename(~check_remove);
    186 
     167VarDimNameSub={};
     168VarAttributeSub={};
     169if isfield(Field_1,'VarAttribute')&&~isempty(Field_1.VarAttribute)
     170    for ilist=1:numel(ListVarNameSub)
     171        ind_prev=find(strcmp(ListVarNameSub{ilist},Field.ListVarName),1);% look for duplicated variable name
     172        if ~isempty(ind_prev)% variable name exists in Field
     173            if isfield(Field_1.VarAttribute{ilist},'Role')&&...
     174                    ismember(Field_1.VarAttribute{ilist}.Role,{'coord_x','coord_y','scalar','vector_x','vector_y','errorflag'})
     175                ListVarNameNew{ilist}=[ListVarNameSub{ilist} '_1'];%modify the name of the second variable
     176                check_rename(ilist)=1;
     177            else
     178                check_remove(ilist)=1;% variable will be removed
     179            end
     180        end
     181    end
     182    ListVarNameSub=ListVarNameSub(~check_remove); %eliminate removed variables from the list of the second field
     183    ListVarNameNew=ListVarNameNew(~check_remove); % %list of renaimed varaibles corresponding to ListVarNameSub
     184    VarDimNameSub=Field_1.VarDimName(~check_remove);
     185    if numel(Field_1.VarAttribute)<max(find(~check_remove))
     186        for ilist=numel(Field_1.VarAttribute)+1:max(find(~check_remove))
     187            Field_1.VarAttribute{ilist}={};
     188        end
     189    end
     190    VarAttributeSub=Field_1.VarAttribute(~check_remove);
     191    check_rename=check_rename(~check_remove);
     192end
    187193% apply the variable renaming and mark the second field variables with the attribute .CheckSub
    188194for ilist=1:numel(ListVarNameSub)
  • trunk/src/transform_field/ima_erode_particles.m

    r899 r906  
    3535
    3636%parameters
    37 radius=2;
    38 SE=strel('disk',2);
     37radius=4;
     38SE=strel('disk',radius);
    3939%---------------------------------------------------------
    4040DataOut=DataIn;%default
     
    4444    return
    4545end
    46 
     46[npy,npx]=size(DataIn.A);
     47[X,Y]=meshgrid(1:npx,1:npy);
    4748%BACKGROUND LEVEL
    4849Atype=class(DataIn.A);
    49 DataOut.A=imerode(DataIn.A,SE);
     50%SE=ones(4);
     51Aerode=imerode(DataIn.A,SE);
     52Aflagmin=find(DataIn.A==Aerode);
     53% Backg=zeros(size(A));
     54%Aflagmin=imregionalmin(DataIn.A);%Amin=1 for local image minima
     55Xmin=X(Aflagmin);
     56Ymin=Y(Aflagmin);
     57Amin=double(DataIn.A(Aflagmin));
     58F = TriScatteredInterp([Xmin Ymin], Amin);
     59DataOut.A=F(X,Y);
     60
    5061% DataOut.A=feval(Atype,DataOut.A);
    5162
  • trunk/src/transform_field/ima_remove_background.m

    r897 r906  
    2727%=======================================================================
    2828
    29 function DataOut=remove_background(DataIn)
     29function DataOut=remove_background(DataIn,Param)
    3030%------------------------------------------------------------------------
    31 DataOut=[];  %default  output field
    32 if strcmp(DataIn,'*')
     31%% request input parameters
     32if isfield(DataIn,'Action') && isfield(DataIn.Action,'RUN') && isequal(DataIn.Action.RUN,0)
     33    prompt = {'radius'};
     34    dlg_title = 'get the disk radius (pixels) used to calculate the regional minimum';
     35    num_lines= 1;
     36    def     = { '4'};
     37    if isfield(Param,'TransformInput')&&isfield(Param.TransformInput,'DiskRadius')
     38        def={num2str(Param.TransformInput.DiskRadius)};
     39    end
     40    answer = inputdlg(prompt,dlg_title,num_lines,def);
     41    DataOut.TransformInput.DiskRadius=str2num(answer{1});
     42    return
     43end
     44if ~isfield(DataIn,'A')
     45    DataOut.Txt='remove_particles only valid for input images';
     46    return
     47end
     48if ~exist('imerode','file');
     49        DataOut.Txt='the function imerode from the image processing toolbox is needed';
    3350    return
    3451end
    3552
    36 %parameters
    37 threshold=200
    38 nblock_x=30;%size of image subblocks for analysis
    39 nblock_y=30;
    40 %---------------------------------------------------------
     53SE=strel('disk',Param.TransformInput.DiskRadius);
     54%---------------------------------------------------------
    4155DataOut=DataIn;%default
     56
     57[npy,npx]=size(DataIn.A);
     58[X,Y]=meshgrid(1:npx,1:npy);
    4259
    4360%BACKGROUND LEVEL
    4461Atype=class(DataIn.A);
    45 A=double(DataIn.A);
    46 Backg=zeros(size(A));
    47 Aflagmin=sparse(imregionalmin(A));%Amin=1 for local image minima
    48 Amin=A.*Aflagmin;%values of A at local minima
    49 % local background: find all the local minima in image subblocks
    50 sumblock= inline('sum(sum(x(:)))');
    51 Backg=blkproc(Amin,[nblock_y nblock_x],sumblock);% take the sum in  blocks
    52 Bmin=blkproc(Aflagmin,[nblock_y nblock_x],sumblock);% find the number of minima in blocks
    53 Backg=Backg./Bmin; % find the average of minima in blocks
    54 B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image
    55 ImPart=(A-B);
    56 DataOut.A=ImPart;
    57 %DataOut.A=ImPart.*(ImPart>threshold);
     62Aerode=imerode(DataIn.A,SE);
     63Aflagmin=find(DataIn.A==Aerode);
     64Xmin=X(Aflagmin);
     65Ymin=Y(Aflagmin);
     66Amin=double(DataIn.A(Aflagmin));
     67F = TriScatteredInterp([Xmin Ymin], Amin);
     68DataOut.A=double(DataOut.A)-F(X,Y);
    5869DataOut.A=feval(Atype,DataOut.A);
     70
     71%BACKGROUND LEVEL
     72% Atype=class(DataIn.A);
     73% A=double(DataIn.A);
     74% Backg=zeros(size(A));
     75% Aflagmin=sparse(imregionalmin(A));%Amin=1 for local image minima
     76% Amin=A.*Aflagmin;%values of A at local minima
     77% % local background: find all the local minima in image subblocks
     78% sumblock= inline('sum(sum(x(:)))');
     79% Backg=blkproc(Amin,[nblock_y nblock_x],sumblock);% take the sum in  blocks
     80% Bmin=blkproc(Aflagmin,[nblock_y nblock_x],sumblock);% find the number of minima in blocks
     81% Backg=Backg./Bmin; % find the average of minima in blocks
     82% B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image
     83% ImPart=(A-B);
     84% DataOut.A=ImPart;
     85% %DataOut.A=ImPart.*(ImPart>threshold);
     86% DataOut.A=feval(Atype,DataOut.A);
  • trunk/src/transform_field/ima_remove_particles.m

    r897 r906  
    2727%=======================================================================
    2828
    29 function DataOut=ima_remove_particles(DataIn)
     29function DataOut=ima_remove_particles(DataIn,Param)
    3030%------------------------------------------------------------------------
    31 DataOut=[];  %default  output field
    32 if strcmp(DataIn,'*')
     31%% request input parameters
     32if isfield(DataIn,'Action') && isfield(DataIn.Action,'RUN') && isequal(DataIn.Action.RUN,0)
     33    prompt = {'radius'};
     34    dlg_title = 'get the disk radius (pixels) used to calculate the regional minimum';
     35    num_lines= 1;
     36    def     = { '4'};
     37    if isfield(Param,'TransformInput')&&isfield(Param.TransformInput,'DiskRadius')
     38        def={num2str(Param.TransformInput.DiskRadius)};
     39    end
     40    answer = inputdlg(prompt,dlg_title,num_lines,def);
     41    DataOut.TransformInput.DiskRadius=str2num(answer{1});
    3342    return
    34    
    3543end
    36 
    37 %parameters
    38 threshold=200;
    39 nblock_x=10;%size of image subblocks for analysis
    40 nblock_y=10;
    41 %---------------------------------------------------------
    42 DataOut=DataIn;%default
    43 
    4444if ~isfield(DataIn,'A')
    4545    DataOut.Txt='remove_particles only valid for input images';
    4646    return
    4747end
     48if ~exist('imerode','file');
     49        DataOut.Txt='the function imerode from the image processing toolbox is needed';
     50    return
     51end
    4852
     53SE=strel('disk',Param.TransformInput.DiskRadius);
     54%---------------------------------------------------------
     55DataOut=DataIn;%default
     56
     57[npy,npx]=size(DataIn.A);
     58[X,Y]=meshgrid(1:npx,1:npy);
    4959%BACKGROUND LEVEL
    5060Atype=class(DataIn.A);
    51 A=double(DataIn.A);
     61%SE=ones(4);
     62Aerode=imerode(DataIn.A,SE);
     63Aflagmin=find(DataIn.A==Aerode);
    5264% Backg=zeros(size(A));
    53 Aflagmin=sparse(imregionalmin(A));%Amin=1 for local image minima
    54 Amin=A.*Aflagmin;%values of A at local minima
    55 % local background: find all the local minima in image subblocks
    56 sumblock= inline('sum(sum(x(:)))');
    57 Backg=blkproc(Amin,[nblock_y nblock_x],sumblock);% take the sum in  blocks
    58 Bmin=blkproc(Aflagmin,[nblock_y nblock_x],sumblock);% find the number of minima in blocks
    59 Backg=Backg./Bmin; % find the average of minima in blocks
    60 B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image
    61 DataOut.A=B;
    62 % ImPart=(A-B);
    63 % ImPart=ImPart.*(ImPart>threshold);
    64 % DataOut.A=A-ImPart;%
     65%Aflagmin=imregionalmin(DataIn.A);%Amin=1 for local image minima
     66Xmin=X(Aflagmin);
     67Ymin=Y(Aflagmin);
     68Amin=double(DataIn.A(Aflagmin));
     69F = TriScatteredInterp([Xmin Ymin], Amin);
     70DataOut.A=F(X,Y);
    6571DataOut.A=feval(Atype,DataOut.A);
    6672
Note: See TracChangeset for help on using the changeset viewer.