Changeset 1179
- Timestamp:
- Mar 23, 2025, 11:13:38 AM (4 weeks ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 3 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/angle2normal.m
r1108 r1179 1 %calculate the components of the unit vector norm_plane normal to the plane 2 %defined by the rotation vector PlaneAngle (in degree) 1 %angle2normal: calculate the components of the unit vector defined by a rotation vector 3 2 % this gives the equation of the plane as norm_plane(1)x + norm_plane(2)y +norm_plane(3)z = cte 3 4 % OUTPUT: 5 %norm_plane: three components of the normal unit vector 6 % INPUT: 7 %PlaneAngle: rotation vector, with three components in degree) 4 8 5 9 function norm_plane=rotate(PlaneAngle) -
trunk/src/browse_data.m
r1150 r1179 242 242 ListExperiments_Callback([],[], handles) 243 243 else 244 msgbox_uvmat('ERROR',['The input ' Campaign ' is not a directory'])244 msgbox_uvmat('ERROR',['The input ' SourceDir ' is not a folder']) 245 245 end 246 246 -
trunk/src/check_files.m
r1127 r1179 28 28 %======================================================================= 29 29 30 function [checkmsg,date_str,svn_info ]=check_files30 function [checkmsg,date_str,svn_info,list_fct]=check_files 31 31 checkmsg={};%default 32 32 svn_info.rep_rev=[]; … … 35 35 list_fct={... 36 36 'activate';...% emulate the mouse selection of a GUI element, for demo 37 'angle2normal';...%rotation vector PlaneAngle (in degree) 37 38 'browse_data';...% function for scanning directories in a project/campaign 38 39 'browse_data.fig';...% GUI corresponding to dataview … … 41 42 'cell2tab';... %transform a Matlab cell in a character array suitable for display in a table 42 43 'check_files';... 44 'civ';... % key function for image correlations (called by series/cvi_series.m) 45 'cluster_command';...% creates the command string for launching jobs in the cluster system 'oar'. 46 'command_launch_matlab';% creates the command strings for opening a new Matlab session 47 'command_load_python';% creates the command strings for loading Python 43 48 'compile';...% compile a Matlab function, create a binary in a subdirectory /bin 44 49 'copyfields';...% copy fields between two matlab structures -
trunk/src/civ.m
r1169 r1179 1 1 %-------------------------------------------------------------------------- 2 % 'civ': function adapted from PIVlab http://pivlab.blogspot.com/2 % 'civ': key function for image correlations (called by series/cvi_series.m) 3 3 % function [xtable ytable utable vtable typevector] = civ (image1,image2,ibx,iby step, subpixfinder, mask, roi) 4 4 % -
trunk/src/cluster_command.m
r1171 r1179 1 %'cluster_command': creates the command string for launching jobs in the cluster 2 %------------------------------------------------------------------------ 1 %'cluster_command': creates the command string for launching jobs in the cluster system 'oar' 2 % other cluster options 'pbs' and 'psmn' are available in cluster_command_pbs and 3 % cluster_command_psmn. The choice is made in the xml file for parameters: series.xml 4 %-- ---------------------------------------------------------------------- 3 5 % function cmd=cluster_command(ListProcess,ActionFullName,DirLog,NbProcess, NbCore,CPUTimeProcess) 4 6 % … … 19 21 filename_log=fullfile(DirLog,'job_list.stdout'); % file for output messages of the master oar process 20 22 filename_errors=fullfile(DirLog,'job_list.stderr'); % file for error messages of the master oar process 21 22 23 24 25 end 23 if NbProcess>=6 24 bigiojob_string=['+{type = ' char(39) 'bigiojob' char(39) '}/licence=1'];% char(39) is quote - bigiojob limit UVmat parallel launch on cluster to avoid saturation of disk access to data 25 else 26 bigiojob_string=''; 27 end 26 28 27 29 WallTimeMax=23;% absolute limit on computation time (in hours) 28 WallTimeTotal=min(WallTimeMax,4*CPUTimeProcess/60);% chosen limit on computation time (in hours),possibly smaller than the absolute limit to favor job priority in the system. 29 WallTimeOneProcess=min(4*CPUTimeProcess+10,WallTimeTotal*60/2); % estimated max time of an individual process, used for checkpoint: 30 30 WallTimeTotal=min(WallTimeMax,4*CPUTimeProcess/60);% chosen limit on computation time (in hours),possibly smaller than the absolute limit to favor job priority in the system. 31 WallTimeOneProcess=min(4*CPUTimeProcess+10,WallTimeTotal*60/2); % estimated max time of an individual process, used for checkpoint: 32 %if less than this time remains before walltime, the job is stopped and a new one can be launched ( by the option 'idempotent') 31 33 32 if NbCore==1 33 corestring='cpu=1/core=4'; %increases the allowed memory in case of single core job 34 else 35 % corestring=['/core=' num2str(NbCore)]; 36 corestring=['{cluster=''calcul8''}/core=' num2str(NbCore)]; 37 end 38 cmd=['oarsub -n UVmat_' ActionFullName ' '... 39 '-t idempotent --checkpoint ' num2str(WallTimeOneProcess*60) ' '... 40 '-l "' corestring bigiojob_string... % char(39) is quote - bigiojob limit UVmat parallel launch on cluster 41 ',walltime=' datestr(WallTimeTotal/24,13) '" '... 42 '-E ' filename_errors ' '... 43 '-O ' filename_log ' '... 44 '"oar-parexec -s -f ' ListProcessFile ' '... 45 '-l ' ListProcessFile '.log"']; 34 % if NbCore==1 35 % corestring='cpu=1/core=4'; %increases the allowed memory in case of single core job 36 % else 37 corestring=['{cluster=''calcul8''}/core=' num2str(max(NbCore,4))]; 38 % end 39 cmd=['oarsub -n UVmat_' ActionFullName ' '... 40 '-t idempotent --checkpoint ' num2str(WallTimeOneProcess*60) ' '... 41 '-l "' corestring bigiojob_string... % char(39) is quote - bigiojob limit UVmat parallel launch on cluster 42 ',walltime=' datestr(WallTimeTotal/24,13) '" '... 43 '-E ' filename_errors ' '... 44 '-O ' filename_log ' '... 45 '"oar-parexec -s -f ' ListProcessFile ' '... 46 '-l ' ListProcessFile '.log"']; -
trunk/src/command_launch_matlab.m
r1134 r1179 1 %'command_launch_matlab': creates the command strings for opening a new Matlab 2 % sessionand running a programme in a Linux system('GLNX86','GLNXA64','MACI64')1 %'command_launch_matlab': creates the command strings for opening a new Matlab session 2 % and running a programme in a Linux system('GLNX86','GLNXA64','MACI64') 3 3 %------------------------------------------------------------------------ 4 4 % function cmd=command_launch_matlab(filelog,path_uvmat,ActionPath,ActionName,inputxml,option) … … 47 47 end 48 48 49 %% case cluster:50 % matlab_ver = ver('MATLAB');51 % matlab_version = matlab_ver.Version;52 % cmd=[...53 % '#!/bin/bash\n'...54 % 'source /etc/profile\n'...55 % 'module purge\n'...56 % 'module load matlab/' matlab_version '\n'...% CHOICE OF CURRENT MATLAB VERSION57 % 'matlab -nodisplay -nosplash -nojvm -singleCompThread -logfile ''' filelog{iprocess} ''' <<END_MATLAB\n'...% open a new Matlab session without display58 % 'addpath(''' path_series ''');\n'...59 % 'addpath(''' ActionPath ''');\n'...60 % '' ActionName '(''' filexml{iprocess} ''');\n'...% launch the Matlab function selected by the GUI 'series'61 % 'exit\n'...62 % 'END_MATLAB\n'];63 % end64 49 65 50 -
trunk/src/editxml.m
r1127 r1179 862 862 filedat=[]; 863 863 if ~isempty(list_uid) 864 filedat=get(t,list_uid(1)) 865 if isfield(filedat,'type') & isequal(filedat.type,'chardata') &isfield(filedat,'value')864 filedat=get(t,list_uid(1)); 865 if isfield(filedat,'type') && isequal(filedat.type,'chardata') && isfield(filedat,'value') 866 866 testsimple=1;%simple element 867 867 end … … 876 876 if isequal(attr.key,'source')% look for 'source' attribute 877 877 if isequal(attr.val,'file')%if the source is 'file', look for the path and open it 878 if isfield(filedat,'type') & isequal(filedat.type,'chardata') &isfield(filedat,'value')878 if isfield(filedat,'type') && isequal(filedat.type,'chardata') && isfield(filedat,'value') 879 879 cur_file=filedat.value; 880 880 uidparent=root_uid;%initialization … … 882 882 uidparent=parent(t,uidparent); 883 883 dirdat=get(t,uidparent); 884 if isfield(dirdat,'type') & isequal(dirdat.type,'element')& isfield(dirdat,'name')884 if isfield(dirdat,'type') && isequal(dirdat.type,'element') && isfield(dirdat,'name') 885 885 nbattrib_up= attributes(t,'length',uidparent); 886 886 for iattr_up=1:nbattrib_up … … 893 893 end 894 894 RootPath=fileparts(CurrentFile);%path to the current .xml file 895 cur_file=fullfile(RootPath,cur_file) 895 cur_file=fullfile(RootPath,cur_file); 896 896 set(handles.CurrentAttributes,'UserData',cur_file)%will be searched by uvmat 897 [ path,fil,ext]=fileparts(cur_file);897 [~,~,ext]=fileparts(cur_file); 898 898 if ~exist(cur_file,'file') 899 899 msgbox_uvmat('ERROR',['non-existent link file' cur_file]) % A FAIRE: propose to updtate the .xml file … … 909 909 CurrentFile_Callback(handles.CurrentFile, [], handles) 910 910 else 911 if isequal(get(heditxml,'Tag'),'browser') ;%if editxml has been called as a browser911 if isequal(get(heditxml,'Tag'),'browser') %if editxml has been called as a browser 912 912 set(heditxml,'Tag','idle')% signal for uvmat browser 913 913 else … … 925 925 %list subtree 926 926 if ~testsimple 927 list_element= [];927 list_element=cell(length(list_uid)); 928 928 for iline=1:length(list_uid) 929 929 element=get(t,list_uid(iline)); 930 if isfield(element,'type')& isequal(element.type,'element')930 if isfield(element,'type')&& isequal(element.type,'element') 931 931 list_element{iline,2}=element.name; 932 932 child_uid=children(t,list_uid(iline)); 933 933 subelem=get(t,child_uid); 934 if isfield(subelem,'type')& isfield(subelem,'value')& isequal(subelem.type,'chardata')934 if isfield(subelem,'type')&& isfield(subelem,'value') && isequal(subelem.type,'chardata') 935 935 data_read=subelem.value; 936 936 list_element{iline,3}=['= ' data_read]; 937 937 end 938 if iscell(subelem)| (isfield(subelem,'type')&isequal(subelem.type,'element'))938 if iscell(subelem)||(isfield(subelem,'type')&& isequal(subelem.type,'element')) 939 939 list_element{iline,1}='+ ';%sign for subtree existence 940 940 else … … 965 965 function update_ref_list(hh,xs_element,element,node,xs_subelem,subelem) 966 966 %----------------------------- 967 pref_col='';967 %pref_col=''; 968 968 key_col=''; 969 equal_sign='';969 %equal_sign=''; 970 970 val_col=''; 971 971 for iline=1:length(subelem) … … 1000 1000 global xs t 1001 1001 1002 export_list=get(handles.export_list,'String');1003 export_val=get(handles.export_list,'UserData');1002 %export_list=get(handles.export_list,'String'); 1003 %export_val=get(handles.export_list,'UserData'); 1004 1004 heditxml=get(handles.replicate,'parent'); 1005 1005 Data=get(heditxml,'UserData'); … … 1007 1007 hdataview=findobj(allchild(0),'Name','dataview'); 1008 1008 if isempty(hdataview) 1009 hdataview=dataview;1010 1009 return 1011 1010 end … … 1027 1026 ListRecords=ListRecords(Value); 1028 1027 end 1029 [ ListDevices,ListRecords,ListXml,List]=dir_scan(CurrentPath,ListExperiments,ListDevices,ListRecords);1028 [~,~,~,List]=dir_scan(CurrentPath,ListExperiments,ListDevices,ListRecords); 1030 1029 ListXml=get(hhdataview.ListXml,'String'); 1031 1030 Value=get(hhdataview.ListXml,'Value'); … … 1065 1064 % fill the root elements if absent 1066 1065 for index=2:length(uidlist) 1067 name_t=get(t,uidlist(index),'name') 1068 findstr=[findstr '/' name_t] 1069 uid=find(t_export,findstr) 1066 name_t=get(t,uidlist(index),'name'); 1067 findstr=[findstr '/' name_t]; 1068 uid=find(t_export,findstr); 1070 1069 if isempty(uid) 1071 1070 [t_export,uid_export(index)]=add(t_export,uid_export(index-1),'element',name_t); … … 1088 1087 for ilistxml=1:length(ListXml) 1089 1088 if isequal(FileName,ListXml{ilistxml}) 1090 xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName) 1089 xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName); 1091 1090 break 1092 1091 end -
trunk/src/script_readlvm.m
r1123 r1179 1 1 %% get the input file 2 project='/fsnet/project/coriolis/2016/16CREST'; 3 % if ~exist(project,'dir') 4 % project='U:\project\coriolis\2015\15MINI_MEDDY\PROBES';%windows 5 % end 2 project='/fsnet/project/coriolis/2024/24PLUME'; 6 3 fileinput=uigetfile_uvmat('pick an input file',project); 7 4 [Path,Name,Ext]=fileparts(fileinput); -
trunk/src/series.m
r1178 r1179 2221 2221 msgbox_uvmat('CONFIRMATION',[num2str(currJobIndex-1) ' jobs launched on queue ' qstat_Queue '.']) 2222 2222 case 'python' 2223 command = command_launch_python(filexml{iprocess});2223 command = ['python -m fluidimage.run_from_xml ' filexml{iprocess}]; 2224 2224 fprintf(['command:\n' command '\n\n']) 2225 2225 [status, result] = call_command_clean(command); -
trunk/src/series/beam_forming.m
r1127 r1179 147 147 time=(b/rsf+[0:A-1]/rsf); %b=250, rsf=10, 148 148 freq1=0.5;freq2=1.5; 149 [BB AA]=butter(4,[freq1 freq2]/rsf*2); .sback149 [BB AA]=butter(4,[freq1 freq2]/rsf*2); 150 150 151 151 for ii=1:length(nbvoie_reception)%=64 -
trunk/src/series/rdvision_check_time.m
r1178 r1179 243 243 end 244 244 copyfile_modif(filexml,timestamp,newxml) 245 % [nbfield2,msg]=copyfile_modif(filexml,timestamp,newxml); %copy the xml file in the upper folder245 246 246 [XmlData,errormsg]=imadoc2struct(newxml);% check reading of the new xml file 247 247 if ~isempty(errormsg) … … 267 267 268 268 269 270 % check the existence of the expected output image files (from the xml) 271 272 273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 274 %--------- reads a series of bin files 275 276 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 277 function [BinList,errormsg]=binread_rdv_series(PathDir,SeqData,SqbData,nbfield2,NomTypeNew) 278 % BINREAD_RDV Permet de lire les fichiers bin g???n???r???s par Hiris ??? partir du 279 % fichier seq associ???. 280 % [IMGS,TIMESTAMPS,NB_FRAMES] = BINREAD_RDV(FILENAME,FRAME_IDX) lit 281 % l'image d'indice FRAME_IDX de la s???quence FILENAME. 282 % 283 % Entr???es 284 % ------- 285 % FILENAME : Nom du fichier s???quence (.seq). 286 % FRAME_IDX : Indice de l'image ??? lire. Si FRAME_IDX vaut -1 alors la 287 % s???quence est enti???rement lue. Si FRAME_IDX est un tableau d'indices 288 % alors toutes les images d'incides correspondant sont lues. Si FRAME_IDX 289 % est un tableau vide alors aucune image n'est lue mais le nombre 290 % d'images et tous les timestamps sont renvoy???s. Les indices commencent ??? 291 % 1 et se termines ??? NB_FRAMES. 292 % 293 % Sorties 294 % ------- 295 % IMGS : Images de sortie. 296 % TIMESTAMPS : Timestaps des images lues. 297 % NB_FRAMES : Nombres d'images dans la s???quence. 298 NbBinFile=0; 299 BinSize=0; 300 fid=0; 301 errormsg=''; 302 BinList={}; 303 304 classname=sprintf('uint%d',SeqData.bytesperpixel*8); 305 306 classname=['*' classname]; 307 BitDepth=8*SeqData.bytesperpixel;%needed to write images (8 or 16 bits) 308 binrepertoire=fullfile(PathDir,SeqData.binrepertoire); 309 FileDir=SeqData.sequencename; 310 FileDir=regexprep(FileDir,'_Master_Dalsa_4M180$','');%suppress '_Master_Dalsa_4M180' 311 OutputDir=fullfile(PathDir,FileDir); 312 if ~exist(OutputDir,'dir') 313 % errormsg=[OutputDir ' already exist, delete it first']; 314 % return 315 % end 316 [s,errormsg]=mkdir(OutputDir); 317 318 if s==0 319 disp(errormsg) 320 return%not able to create new image dir 321 end 322 end 323 bin_file_counter=0; 324 for ii=1:SeqData.nb_frames 325 j1=[]; 326 if ~isequal(nbfield2,1) 327 j1=mod(ii-1,nbfield2)+1; 328 end 329 i1=floor((ii-1)/nbfield2)+1; 330 OutputFile=fullfile_uvmat(PathDir,FileDir,'img','.png',NomTypeNew,i1,[],j1);% TODO: set NomTypeNew from SeqData.mode 331 fname=fullfile(binrepertoire,sprintf('%s%.5d.bin',SeqData.binfile,SqbData(ii).file_idx)); 332 if exist(OutputFile,'file')% do not recreate existing image file 333 fid=0; 334 else 335 if fid==0 || ~strcmp(fname,fname_prev) % open the bin file if not in use 336 if fid~=0 337 fclose(fid);%close the previous bin file if relevant 338 end 339 [fid,msg]=fopen(fname,'rb'); 340 if isequal(fid,-1) 341 errormsg=['error in opening ' fname ': ' msg]; 342 return 343 else 344 disp([fname ' opened for reading']) 345 bin_file_counter=bin_file_counter+1; 346 BinList{bin_file_counter}=fname; 347 end 348 fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file 349 NbBinFile=NbBinFile+1;%counter of binary files (for checking purpose) 350 BinSize(NbBinFile)=0;% strat counter for new bin file 351 else 352 fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file 353 end 354 fname_prev=fname; 355 A=reshape(fread(fid,SeqData.width*SeqData.height,classname),SeqData.width,SeqData.height);%read the current image 356 A=A'; 357 BinSize(NbBinFile)=BinSize(NbBinFile)+SeqData.width*SeqData.height*SeqData.bytesperpixel*8; %record bits read 358 try 359 imwrite(A,OutputFile,'BitDepth',BitDepth) % case of 16 bit images 360 disp([OutputFile ' written']); 361 % [s,errormsg] = fileattrib(OutputFile,'-w','a'); %set images to read only '-w' for all users ('a') 362 % if ~s 363 % % disp_uvmat('ERROR',errormsg,checkrun); 364 % return 365 % end 366 catch ME 367 errormsg=ME.message; 368 return 369 end 370 end 371 end 372 if fid~=0 373 fclose(fid) 374 end 375 376 377 378 269 379 270 function [nbfield2,msg]=copyfile_modif(filexml,timestamp,newxml) 380 271 msg=''; -
trunk/src/series/sub_background.m
r1178 r1179 301 301 indselect=reshape(1:nbfield,NbSlice,[]); 302 302 for j_slice=1:NbSlice 303 indselect(j_slice,:)=j_slice: step*NbSlice:nbfield;% select file indices of the slice303 indselect(j_slice,:)=j_slice:NbSlice:nbfield;% select file indices of the slice 304 304 end 305 305 end -
trunk/src/series/test_civ.m
r1163 r1179 1 1 %'test_civ': test the civ fct on a simple shear produced by defomation of the input image 2 % use Matlab signal processing toolbox 2 3 %------------------------------------------------------------------------ 3 4 % Method: -
trunk/src/transform_field/ima_edge_detection.m
r1127 r1179 1 1 % 'ima_edge_detection': find edges 2 % requires MATLAB Image Processing toolbox 2 3 3 4 %------------------------------------------------------------------------ -
trunk/src/transform_field/ima_patch_detection.m
r1127 r1179 1 % 'ima_ edge_detection': find edges2 1 % 'ima_patch_detection': find patches 2 % requires the Matlab image processing toolbox 3 3 %------------------------------------------------------------------------ 4 4 %%%% Use the general syntax for transform fields with a single input and parameters %%%% -
trunk/src/uigetfile_uvmat.m
r1144 r1179 41 41 fileinput=''; %default file selection 42 42 if strcmp(title,'status_display') 43 option='status_display'; 44 else 45 option='browser'; 43 option='status_display';% use with the button 'Status Display' from the GUI 'series' 44 else 45 option='browser';% usual browser 46 46 end 47 47 InputDir=pwd;%look in the current work directory if the input file does not exist 48 48 InputFileName='';%default 49 49 if ischar(InputName) 50 if isempty(regexp(InputName,'^http://' ))%usual files50 if isempty(regexp(InputName,'^http://', 'once'))%usual files 51 51 if exist(InputName,'dir') 52 52 InputDir=InputName; … … 68 68 InputDir=[InputDir '\'];% append '\' for a correct action of dir 69 69 end 70 else 71 [InputDir,InputFileName,Ext]=fileparts(InputName); 72 end 73 end 74 70 else % files accessed on the web by Opendap 71 [InputDir,InputFileName]=fileparts(InputName); 72 end 73 end 74 75 %% Display the browser figure 75 76 hfig=findobj(allchild(0),'tag',option);%look for existing browser fig 76 77 if isempty(hfig)% create the browser fig if it does not exist … … 83 84 hfig=figure('name',option,'tag',option,'MenuBar','none','NumberTitle','off','Unit','points','Position',[Left,Bottom,Width,Height],'UserData',InputDir); 84 85 BackgroundColor=get(hfig,'Color'); 86 % text title 85 87 path_title=uicontrol('Style','text','Units','normalized', 'Position', [0.02 0.97 0.9 0.03],'BackgroundColor',BackgroundColor,'Tag','Path_title',... 86 88 'String','path:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left'); 87 htitlebox=uicontrol('Style','edit','Units','normalized', 'Position', [0.02 0.89 0.96 0.08],'tag','titlebox','Max',2,'BackgroundColor',[1 1 1],'Callback',@titlebox_Callback,... 89 % edit box for the current folder name 90 uicontrol('Style','edit','Units','normalized', 'Position', [0.02 0.89 0.96 0.08],'tag','titlebox','Max',2,'BackgroundColor',[1 1 1],'Callback',@titlebox_Callback,... 88 91 'String',InputDir,'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''titlebox'':current path'); 92 % button for backward move in the directory tree 89 93 uicontrol('Style','pushbutton','Tag','backward','Units','normalized','Position',[0.02 0.77 0.1 0.05],... 90 94 'String','<--','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@backward,'TooltipString','move backward'); … … 118 122 uicontrol('Style','togglebutton','Units','normalized', 'Position', [0.75 0.78 0.23 0.04],'tag','check_date','Callback',@dates_Callback,... 119 123 'String','show dates','FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''check_date'':press button to display dates'); 120 % uicontrol('Style','text','Units','normalized', 'Position', [0.37 0.8 0.35 0.03],'BackgroundColor',BackgroundColor,...121 % 'String','sort: ','FontUnits','points','FontSize',12,'FontWeight','bold','HorizontalAlignment','right');122 124 set(OK_button,'String','Open') 123 125 set(close_button,'String','Cancel') … … 126 128 end 127 129 refresh_GUI(findobj(hfig,'Tag','refresh'),InputFileName,FilterExt)% refresh the list of content of the current dir 128 if ~strcmp(option,'status_display') 130 if ~strcmp(option,'status_display') && strcmp(get(hfig,'Type'),'figure') 129 131 uiwait(hfig) 130 132 if ishandle(hfig) … … 140 142 function titlebox_Callback(hObject,event) 141 143 refresh_GUI(hObject) 144 145 146 %------------------------------------------------------------------------ 147 % --- launched by refreshing the display figure 148 function refresh_GUI(hObject,InputFileName,FilterExt) 149 %------------------------------------------------------------------------ 150 if ~exist('InputFileName','var') 151 InputFileName=''; 152 end 153 if ~exist('FilterExt','var') 154 FilterExt='*'; 155 end 156 if strcmp(FilterExt,'uigetdir') 157 FilterExt='*'; 158 end 159 hfig=get(hObject,'parent'); 160 hlist=findobj(hfig,'tag','list');% find the list object 161 set(hlist,'BackgroundColor',[1 1 0]) 162 drawnow 163 htitlebox=findobj(hfig,'tag','titlebox'); 164 DirName=get(htitlebox,'String'); 165 hsort_option=findobj(hfig,'tag','sort_option'); 166 167 %% case of file browser opened by Status Display in the GUI series 168 if strcmp(get(hfig,'Tag'),'status_display') % use with GUI series 169 hseries=findobj(allchild(0),'tag','series'); 170 hstatus=findobj(hseries,'tag','status'); 171 StatusData=get(hstatus,'UserData'); 172 TimeStart=0; 173 if isfield(StatusData,'TimeStart') 174 TimeStart=StatusData.TimeStart; 175 end 176 hlist=findobj(hfig,'tag','list'); 177 NbOutputFile=[]; 178 if isfield(StatusData,'NbOutputFile') 179 NbOutputFile=StatusData.NbOutputFile; 180 end 181 [ListFiles,NumFiles]=list_files(DirName,1,TimeStart);% list the directory content 182 183 % update the waitbar 184 hwaitbar=findobj(hfig,'tag','waitbar'); 185 if ~isempty(NbOutputFile) 186 BarPosition=get(hwaitbar,'Position'); 187 BarPosition(3)=0.9*max(0.01,NumFiles/NbOutputFile);% the bar width cannot be set to 0, set to 0.01 instead 188 set(hwaitbar,'Position',BarPosition) 189 end 190 %% case of usual browser 191 else %use as usual browser 192 sort_option='name'; 193 if strcmp(get(hsort_option,'Visible'),'on')&& isequal(get(hsort_option,'Value'),2) 194 sort_option='date'; 195 end 196 hcheck_date=findobj(hfig,'tag','check_date'); 197 ListFiles=list_files(DirName,get(hcheck_date,'Value'),sort_option,FilterExt);% list the directory content 198 end 199 if ~isempty(DirName) && isempty(ListFiles) 200 if isempty(regexp(DirName,'^http://', 'once'))%usual files 201 ListFiles='empty folder'; 202 else 203 ListFiles='address http:// not found'; 204 end 205 end 206 set(hlist,'String',ListFiles) 207 Value=[]; 208 if ~isempty(InputFileName) 209 Value=find(strcmp(InputFileName,ListFiles)); 210 end 211 if isempty(Value) 212 Value=1; 213 end 214 set(hlist,'Value',Value) 215 set(hlist,'BackgroundColor',[0.7 0.7 0.7]) 142 216 143 217 %------------------------------------------------------------------------ … … 158 232 list=get(hlist,'String'); 159 233 index=get(hlist,'Value'); 160 if ~isempty(regexp(list{index},'^\+/' ))234 if ~isempty(regexp(list{index},'^\+/', 'once')) 161 235 return % quit if a dir has been opened 162 236 end … … 167 241 SelectName=SelectName(1:ind_dot-1); 168 242 end 169 if isempty(regexp(DirName,'^http://' ))% if the input dir is not a web site (begins by http://)243 if isempty(regexp(DirName,'^http://', 'once'))% if the input dir is not a web site (begins by http://) 170 244 FullSelectName=fullfile(DirName,SelectName); 171 245 check_exist=exist(FullSelectName,'file'); … … 201 275 end 202 276 203 %------------------------------------------------------------------------ 204 % --- launched by refreshing the display figure 205 function refresh_GUI(hObject,InputFileName,FilterExt) 206 %------------------------------------------------------------------------ 207 if ~exist('InputFileName','var') 208 InputFileName=''; 209 end 210 if ~exist('FilterExt','var') 211 FilterExt='*'; 212 end 213 if strcmp(FilterExt,'uigetdir') 214 FilterExt='*'; 215 end 216 hfig=get(hObject,'parent'); 217 hlist=findobj(hfig,'tag','list');% find the list object 218 set(hlist,'BackgroundColor',[1 1 0]) 219 drawnow 220 htitlebox=findobj(hfig,'tag','titlebox'); 221 DirName=get(htitlebox,'String'); 222 hsort_option=findobj(hfig,'tag','sort_option'); 223 % use with GUI series 224 if strcmp(get(hfig,'Tag'),'status_display') % use with GUI series 225 hseries=findobj(allchild(0),'tag','series'); 226 hstatus=findobj(hseries,'tag','status'); 227 StatusData=get(hstatus,'UserData'); 228 TimeStart=0; 229 if isfield(StatusData,'TimeStart') 230 TimeStart=StatusData.TimeStart; 231 end 232 hlist=findobj(hfig,'tag','list'); 233 testrecent=0; 234 NbOutputFile=[]; 235 if isfield(StatusData,'NbOutputFile') 236 NbOutputFile=StatusData.NbOutputFile; 237 NbOutputFile_str=num2str(NbOutputFile); 238 end 239 [ListFiles,NumFiles]=list_files(DirName,1,TimeStart);% list the directory content 240 241 % update the waitbar 242 hwaitbar=findobj(hfig,'tag','waitbar'); 243 if ~isempty(NbOutputFile) 244 BarPosition=get(hwaitbar,'Position'); 245 BarPosition(3)=0.9*max(0.01,NumFiles/NbOutputFile);% the bar width cannot be set to 0, set to 0.01 instead 246 set(hwaitbar,'Position',BarPosition) 247 end 248 else %use as usual browser 249 sort_option='name'; 250 if strcmp(get(hsort_option,'Visible'),'on')&& isequal(get(hsort_option,'Value'),2) 251 sort_option='date'; 252 end 253 hcheck_date=findobj(hfig,'tag','check_date'); 254 [ListFiles,NumFiles]=list_files(DirName,get(hcheck_date,'Value'),sort_option,FilterExt);% list the directory content 255 end 256 257 set(hlist,'String',ListFiles) 258 Value=[]; 259 if ~isempty(InputFileName) 260 Value=find(strcmp(InputFileName,ListFiles)); 261 end 262 if isempty(Value) 263 Value=1; 264 end 265 set(hlist,'Value',Value) 266 set(hlist,'BackgroundColor',[0.7 0.7 0.7]) 267 268 %------------------------------------------------------------------------ 277 278 %------------------------------------------------------------------------ 269 279 % --- launched by selecting an item on the file list 270 280 %------------------------------------------------------------------------ … … 282 292 283 293 284 %------------------------------------------------------------------------ 294 %------------------------------------------------------------------------ 285 295 % --- launched by selecting an item on the file list 286 296 function list_Callback(option,filter_ext,hObject,event) … … 288 298 hfig=get(hObject,'parent');%handle of the fig 289 299 set(hObject,'BackgroundColor',[1 1 0])% paint list in yellow to indicate action 290 300 drawnow 291 301 list=get(hObject,'String'); 292 302 index=get(hObject,'Value'); 293 303 294 htitlebox=findobj(hfig,'tag','titlebox'); % display the new dir name 304 htitlebox=findobj(hfig,'tag','titlebox'); % display the new dir name 295 305 DirName=get(htitlebox,'String'); 296 CheckSubDir=~isempty(regexp(list{index},'^\+' ));306 CheckSubDir=~isempty(regexp(list{index},'^\+', 'once')); 297 307 SelectName=regexprep(list{index},'^\+/','');% remove the +/ used to mark dir 298 308 ind_dot=regexp(SelectName,'\s*\.\.\.');%remove what is beyond '...' … … 303 313 FullSelectName=fileparts(DirName); 304 314 else 305 if isempty(regexp(DirName,'^http://' ))% usual files315 if isempty(regexp(DirName,'^http://', 'once'))% usual files 306 316 FullSelectName=fullfile(DirName,SelectName); 307 317 else … … 321 331 end 322 332 hcheck_date=findobj(hfig,'tag','check_date'); 323 333 324 334 ListFiles=list_files(FullSelectName,get(hcheck_date,'Value'),sort_option,filter_ext);% list the directory content 325 335 set(hObject,'Value',1) … … 330 340 set(hObject,'BackgroundColor',[0.7 0.7 0.7])% paint list in grey to indicate action end 331 341 332 %------------------------------------------------------------------------- 342 %------------------------------------------------------------------------- 333 343 % list the content of a directory 334 344 function [ListFiles,NumFiles]=list_files(DirName,check_date,sort_option,filter_ext) 335 345 %------------------------------------------------------------------------- 346 ListFiles={};%default 347 NumFiles=0; 336 348 ListStruct=dir_uvmat(DirName);% get structure of the current directory 337 349 if ~isstruct(ListStruct) 338 350 return 339 351 end 340 352 341 353 date_index=find(strcmp('datenum',fieldnames(ListStruct)));% find the index of the date displayin the list of fields 342 NumFiles=0; %default343 354 if numel(ListStruct)<1 % case of empty dir 344 ListFiles={};345 355 return 346 356 end 347 357 ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray 348 358 ListFiles=ListCells(1,:);%list of file names 349 index_dir= find(strcmp('isdir',fieldnames(ListStruct)));359 index_dir=strcmp('isdir',fieldnames(ListStruct)); 350 360 check_dir=cell2mat(ListCells(index_dir,:));% =1 for directories, =0 for files 351 361 ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display … … 362 372 check_dir=check_dir(check_keep); 363 373 end 364 check_emptydate=cellfun('isempty',ListCells(date_index,:));% = 1 if datenum undefined 365 ListCells(date_index, find(check_emptydate))={0}; %set to 0 the empty dates374 check_emptydate=cellfun('isempty',ListCells(date_index,:));% = 1 if datenum undefined 375 ListCells(date_index,check_emptydate)={0}; %set to 0 the empty dates 366 376 ListDates=cell2mat(ListCells(date_index,:));%list of numerical dates 367 377 if isnumeric(sort_option) … … 369 379 NumFiles=numel(find(~check_old&~check_dir)); 370 380 end 371 if ~isempty(find(~check_dir ))372 ListDates(check_dir)=max(ListDates(~check_dir))+1000; % we set the dir in front381 if ~isempty(find(~check_dir, 1)) 382 ListDates(check_dir)=max(ListDates(~check_dir))+1000; % we set the dir in front 373 383 end 374 384 375 385 if isnumeric(sort_option)|| strcmp(sort_option,'date') 376 [ tild,index_sort]=sort(ListDates,2,'descend');% sort files by chronological order, recent first, put the dir first in the list377 else 378 [ tild,index_sort]=sort(check_dir,2,'descend');% put the dir first in the list386 [~,index_sort]=sort(ListDates,2,'descend');% sort files by chronological order, recent first, put the dir first in the list 387 else 388 [~,index_sort]=sort(check_dir,2,'descend');% put the dir first in the list 379 389 end 380 390 ListFiles=ListFiles(index_sort);% list of names sorted by alaphabetical order and dir and file … … 447 457 function CheckImage=isimage(filename) 448 458 449 [ pp,name,ext]=fileparts(filename);459 [~,~,ext]=fileparts(filename); 450 460 CheckImage=~isempty(ext)&&~strcmp(ext,'.')&&~isempty(imformats(regexprep(ext,'^.',''))); -
trunk/src/uvmat.m
r1178 r1179 461 461 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 462 462 if isempty(regexp(RootPath,'^http://'))%usual files 463 oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];463 oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; 464 464 else %Opendap 465 465 oldfile=[RootPath '/' SubDir '/' RootFile FileIndices FileExt]; … … 484 484 % -------------------------------------------------------------------- 485 485 function MenuBrowseOpendap_Callback(hObject, eventdata, handles) 486 486 oldfile=get(hObject,'Label'); 487 487 fileinput=uigetfile_uvmat('pick an input file',oldfile); 488 488 hh=dir(fileinput); … … 710 710 delete(figure_movie)%delete existing figure_movie 711 711 end 712 figure_movie=figure;% create a new movie figure 712 figure_movie=figure;% create a new movie figure 713 713 nbpix=[640 480];% resolution VGA 714 714 set(figure_movie,'name','figure_movie','Position',[1 1 nbpix]) … … 2428 2428 TimeName='';%default 2429 2429 CheckIndexing=false;%default 2430 XmlData=[]; 2430 2431 if isempty(XmlFileName) 2431 2432 set(handles.view_xml,'Visible','off') … … 2560 2561 2561 2562 %% read parameters (time, geometric calibration..) from a documentation file (.xml advised) 2562 XmlData.GeometryCalib=[];%default2563 %XmlData.GeometryCalib=[];%default 2563 2564 if input_line==1 2564 2565 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
Note: See TracChangeset
for help on using the changeset viewer.