Changeset 604


Ignore:
Timestamp:
Apr 4, 2013, 10:54:25 PM (11 years ago)
Author:
sommeria
Message:

bugs corrected in series, ima_levels cleaned as exemple

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ_matlab.m

    r596 r604  
    8989   
    9090    %set the values of all the global attributes in list_param
    91     Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param];
    9291    for ilist=1:length(list_param)
    9392        Civ1_param{ilist}=['Civ1_' list_param{ilist}];
    9493        Data.(['Civ1_' list_param{ilist}])=Param.Civ1.(list_param{ilist});
    9594    end
     95    Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param];
    9696    Data.CivStage=1;
    9797   
     
    105105    Data.VarAttribute{5}.Role='warnflag';
    106106   
    107     if strcmp(Param.ListCompareMode, 'PIV volume')
     107    if isfield(Param,'ListCompareMode') && strcmp(Param.ListCompareMode, 'PIV volume')
    108108        Data.ListVarName=[Data.ListVarName 'Civ1_Z'];
    109109        Data.Civ1_X=[];Data.Civ1_Y=[];Data.Civ1_Z=[];
  • trunk/src/read_image.m

    r497 r604  
    55% OUTPUT:
    66% A(npy,npx,rgb): matrix of integers (iunt8 or uint16) representing the image, with sizes npy, npx, and possibly color component rgb=1:3
    7 % ObjectOut: video object (=[] for images)
     7% ObjectOut: video object (=[] for single images)
    88%
    99% INPUT:
    1010% FileName: input file name
     11%                 other inputs needed  only for video and multi-image file:
    1112% FileType: input file type, as determined by the function get_file_type.m
    1213% VideoObject: video object (for faster reading if availlable)
     
    1516function [A,ObjectOut]=read_image(FileName,FileType,VideoObject,num)
    1617%-----------------------------------------------------------------------
     18if ~exist(FileType,'var')
     19    FileType='image';
     20end
    1721if ~exist('VideoObject','var')
    1822    VideoObject=[];
  • trunk/src/series.m

    r603 r604  
    14601460nbfield_j=numel(first_j:incr_j:last_j);
    14611461
    1462 %% record nbre of output files for status
     1462%% record nbre of output files and starting time for computation for status
    14631463StatusData=get(handles.status,'UserData');
    1464 StatusData.NbCore=NbCore;
    1465 StatusData.NbProcess=NbProcess;
    1466 if isfield(StatusData,'OutputFileMode')
    1467 switch StatusData.OutputFileMode
    1468     case 'NbInput'%TODO:finish
    1469 end
    1470 end
     1464    switch StatusData.OutputFileMode
     1465        case 'NbInput'
     1466            StatusData.NbOutputFile=numel(first_i,incr_i:last_i)*numel(first_j,incr_j:last_j);
     1467        case 'NbInput_i'
     1468            StatusData.NbOutputFile=numel(first_i,incr_i:last_i);
     1469        case 'NbSlice'   
     1470            StatusData.NbOutputFile=str2num(get(handles.num_NbSlice,'String'));
     1471    end
     1472StatusData.TimeStart=now;
     1473set(handles.status,'UserData',StatusData)
    14711474
    14721475%% direct processing on the current Matlab session
     
    16171620    case 'background'
    16181621        for iprocess=1:NbProcess
    1619             system(batch_file_list{iprocess})% directly execute the command file for each process
     1622            system([batch_file_list{iprocess} ' &'])% directly execute the command file for each process
    16201623        end
    16211624    case 'cluster_oar' % option 'oar-parexec' used
     
    19351938if isfield(Series.IndexRange,'first_i')
    19361939    first_i=Series.IndexRange.first_i;
     1940    incr_i=Series.IndexRange.incr_i;
    19371941    last_i=Series.IndexRange.last_i;
    19381942end
    19391943if isfield(Series.IndexRange,'first_j')
    19401944    first_j=Series.IndexRange.first_j;
     1945     incr_j=Series.IndexRange.incr_j;
    19411946    last_j=Series.IndexRange.last_j;
    19421947end
     
    20442049%% Expected nbre of output files
    20452050if isfield(ParamOut,'OutputFileMode')
    2046 StatusData.NbOutputFile=ParamOut.OutputFileMode;
     2051StatusData.OutputFileMode=ParamOut.OutputFileMode;
    20472052set(handles.status,'UserData',StatusData)
    20482053end
     
    24432448    set(handles.status,'BackgroundColor',[1 1 0])
    24442449    drawnow
    2445     StatusData.time_ref=get(handles.RUN,'UserData');% get the time of launch
     2450    %StatusData.time_ref=get(handles.RUN,'UserData');% get the time of launch
    24462451    Param=read_GUI(handles.series);
    24472452    RootPath=Param.InputTable{1,1};
     
    24542459    hfig=findobj(allchild(0),'name','series_status');
    24552460    if isempty(hfig)
    2456         hfig=figure('DeleteFcn',@stop_status,'Position',[600 600 560 600]);
     2461        ScreenSize=get(0,'ScreenSize');
     2462        hfig=figure('DeleteFcn',@stop_status,'Position',[ScreenSize(3)-600 ScreenSize(4)-640 560 600]);
    24572463        set(hfig,'MenuBar','none')% suppress the menu bar
    24582464        set(hfig,'NumberTitle','off')%suppress the fig number in the title
     
    24642470        uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@stop_status);
    24652471        hrefresh=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@refresh_GUI);
    2466         set(hrefresh,'UserData',StatusData)
     2472        %set(hrefresh,'UserData',StatusData)
    24672473        BarPosition=[0.05 0.81 0.01 0.05];
    24682474        uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar');
     
    24842490% launched by selecting a file on the list
    24852491function view_file(hObject, eventdata)
     2492%------------------------------------------------------------------------
    24862493list=get(hObject,'String');
    24872494index=get(hObject,'Value');
     
    25212528
    25222529
    2523 %------------------------------------------------------------------------
    2524 
    25252530%------------------------------------------------------------------------   
    25262531% launched by refreshing the status figure
     
    25302535htitlebox=findobj(hfig,'tag','titlebox');
    25312536hlist=findobj(hfig,'tag','list');
    2532 StatusData=get(hObject,'UserData');
     2537hseries=findobj(allchild(0),'tag','series');
     2538hstatus=findobj(hseries,'tag','status');
     2539StatusData=get(hstatus,'UserData');
    25332540OutputDir=get(htitlebox,'String');
    25342541if ischar(OutputDir),OutputDir={OutputDir};end
    25352542ListFiles=dir(OutputDir{1});
     2543if numel(ListFiles)<1
     2544    return
     2545end
     2546ListFiles(1)=[];%removes the first line ='.'
    25362547ListDisplay=cell(numel(ListFiles),1);
    25372548testrecent=0;
    2538 datnum=zeros(numel(ListDisplay)-1,1);
    2539 for ilist=2:numel(ListDisplay)
    2540     ListDisplay{ilist-1}=ListFiles(ilist).name;
     2549datnum=zeros(numel(ListDisplay),1);
     2550for ilist=1:numel(ListDisplay)
     2551    ListDisplay{ilist}=ListFiles(ilist).name;
    25412552      if ~ListFiles(ilist).isdir && isfield(ListFiles(ilist),'datenum')
    25422553            datnum(ilist)=ListFiles(ilist).datenum;%only available in recent matlab versions
     
    25472558
    25482559%% Look at date of creation
     2560ListDisplay=ListDisplay(datnum~=0);
    25492561datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
    2550 ListDisplay=ListDisplay(datnum~=0);
    25512562if isempty(datnum)
    25522563    if testrecent
     
    25582569    [first,indfirst]=min(datnum);
    25592570    [last,indlast]=max(datnum);
    2560     message={[num2str(numel(datnum)) ' file(s) done over ?'] ;['oldest modification:  ' ListDisplay{indfirst} ' : ' datestr(first)];...
     2571    NbOutputFile_str='?';
     2572    NbOutputFile=[];
     2573    if isfield(StatusData,'NbOutputFile')
     2574        NbOutputFile=StatusData.NbOutputFile;
     2575        NbOutputFile_str=num2str(NbOutputFile);
     2576    end
     2577    message={[num2str(numel(datnum)) ' file(s) done over ' NbOutputFile_str] ;['oldest modification:  ' ListDisplay{indfirst} ' : ' datestr(first)];...
    25612578        ['latest modification:  ' ListDisplay{indlast} ' : ' datestr(last)]};
    25622579end
    2563 titlebox=findobj(hfig,'tag','titlebox');
    2564 msg_old=get(titlebox,'String');
    2565 set(titlebox,'String', [msg_old(1);message])
     2580set(htitlebox,'String', [OutputDir{1};message])
     2581
     2582%% update the waitbar
    25662583hwaitbar=findobj(hfig,'tag','waitbar');
     2584if ~isempty(NbOutputFile)
     2585    BarPosition=get(hwaitbar,'Position');
     2586    BarPosition(3)=0.9*numel(datnum)/NbOutputFile;
     2587    set(hwaitbar,'Position',BarPosition)
     2588end
    25672589%TODO: adjust waitbar
    25682590
     
    26412663% set(hlist,'String',Tabchar)
    26422664% set(htitlebox,'String', message)
    2643 % if count>0 %&& ~test_new
    2644 %     BarPosition(3)=0.9*count/nbfiles;
    2645 %     set(hwaitbar,'Position',BarPosition)
    2646 % end
     2665%
    26472666%------------------------------------------------------------------------   
    26482667% launched by deleting the status figure
     
    26722691        end
    26732692    end
    2674     currentdir=pwd;
    2675     cd(get(handles.ActionPath,'String'))
    2676     sh_file=dir([ActionName '.sh']);
    2677     m_file=dir([ActionName '.m']);
    2678     if isfield(m_file,'datenum') && m_file.datenum>sh_file.datenum
     2693    sh_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.sh']));
     2694    m_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.m']));
     2695    if isfield(m_file_info,'datenum') && m_file_info.datenum>sh_file_info.datenum
    26792696        set(handles.ActionExt,'BackgroundColor',[1 1 0])
    26802697        drawnow
    26812698        answer=msgbox_uvmat('INPUT_Y-N',[ActionName '.sh needs to be updated: recompile now?']);
    26822699        if strcmp(answer,'Yes')
     2700            currentdir=pwd;
     2701            cd(get(handles.ActionPath,'String'))
    26832702            compile(ActionName)
     2703            cd(currentdir)
    26842704        end
    26852705        set(handles.ActionExt,'BackgroundColor',[1 1 1])
    26862706    end
    2687     cd(currentdir)
    26882707end
    26892708
  • trunk/src/series/civ_input.m

    r603 r604  
    2525
    2626
    27 % Last Modified by GUIDE v2.5 04-Apr-2013 09:14:14
     27% Last Modified by GUIDE v2.5 04-Apr-2013 22:08:23
    2828% Begin initialization code - DO NOT EDIT
    2929gui_Singleton = 1;
     
    8282%% input file info
    8383RootPath=Param.InputTable{1,1};
     84set(handles.RootPath,'String',RootPath)
    8485RootFile=Param.InputTable{1,3};
    8586SubDir=Param.InputTable{1,2};
     
    116117        imageinput='';
    117118        Data=nc2struct(FileInput,'ListGlobalAttribute','Civ2_ImageA','Civ1_ImageA','Civ2_ImageB','Civ1_ImageB');
     119        [PathCiv1_ImageA,Civ1_ImageA,FileExtA]=fileparts(Data.Civ1_ImageA);
     120        [PathCiv1_ImageB,Civ1_ImageB,FileExtA]=fileparts(Data.Civ1_ImageB);
     121        [PathCiv2_ImageA,Civ2_ImageA,FileExtA]=fileparts(Data.Civ2_ImageA);
     122        [PathCiv2_ImageB,Civ2_ImageB,FileExtA]=fileparts(Data.Civ2_ImageB);
     123        set(handles.Civ1_ImageA,'String',Civ1_ImageA)
     124        set(handles.Civ1_ImageB,'String',Civ1_ImageB)
     125        set(handles.Civ2_ImageA,'String',Civ2_ImageA)
     126        set(handles.Civ2_ImageB,'String',Civ2_ImageB)
    118127    if isfield(Data,'Txt')
    119128        errormsg=Data.Txt;
     
    121130        %TODO: introduce the image in the input table of series
    122131    end
    123         %         if  ~isempty(Data.Civ2_ImageB)%get the corresponding input image in the netcdf file
    124         %             imageinput=Data.Civ2_ImageB;
    125         %             [tild,ImaName,ImaExt]=fileparts(Data.Civ2_ImageA);
    126         %             set(handles.RootFile_1,'String',[ImaName ImaExt])
    127         %         elseif ~isempty(Data.Civ1_ImageB)
    128         %             imageinput=Data.Civ1_ImageB;
    129         %             [tild,ImaName,ImaExt]=fileparts(Data.Civ1_ImageA);
    130         %             set(handles.RootFile_1,'String',[ImaName ImaExt])
    131         %         end
    132         % settings for civx data,       
    133         % look for the corresponding input images
    134         check_letter=~isempty(regexp(NomTypeInput,'[ab|AB]$','once'));%detect pair label by letter
    135         NomTypeIma=NomTypeInput;
    136         if check_letter
    137             NomTypeIma=NomTypeInput(1:end-1);
    138         else
    139             r=regexp(NomTypeIma,'.-(?<num2>\d+)$','names');
    140             if ~isempty(r)
    141                 NomTypeIma=regexprep(NomTypeIma,['-' r.num2],'');
    142             end
    143             r=regexp(NomTypeIma,'.-(?<num2>\d+)','names');
    144             if ~isempty(r)
    145                 NomTypeIma=regexprep(NomTypeIma,['-' r.num2],'');
    146             end
    147         end
    148 %         if ~exist(imageinput,'file')
    149 %             imageinput=fullfile_uvmat(RootPath,regexprep(SubDir,'.civ(_?)(\d*)$',''),RootFile,'.png',NomTypeIma,i1,[],j1);
    150 %         end
     132        [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaA]=fileparts_uvmat(Data.Civ1_ImageA);
     133        [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaB]=fileparts_uvmat(Data.Civ1_ImageB);
    151134    case 'civxdata'% case of  civx data,
    152135        NomTypeNc=NomTypeInput;
     
    407390
    408391%% determine nomenclature types and extension of the input files
    409 % [RootPath,SubDir,RootFile,i1,i2,j1,j2,ExtInput,NomTypeInput]=fileparts_uvmat(fileinput);
     392% [RootPath,SubDir,Civ2_ImageB,i1,i2,j1,j2,ExtInput,NomTypeInput]=fileparts_uvmat(fileinput);
    410393% NomTypeNc='';%default
    411394
     
    416399% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    417400% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
    418 %[RootPath,ImageACiv1,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,MovieObject]=find_file_series(FilePath,[FileName ImaExt]);
     401%[RootPath,Civ1_ImageA,Civ2_ImageB,i1_series,tild,j1_series,tild,NomTypeIma,FileType,MovieObject]=find_file_series(FilePath,[FileName ImaExt]);
    419402switch Param.FileType{1}
    420403    case {'image','multimage','video','mmreader'}
     
    424407end
    425408set(handles.RootPath,'String',RootPath)
    426 set(handles.ImageACiv1,'String',SubDirImages)
    427 set(handles.RootFile,'String',RootFile)
     409set(handles.Civ1_ImageA,'String',SubDirImages)
     410set(handles.Civ2_ImageB,'String',RootFile)
    428411if strcmp(ExtInput,'.nc')
    429412    SubDirCiv=regexprep(SubDir,['^' SubDirImages],'');%suppress the root  SuddirImages;
     
    431414    SubDirCiv= '.civ';
    432415end
    433 set(handles.ImageBCiv1,'String',SubDirCiv)
    434 set(handles.ImageACiv2,'String',SubDirCiv)
     416set(handles.Civ1_ImageB,'String',SubDirCiv)
     417set(handles.Civ2_ImageA,'String',SubDirCiv)
    435418browse=get(handles.RootPath,'UserData');
    436419browse.incr_pair=[0 0];%default
     
    511494%------------------------------------------------------------------------
    512495% --- Executes on carriage return on the subdir checkciv1 edit window
    513 function ImageBCiv1_Callback(hObject, eventdata, handles)
    514 %------------------------------------------------------------------------
    515 SubDir=get(handles.ImageBCiv1,'String');
     496function Civ1_ImageB_Callback(hObject, eventdata, handles)
     497%------------------------------------------------------------------------
     498SubDir=get(handles.Civ1_ImageB,'String');
    516499menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update
    517500ichoice=find(strcmp(SubDir,menu_str),1);
     
    523506set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu
    524507if get(handles.CheckCiv1,'Value')% if Civ1 is performed
    525     set(handles.ImageACiv2,'String',SubDir);% set by default civ2 directory the same as civ1
     508    set(handles.Civ2_ImageA,'String',SubDir);% set by default civ2 directory the same as civ1
    526509%     set(handles.ListSubdirCiv2,'Value',ilist)
    527510else % if Civ1 data already exist
     
    534517%------------------------------------------------------------------------
    535518% --- Executes on carriage return on the SubDir checkciv1 edit window
    536 function ImageACiv2_Callback(hObject, eventdata, handles)
    537 %------------------------------------------------------------------------
    538 SubDir=get(handles.ImageBCiv1,'String');
     519function Civ2_ImageA_Callback(hObject, eventdata, handles)
     520%------------------------------------------------------------------------
     521SubDir=get(handles.Civ1_ImageB,'String');
    539522menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update
    540523ichoice=find(strcmp(SubDir,menu_str),1);
     
    609592% end
    610593set(handles.PairIndices,'Visible','on')
    611 set(handles.ImageBCiv1,'Visible','on')
     594set(handles.Civ1_ImageB,'Visible','on')
    612595set(handles.TitleSubdirCiv1,'Visible','on')
    613596if opening==0
     
    620603    set(handles.TitlePairCiv2,'Visible','on')
    621604    set(handles.TitleSubdirCiv2,'Visible','on')
    622     set(handles.ImageACiv2,'Visible','on')
     605    set(handles.Civ2_ImageA,'Visible','on')
    623606    %set(handles.ListSubdirCiv2,'Visible','on')
    624607    set(handles.ListPairCiv2,'Visible','on')
     
    631614else
    632615    set(handles.TitleSubdirCiv2,'Visible','off')
    633     set(handles.ImageACiv2,'Visible','off')
     616    set(handles.Civ2_ImageA,'Visible','off')
    634617    set(handles.ListPairCiv2,'Visible','off')
    635618end
     
    11301113
    11311114%% reads .nc subdirectoy and image numbers from the interface
    1132 SubDirImages=get(handles.ImageACiv1,'String');
    1133 subdir_civ1=[SubDirImages get(handles.ImageBCiv1,'String')];%subdirectory subdir_civ1 for the netcdf data
    1134 subdir_civ2=[SubDirImages get(handles.ImageACiv2,'String')];%subdirectory subdir_civ2 for the netcdf data
     1115SubDirImages=get(handles.Civ1_ImageA,'String');
     1116subdir_civ1=[SubDirImages get(handles.Civ1_ImageB,'String')];%subdirectory subdir_civ1 for the netcdf data
     1117subdir_civ2=[SubDirImages get(handles.Civ2_ImageA,'String')];%subdirectory subdir_civ2 for the netcdf data
    11351118ref_i=str2double(get(handles.ref_i,'String'));
    11361119ref_j=[];
     
    11661149testpair=0;
    11671150RootPath=get(handles.RootPath,'String');
    1168 RootFile=get(handles.RootFile,'String');
     1151RootFile=get(handles.Civ2_ImageB,'String');
    11691152if index==1 % case civ1
    11701153    if ~get(handles.CheckCiv1,'Value') %
     
    15921575nbslice=1;
    15931576
    1594 % subdir=get(handles.ImageBCiv1,'String');
     1577% subdir=get(handles.Civ1_ImageB,'String');
    15951578[Path,Name]=fileparts(filebase);
    15961579if ~isdir(Path)
     
    16881671%     end   
    16891672% end
    1690 % set(handles.ImageBCiv1,'String',SubDir);
     1673% set(handles.Civ1_ImageB,'String',SubDir);
    16911674% errormsg=find_netcpair_civ(handles,1);
    16921675% if ~isempty(errormsg)
     
    17091692%     end
    17101693% end
    1711 % set(handles.ImageACiv2,'String',SubDir);
     1694% set(handles.Civ2_ImageA,'String',SubDir);
    17121695
    17131696%------------------------------------------------------------------------
     
    22022185
    22032186
    2204 function NcFileCiv2_Callback(hObject, eventdata, handles)
    2205 % hObject    handle to NcFileCiv2 (see GCBO)
    2206 % eventdata  reserved - to be defined in a future version of MATLAB
    2207 % handles    structure with handles and user data (see GUIDATA)
    2208 
    2209 % Hints: get(hObject,'String') returns contents of NcFileCiv2 as text
    2210 %        str2double(get(hObject,'String')) returns contents of NcFileCiv2 as a double
    2211 
    2212 
    2213 % --- Executes during object creation, after setting all properties.
    2214 function NcFileCiv2_CreateFcn(hObject, eventdata, handles)
    2215 % hObject    handle to NcFileCiv2 (see GCBO)
    2216 % eventdata  reserved - to be defined in a future version of MATLAB
    2217 % handles    empty - handles not created until after all CreateFcns called
    2218 
    2219 % Hint: edit controls usually have a white background on Windows.
    2220 %       See ISPC and COMPUTER.
    2221 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    2222     set(hObject,'BackgroundColor','white');
    2223 end
    2224 
    2225 
    2226 
    2227 function ImageACiv1_Callback(hObject, eventdata, handles)
    2228 % hObject    handle to ImageACiv1 (see GCBO)
    2229 % eventdata  reserved - to be defined in a future version of MATLAB
    2230 % handles    structure with handles and user data (see GUIDATA)
    2231 
    2232 % Hints: get(hObject,'String') returns contents of ImageACiv1 as text
    2233 %        str2double(get(hObject,'String')) returns contents of ImageACiv1 as a double
  • trunk/src/series/civ_series.m

    r601 r604  
    192192        Civ1_param=list_param;%default
    193193       
    194         %set the values of all the global attributes in list_param
    195         Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param];
     194        %set the values of all the global attributes in list_param 
    196195        for ilist=1:length(list_param)
    197196            Civ1_param{ilist}=['Civ1_' list_param{ilist}];
    198197            Data.(['Civ1_' list_param{ilist}])=Param.ActionInput.Civ1.(list_param{ilist});
    199198        end
     199        Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param];
    200200        Data.CivStage=1;
    201201       
  • trunk/src/series/ima_levels.m

    r602 r604  
    44% function GUI_input=ima_levels(Param)
    55%
     6%------------------------------------------------------------------------
    67%%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%%
    78%
    8 % This function is used in four modes by the GUI series:
    9 %           1) config GUI: with no input argument, the function determine the suitable GUI configuration
    10 %           2) interactive input: the function is used to interactively introduce input parameters, and then stops
    11 %           3) RUN: the function itself runs, when an appropriate input  structure Param has been introduced.
    12 %           4) BATCH: the function itself proceeds in BATCH mode, using an xml file 'Param' as input.
    13 %
    149%OUTPUT
    15 % GUI_input=list of options in the GUI series.fig needed for the function
     10% ParamOut: sets options in the GUI series.fig needed for the function
    1611%
    1712%INPUT:
    1813% In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series.
    1914% In batch mode, Param is the name of the corresponding xml file containing the same information
    20 % In the absence of input (as activated when the current Action is selected
    21 % in series), the function ouput GUI_input set the activation of the needed GUI elements
    22 %
    23 % Param contains the elements:(use the menu bar command 'export/GUI config' in series to see the current structure Param)
     15% when Param.Action.RUN=0 (as activated when the current Action is selected
     16% in series), the function ouput paramOut set the activation of the needed GUI elements
     17%
     18% Param contains the elements:(use the menu bar command 'export/GUI config' in series to
     19% see the current structure Param)
    2420%    .InputTable: cell of input file names, (several lines for multiple input)
    2521%                      each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension}
    2622%    .OutputSubDir: name of the subdirectory for data outputs
    27 %    .OutputDir: directory for data outputs, including path
     23%    .OutputDirExt: directory extension for data outputs
    2824%    .Action: .ActionName: name of the current activated function
    2925%             .ActionPath:   path of the current activated function
     26%             .ActionExt: fct extension ('.m', Matlab fct, '.sh', compiled   Matlab fct
     27%             .RUN =0 for GUI input, =1 for function activation
     28%             .RunMode='local','background', 'cluster': type of function  use
     29%             
    3030%    .IndexRange: set the file or frame indices on which the action must be performed
    3131%    .FieldTransform: .TransformName: name of the selected transform function
    3232%                     .TransformPath:   path  of the selected transform function
    33 %                     .TransformHandle: corresponding function handle
    3433%    .InputFields: sub structure describing the input fields withfields
    35 %              .FieldName: name of the field
     34%              .FieldName: name(s) of the field
    3635%              .VelType: velocity type
    3736%              .FieldName_1: name of the second field in case of two input series
    3837%              .VelType_1: velocity type of the second field in case of two input series
     38%              .Coord_y: name of y coordinate variable
     39%              .Coord_x: name of x coordinate variable
    3940%    .ProjObject: %sub structure describing a projection object (read from ancillary GUI set_object)
    4041%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    4445%% set the input elements needed on the GUI series when the action is selected in the menu ActionName
    4546if isstruct(Param) && isequal(Param.Action.RUN,0)
    46     ParamOut.NbViewMax=1;% max nbre of input file series (default='' , no limitation)
     47    ParamOut.NbViewMax=1;% max nbre of input file series (default , no limitation)
    4748    ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
    4849    ParamOut.WholeIndexRange='off';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
     
    5455    ParamOut.Mask='off';%can use mask option   (option 'off'/'on', 'off' by default)
    5556    ParamOut.OutputDirExt='.lev';%set the output dir extension
    56     ParamOut.OutputFileMode='NbInput';%NbInput= 1 output file per input file index, NbInput_i=1 fileper input file index i,NbSlice= 1 file per slice
     57    ParamOut.OutputFileMode='NbInput';% ='=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice
     58    %check the type of the existence and type of the first input file:
     59    Param.IndexRange.last_i=Param.IndexRange.first_i;%keep only the first index in the series
     60    Param.IndexRange.last_j=Param.IndexRange.first_j;
     61    filecell=get_file_series(Param);
     62    if ~exist(filecell{1,1},'file')
     63        msgbox_uvmat('WARNING','the first input file does not exist')
     64    else
     65        FileType=get_file_type(filecell{1,1});
     66        if isempty(find(strcmp(FileType,{'image','multimage','mmreader','video'})));% =1 for images
     67            msgbox_uvmat('ERROR',['bad input file type for ' mfilename ': an image is needed'])
     68        end
     69    end
    5770return
    5871end
     
    6679end
    6780
    68 ParamOut=Param; %default output
    69 if ~isfield(Param,'InputFields')
    70     Param.InputFields.FieldName='';
    71 end
    72 OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files
    73 
    74 %% root input file(s) and type
     81%% root input file names and nomenclature type (cell arrays with one element)
    7582RootPath=Param.InputTable(:,1);
    7683RootFile=Param.InputTable(:,3);
     
    7885NomType=Param.InputTable(:,4);
    7986FileExt=Param.InputTable(:,5);
    80 OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files
    81 
    82 % get the set of input file names (cell array filecell), and the lists of
    83 % input file or frame indices i1_series,i2_series,j1_series,j2_series
     87
     88%% subdirectory for output files
     89SubdirOut=[Param.OutputSubDir Param.OutputDirExt];
     90
     91%% get the set of input file names (cell array filecell), and file indices
    8492[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
    8593% filecell{iview,fileindex}: cell array representing the list of file names
     
    8896% i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j
    8997% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
    90 % set of frame indices used for movie or multimage input
    91 % numbers of slices and file indices
    92 
    93 NbSlice=1;%default
    94 if isfield(Param.IndexRange,'NbSlice')
    95     NbSlice=Param.IndexRange.NbSlice;
    96 end
    97 nbview=numel(i1_series);%number of input file series (lines in InputTable)
    98 nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
     98nbfield_j=size(j1_series{1},1); %nb of fields for the j index (bursts or volume slices)
    9999nbfield_i=size(i1_series{1},2); %nb of fields for the i index
    100100nbfield=nbfield_j*nbfield_i; %total number of fields
    101 nbfield_i=floor(nbfield/NbSlice);%total number of  indexes in a slice (adjusted to an integer number of slices)
    102 nbfield=nbfield_i*NbSlice; %total number of fields after adjustement
    103 
    104 %determine the file type on each line from the first input file
    105 ImageTypeOptions={'image','multimage','mmreader','video'};%allowed input file types(images)
    106 
    107 [FileType{1},FileInfo{1},MovieObject{1}]=get_file_type(filecell{1,1});
    108 CheckImage{1}=~isempty(find(strcmp(FileType,ImageTypeOptions)));% =1 for images
     101[FileType{1},FileInfo{1},VideoObject{1}]=get_file_type(filecell{1,1});% type of input file
     102
     103%% frame index for movie or multimage file input 
    109104if ~isempty(j1_series{1})
    110105    frame_index{1}=j1_series{1};
     
    125120 % EDIT FROM HERE
    126121
    127  %% check the validity of  input file types
    128 if CheckImage{1}
    129     FileExtOut='.png'; % write result as .png images for image inputs
    130     if strcmp(lower(NomType{1}(end)),'a')
    131         NomTypeOut=NomType{1};
    132     else
    133         NomTypeOut='_1_1';
    134     end
    135 else
    136     msgbox_uvmat('ERROR',['invalid file type input: ' FileType{1} ' not an image'])
    137     return
    138 end
     122 %% Extension and indexing nomenclature for output file
     123 FileExtOut='.png'; % write result as .png images for image inputs
     124 if strcmpi(NomType{1}(end),'a')
     125     NomTypeOut=NomType{1};
     126 else
     127     NomTypeOut='_1_1';
     128 end
    139129
    140130%% Set field names and velocity types
     
    153143j1=[];%default
    154144for ifile=1:nbfield
    155           if checkrun
    156                 stopstate=get(Param.RUNHandle,'BusyAction');
    157                 update_waitbar(Param.WaitbarHandle,ifile/nbfield)
    158           else
    159                 stopstate='queue';
    160           end
    161     if isequal(stopstate,'queue') % enable STOP command
    162         if ~isempty(j1_series)&&~isequal(j1_series,{[]})
    163             j1=j1_series{1}(ifile);
    164         end
    165         filename=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},NomType{1},i1_series{1}(ifile),[],j1);
    166         A=read_image(filename,FileType{1},MovieObject{1},frame_index{1}(ifile));
    167         if ndims(A)==3;%color images
    168             A=sum(double(Aread),3);% take the sum of color components
    169         end
    170         % operation on images
    171         A=levels(A);
    172         filename_new=fullfile_uvmat(RootPath{1},OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);
    173         imwrite(A,filename_new)
    174         display([filename_new ' written'])
    175     end
     145    if checkrun
     146        stopstate=get(Param.RUNHandle,'BusyAction');
     147        update_waitbar(Param.WaitbarHandle,ifile/nbfield)
     148    else
     149        stopstate='queue';
     150    end
     151    if ~isequal(stopstate,'queue') % enable STOP command
     152        break
     153    end
     154    if ~isempty(j1_series)&&~isequal(j1_series,{[]})
     155        j1=j1_series{1}(ifile);
     156    end
     157    filename=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},NomType{1},i1_series{1}(ifile),[],j1);
     158    A=read_image(filename,FileType{1},VideoObject{1},frame_index{1}(ifile));
     159    if ndims(A)==3;%color images
     160        A=sum(double(Aread),3);% take the sum of color components
     161    end
     162    % operation on images
     163    A=levels(A);
     164    % write output file
     165    filename_new=fullfile_uvmat(RootPath{1},SubdirOut,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);
     166    imwrite(A,filename_new)
     167    display([filename_new ' written'])
    176168end
    177169%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracChangeset for help on using the changeset viewer.