Changeset 1184
- Timestamp:
- Nov 6, 2025, 7:03:02 PM (4 weeks ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 15 edited
-
command_launch_matlab.m (modified) (1 diff)
-
get_file_index.m (modified) (1 diff)
-
imadoc2struct.m (modified) (3 diffs)
-
index2filename.m (modified) (2 diffs)
-
keyboard_callback.m (modified) (1 diff)
-
phys_XYZ.m (modified) (4 diffs)
-
read_GUI.m (modified) (1 diff)
-
read_field.m (modified) (1 diff)
-
read_multimadoc.m (modified) (1 diff)
-
rename_indexing.m (modified) (1 diff)
-
series.m (modified) (31 diffs)
-
series/beam_forming.m (modified) (1 diff)
-
series/bed_scan.m (modified) (7 diffs)
-
series/bed_scan_init.m (added)
-
uvmat.fig (modified) (previous)
-
uvmat.m (modified) (55 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/command_launch_matlab.m
r1179 r1184 36 36 'matlab -nodisplay -nosplash -nojvm ''' ThreadOption ''' -logfile ''' filelog ''' <<END_MATLAB\n'...%launch the new Matlab session without display 37 37 'addpath(''' path_uvmat ''');\n'... 38 'addpath(''' ActionPath ''');\n']; 38 'current_dir=pwd;\n'... % current working dir 39 'cd(''' ActionPath ''');\n'... 40 'h_fun=str2func(''' ActionName ''');\n'...% create the function handle for the function ActionName 41 'cd(current_dir);\n']; 42 % 'addpath(''' ActionPath ''');\n']; 39 43 for iprocess=1:numel(inputxml) 40 cmd=[cmd '' ActionName '(''' inputxml{iprocess} ''');\n']; 44 % cmd=[cmd '' ActionName '(''' inputxml{iprocess} ''');\n']; 45 cmd=[cmd ' h_fun (''' inputxml{iprocess} ''');\n']; 41 46 end 42 47 cmd=[cmd 'exit\n' 'END_MATLAB\n']; -
trunk/src/get_file_index.m
r1172 r1184 46 46 switch r.mode 47 47 case 'Di=' % case 'series(Di)') 48 i1=ref_i-str2 num(r.num1);49 i2=ref_i+str2 num(r.num2);48 i1=ref_i-str2double(r.num1); 49 i2=ref_i+str2double(r.num2); 50 50 case 'Dj=' % case 'series(Dj)' 51 j1=ref_j-str2 num(r.num1);52 j2=ref_j+str2 num(r.num2);51 j1=ref_j-str2double(r.num1); 52 j2=ref_j+str2double(r.num2); 53 53 case '-' % case 'bursts' 54 j1=str2 num(r.num1)*ones(size(ref_i));55 j2=str2 num(r.num2)*ones(size(ref_i));54 j1=str2double(r.num1)*ones(size(ref_i)); 55 j2=str2double(r.num2)*ones(size(ref_i)); 56 56 end 57 57 end -
trunk/src/imadoc2struct.m
r1183 r1184 34 34 35 35 function [s,errormsg]=imadoc2struct(ImaDoc,varargin) 36 %% default input and output 37 errormsg='';%default 38 s=[]; 36 37 s=[]; %default output 39 38 40 39 %% opening the xml file 41 [tild,tild,FileExt]=fileparts(ImaDoc);42 43 40 if nargin ==1% no additional input variable beyond 'ImaDoc' 44 41 [s,Heading,errormsg]=xml2struct(ImaDoc);% convert the whole xml file in a structure s … … 56 53 return 57 54 end 55 58 56 %% reading timing 59 57 if isfield(s,'Camera') … … 67 65 end 68 66 69 70 function [s,errormsg]=read_subtree(subt,Data,NbOccur,NumTest)71 %--------------------------------------------------72 s=[];%default73 errormsg='';74 head_element=get(subt,1,'name');75 cont=get(subt,1,'contents');76 if ~isempty(cont)77 for ilist=1:length(Data)78 uid_key=find(subt,[head_element '/' Data{ilist}]);79 if ~isequal(length(uid_key),NbOccur(ilist))80 errormsg=['wrong number of occurence for ' Data{ilist}];81 return82 end83 for ival=1:length(uid_key)84 val=get(subt,children(subt,uid_key(ival)),'value');85 if ~NumTest(ilist)86 eval(['s.' Data{ilist} '=val;']);87 else88 eval(['s.' Data{ilist} '=str2double(val);'])89 end90 end91 end92 end93 94 95 %--------------------------------------------------96 % read an xml element97 function val=get_value(t,label,default)98 %--------------------------------------------------99 val=default;100 uid=find(t,label);%find the element iud(s)101 if ~isempty(uid) %if the element named label exists102 uid_child=children(t,uid);%find the children103 if ~isempty(uid_child)104 data=get(t,uid_child,'type');%get the type of child105 if iscell(data)% case of multiple element106 for icell=1:numel(data)107 val_read=str2num(get(t,uid_child(icell),'value'));108 if ~isempty(val_read)109 val(icell,:)=val_read;110 end111 end112 % val=val';113 else % case of unique element value114 val_read=str2num(get(t,uid_child,'value'));115 if ~isempty(val_read)116 val=val_read;117 else118 val=get(t,uid_child,'value');%char string data119 end120 end121 end122 end123 124 %------------------------------------------------------------------------125 %'read_imatext': reads the .civ file for image documentation (obsolete)126 % fileinput: name of the documentation file127 % time: matrix of times for the set of images128 %pxcmx: scale along x in pixels/cm129 %pxcmy: scale along y in pixels/cm130 function [error,time,TimeUnit,mode,npx,npy,GeometryCalib]=read_imatext(fileinput)131 %------------------------------------------------------------------------132 error='';%default133 time=[]; %default134 TimeUnit='s';135 mode='pairs';136 npx=[]; %default137 npy=[]; %default138 GeometryCalib=[];139 if ~exist(fileinput,'file'), error=['image doc file ' fileinput ' does not exist']; return;end;%input file does not exist140 dotciv=textread(fileinput);141 sizdot=size(dotciv);142 if ~isequal(sizdot(1)-8,dotciv(1,1));143 error=1; %inconsistent number of bursts144 end145 nbfield=sizdot(1)-8;146 npx=(dotciv(2,1));147 npy=(dotciv(2,2));148 pxcmx=(dotciv(6,1));% pixels/cm in the .civ file149 pxcmy=(dotciv(6,2));150 % nburst=dotciv(3,1); % nbre of bursts151 abs_time1=dotciv([9:nbfield+8],2);152 dtime=dotciv(5,1)*(dotciv([9:nbfield+8],[3:end-1])+1);153 timeshift=[abs_time1 dtime];154 time=cumsum(timeshift,2);155 GeometryCalib.CalibrationType='rescale';156 GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];157 GeometryCalib.Tx=0;158 GeometryCalib.Ty=0;159 GeometryCalib.Tz=1;160 GeometryCalib.dpx=1;161 GeometryCalib.dpy=1;162 GeometryCalib.sx=1;163 GeometryCalib.Cx=0;164 GeometryCalib.Cy=0;165 GeometryCalib.f=1;166 GeometryCalib.kappa1=0;167 GeometryCalib.CoordUnit='cm'; -
trunk/src/index2filename.m
r1180 r1184 1 % get the file name and frame index froma set of multimage files (e.g. from PCO camera)1 % translate logical indices i1, j1, into file name and frame index in a set of multimage files (e.g. from PCO camera) 2 2 %------------------------------------------------------------------------ 3 % [RootFile,F ileIndexString,FrameIndex]=index2filename(FileSeries,i1,j1,NbField_j)3 % [RootFile,FrameIndex]=index2filename(FileSeries,i1,j1,NbField_j) 4 4 % 5 5 % OUTPUT: 6 % RootFile, FileIndexString: name of the multimage file = [RootFile FileIndexString FileExt]7 % FrameIndex: index in the multimage file 6 % FileName: name of the multimage file = [RootFile FileIndexString FileExt] 7 % FrameIndex: index in the multimage file FileName 8 8 % 9 9 % INPUT: 10 % FileSeries: structure read from the xml file, defining the themultifile organisation of images11 % i1: global frame index i, or single concatenated index vector (then no furtherinput j1 and NbField_j10 % FileSeries: structure read from the xml file, defining the multifile organisation of images 11 % i1: global frame index i, or single concatenated index vector (then no input j1 and NbField_j 12 12 % j1: j index 13 13 % NbField_j: nbre of j indices in the index matrix … … 55 55 FileName=FileSeries.FileName{FileIndex}; 56 56 end 57 58 % switch FileSeries.Convention59 % case 'PCO'60 % RootFile=FileSeries.RootName;61 % FileIndex=floor(i_vector/FileSeries.NbFramePerFile);62 % if FileIndex>063 % RootFile=[RootFile '@'];64 % FileIndexString=num2str(FileIndex,'%04d');65 % end66 57 FrameIndex=mod(i_vector-1,FileSeries.NbFramePerFile)+1; 67 58 end -
trunk/src/keyboard_callback.m
r1183 r1184 90 90 set(handleshaxes.movie_pair,'value',0); 91 91 set(handleshaxes.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off' 92 set(handleshaxes. i2,'String','')% the second i index display is suppressed93 set(handleshaxes. j2,'String','')% the second j index display is suppressed92 set(handleshaxes.num_i2,'String','')% the second i index display is suppressed 93 set(handleshaxes.num_j2,'String','')% the second j index display is suppressed 94 94 set(handleshaxes.Dt_txt,'String','')% the time interval indication is suppressed 95 95 end -
trunk/src/phys_XYZ.m
r1127 r1184 1 1 %------------------------------------------------------------------------ 2 2 %'phys_XYZ':transforms image (px) to real world (phys) coordinates using geometric calibration parameters 3 % function [Xphys,Yphys,Zphys]=phys_XYZ(Calib, X,Y,Zindex)3 % function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,Slice,X,Y,Zindex) 4 4 % 5 5 %OUTPUT: … … 7 7 %INPUT: 8 8 % Calib: Matlab structure containing the calibration parameters (pinhole camera model, see 9 % http://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/wiki/UvmatHelp#GeometryCalib) and the 10 % parameters describing the illumination plane(s) 9 % http://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/wiki/UvmatHelp#GeometryCalib) 11 10 % .Tx_Ty_Tz: translation (3 phys coordinates) defining the origine of the camera frame 12 11 % .R : rotation matrix from phys to camera frame 13 12 % .fx_fy: focal length along each direction of the image 13 % Slice: Matlab structure containing the parameters describing the position and inclination of the illumination plane 14 14 % X, Y: vectors of X and Y image coordinates 15 % ZIndex : index defining the current illumination plane in a volume scan15 % ZIndex (if needed): index defining the current illumination plane in a volume scan,=1 by default 16 16 17 17 %======================================================================= … … 37 37 testangle=0;% =1 if the illumination plane is tilted with respect to the horizontal plane Xphys Yphys 38 38 test_refraction=0;% =1 if the considered points are viewed through an horizontal interface (located at z=Calib.InterfaceCoord(3)') 39 if ~exist('X','var')||~exist('Y','var') 40 Xphys=[]; 41 Yphys=[];%default 42 return 43 end 39 44 Zphys=0; %default output 45 40 46 if isempty(Slice) 41 47 Slice=Calib;%old convention < 2022 48 elseif ~isfield(Slice,'SliceCoord')% bad input 49 Xphys=[]; 50 Yphys=[];% bad input 51 return 42 52 end 43 53 if exist('Zindex','var')&& isequal(Zindex,round(Zindex))&& Zindex>0 && isfield(Slice,'SliceCoord')&&size(Slice.SliceCoord,1)>=Zindex … … 59 69 Z0virt=0; 60 70 end 61 if ~exist('X','var')||~exist('Y','var') 62 Xphys=[]; 63 Yphys=[];%default 64 return 65 end 71 66 72 %coordinate transform 67 73 if ~isfield(Calib,'fx_fy') -
trunk/src/read_GUI.m
r1127 r1184 43 43 switch object_type 44 44 case 'uipanel' 45 eval(['struct.' tag '=read_GUI(hchild(ichild));'])45 struct.(tag)= read_GUI(hchild(ichild)); 46 46 case 'uicontrol' 47 47 object_style=get(hchild(ichild),'Style'); -
trunk/src/read_field.m
r1180 r1184 58 58 errormsg=''; 59 59 if isempty(regexp(FileName,'^http://', 'once'))&& ~exist(FileName,'file') 60 errormsg= ['input file ' FileName ' does not exist'];60 errormsg='input file does not exist'; 61 61 return 62 62 end -
trunk/src/read_multimadoc.m
r1152 r1184 35 35 warnmsg=''; 36 36 if ischar(RootPath) 37 RootPath={RootPath};SubDir={SubDir}; RootFile={RootFile};FileExt={FileExt};37 RootPath={RootPath};SubDir={SubDir};%RootFile={RootFile};FileExt={FileExt}; 38 38 end 39 39 nbview=numel(RootPath); -
trunk/src/rename_indexing.m
r1078 r1184 11 11 NewName=[NewName '_1'];%add the index 1 12 12 else 13 newindex=str2 num(NewName(rr:end))+1; %increment the index by 113 newindex=str2double(NewName(rr:end))+1; %increment the index by 1 14 14 NewName=[NewName(1:rr-1) num2str(newindex)]; 15 15 end -
trunk/src/series.m
r1183 r1184 134 134 %% Read the parameter file series.xml, or created from series.xml.default if it does not exist 135 135 SeriesData=[]; 136 [path_series,name,ext]=fileparts(which('series'));% path to the GUI series136 path_series=fileparts(which('series'));% path to the GUI series 137 137 xmlfile=fullfile(path_series,'series.xml'); 138 138 if ~exist(xmlfile,'file') … … 157 157 NbBuiltinAction=numel(ActionList); 158 158 set(handles.Action,'UserData',NbBuiltinAction) 159 path_series_fct=fullfile(path_series,'series');%path of the functions in subdirectroy 'series'160 [path_series ,name,ext]=fileparts(which('series')); % path to the GUI series159 %path_series_fct=fullfile(path_series,'series');%path of the functions in subdirectroy 'series' 160 [path_series]=fileparts(which('series')); % path to the GUI series 161 161 path_series_fct=fullfile(path_series,'series'); % path of the functions in subdirectroy 'series' 162 162 ActionExtList={'.m';'.sh';'fluidimage'}; % default choice of extensions (Matlab fct .m or compiled version .sh … … 166 166 if isfield(SeriesData.ClusterParam, 'ExistenceTest') 167 167 oarcommand=SeriesData.ClusterParam.ExistenceTest; 168 [s,w]=system(oarcommand); % look for cluster system presence168 s=system(oarcommand); % look for cluster system presence 169 169 if isequal(s,0)% cluster detected 170 170 RunModeList=[RunModeList;{'cluster'}]; … … 275 275 %% fill the list of input file series 276 276 InputTable=[{Param.InputFile.RootPath},{Param.InputFile.SubDir},{Param.InputFile.RootFile},{Param.InputFile.NomType},{Param.InputFile.FileExt}]; 277 if isempty(find(cellfun('isempty',InputTable)==0 )) % if there is no input file, do not introduce input info277 if isempty(find(cellfun('isempty',InputTable)==0,1)) % if there is no input file, do not introduce input info 278 278 set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refresh is needed 279 279 return 280 280 end 281 TimeTable=[{Param.InputFile.TimeName},{[]},{[]},{[]},{[]}];281 % TimeTable=[{Param.InputFile.TimeName},{[]},{[]},{[]},{[]}]; 282 282 if isfield(Param.InputFile,'RootPath_1') 283 283 InputTable=[InputTable;[{Param.InputFile.RootPath_1},{Param.InputFile.SubDir_1},{Param.InputFile.RootFile_1},{Param.InputFile.NomType_1},{Param.InputFile.FileExt_1}]]; 284 TimeTable=[TimeTable; [{Param.InputFile.TimeName_1},{[]},{[]},{[]},{[]}]];284 % TimeTable=[TimeTable; [{Param.InputFile.TimeName_1},{[]},{[]},{[]},{[]}]]; 285 285 end 286 286 set(handles.InputTable,'Data',InputTable) … … 291 291 set(handles.Device,'String',[Device DeviceExt]) 292 292 set(handles.Experiment,'String',[Experiment ExperimentExt]) 293 if ~isempty(regexp(InputTable{1,1},'(^http://)|(^https://)' ))293 if ~isempty(regexp(InputTable{1,1},'(^http://)|(^https://)','once')) 294 294 set(handles.OutputPathBrowse,'Value',1)% an output folder needs to be specified for OpenDAP data 295 295 end … … 308 308 %% determine the selected reference field indices for pair display 309 309 310 [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(Param.InputFile.FileIndex); 311 if isempty(i1) 312 i1=1; 313 end 314 if isempty(i2) 315 i2=i1; 316 end 310 % [~,~,~,i1,i2,j1,j2]=fileparts_uvmat(Param.InputFile.FileIndex); 311 i1=1;j1=1;%default 312 if isfield(Param,'i1') 313 i1=Param.i1; 314 end 315 if isfield(Param,'j1') 316 j1=Param.j1; 317 end 318 if isfield(Param,'i2') 319 i2=Param.i2; 320 end 321 if isfield(Param,'j2') 322 j2=Param.j2; 323 end 324 317 325 ref_i=floor((i1+i2)/2); % reference image number corresponding to the file 318 326 % set(handles.num_ref_i,'String',num2str(ref_i)); … … 609 617 %% update MinIndex_i and MaxIndex_i if the input table content has been reduced in line nbre 610 618 MinIndex_i_table=get(handles.MinIndex_i,'Data'); % retrieve the min indices in the table MinIndex 611 if ~isempty(MinIndex_i_table)612 619 set(handles.MinIndex_i,'Data',MinIndex_i_table(1:nbview,:)); 613 end614 620 MinIndex_j_table=get(handles.MinIndex_j,'Data'); % retrieve the min indices in the table MinIndex 615 if ~isempty(MinIndex_j_table)616 621 set(handles.MinIndex_j,'Data',MinIndex_j_table(1:nbview,:)); 617 end618 622 MaxIndex_i_table=get(handles.MaxIndex_i,'Data'); % retrieve the min indices in the table MinIndex 619 if ~isempty(MaxIndex_i_table) 623 620 624 set(handles.MaxIndex_i,'Data',MaxIndex_i_table(1:nbview,:)); 621 end622 625 MaxIndex_j_table=get(handles.MaxIndex_j,'Data'); % retrieve the min indices in the table MinIndex 623 if ~isempty(MaxIndex_j_table)624 626 set(handles.MaxIndex_j,'Data',MaxIndex_j_table(1:nbview,:)); 625 end626 627 PairString=get(handles.PairString,'Data'); % retrieve the min indices in the table MinIndex 627 if ~isempty(PairString)628 628 set(handles.PairString,'Data',PairString(1:nbview,:)); 629 end630 629 TimeTable=get(handles.TimeTable,'Data'); % retrieve the min indices in the table MinIndex 631 if ~isempty(TimeTable)632 630 set(handles.TimeTable,'Data',TimeTable(1:nbview,:)); 633 end634 631 635 632 %% set length of waitbar … … 861 858 862 859 %% display the min and max indices for the whole file series 863 if size(i1_series,2)==2 && min(min(i1_series(:,1,:)))==0 860 if isempty(i1_series) 861 MinIndex_j=1;MaxIndex_j=1;MinIndex_i=1;MaxIndex_i=1; 862 elseif size(i1_series,2)==2 && min(min(i1_series(:,1,:)))==0 864 863 MinIndex_j=1; % index j set to 1 by default 865 864 MaxIndex_j=1; … … 988 987 XmlData=[]; 989 988 check_calib=0; 990 991 989 XmlFileName=find_imadoc(InputTable{iview,1},InputTable{iview,2}); 992 990 if ~isempty(XmlFileName) … … 996 994 end 997 995 % read time if available 998 if isfield(XmlData,'Time') && strcmp(FileInfo.FieldType,'image')996 if isfield(XmlData,'Time') 999 997 Time=XmlData.Time; 1000 998 TimeName='xml'; … … 1310 1308 end 1311 1309 PairString=get(handles.PairString,'Data'); 1312 ref_i_1=str2num(get(handles.num_first_i,'String')); % first reference index 1313 ref_i_2=str2num(get(handles.num_last_i,'String')); % last reference index 1314 ref_j_1=[];ref_j_2=[]; 1310 ref_i_1=str2double(get(handles.num_first_i,'String')); % first reference index 1311 if isnan(ref_i_1) 1312 ref_i_1=1; 1313 end 1314 ref_i_2=str2double(get(handles.num_last_i,'String')); % last reference index 1315 if isnan(ref_i_2) 1316 ref_i_2=1; 1317 end 1318 ref_j_1=NaN;ref_j_2=NaN; 1315 1319 if strcmp(get(handles.num_first_j,'Visible'),'on') 1316 ref_j_1=str2num(get(handles.num_first_j,'String'));1317 ref_j_2=str2num(get(handles.num_last_j,'String'));1320 ref_j_1=str2double(get(handles.num_first_j,'String')); 1321 ref_j_2=str2double(get(handles.num_last_j,'String')); 1318 1322 end 1319 1323 [i1_1,i2_1,j1_1,j2_1] = get_file_index(ref_i_1,ref_j_1,PairString); … … 1429 1433 1430 1434 function errormsg=launch_action(handles) 1431 errormsg=''; % default1435 %errormsg=''; % default 1432 1436 1433 1437 %% read the data on the GUI series … … 1637 1641 end 1638 1642 end 1639 [ xx,ExpName]=fileparts(Param.InputTable{1,1});1640 Param.IndexRange.first_i=str2 num(get(handles.num_first_i,'String'));%reset the firrst_i and last_i for multiple experiments, modified by the splitting into NbProcess1641 Param.IndexRange.last_i=str2 num(get(handles.num_last_i,'String'));1643 [~,ExpName]=fileparts(Param.InputTable{1,1}); 1644 Param.IndexRange.first_i=str2double(get(handles.num_first_i,'String'));%reset the firrst_i and last_i for multiple experiments, modified by the splitting into NbProcess 1645 Param.IndexRange.last_i=str2double(get(handles.num_last_i,'String')); 1642 1646 1643 1647 %% create the output data directory if needed, after checking its existence … … 1655 1659 else 1656 1660 PathExpOut=fullfile(PathOut,get(handles.Experiment,'String')); 1657 PathExpDeviceOut=fullfile(PathExpOut,get(handles.Device,'String')) 1661 PathExpDeviceOut=fullfile(PathExpOut,get(handles.Device,'String')); 1658 1662 end 1659 1663 if ~exist(PathExpOut,'dir') 1660 [ tild,msg1]=mkdir(PathExpOut);1664 [~,msg1]=mkdir(PathExpOut); 1661 1665 if ~strcmp(msg1,'') 1662 1666 errormsg=['cannot create ' PathExpOut ': ' msg1]; % error message for directory creation … … 1665 1669 end 1666 1670 if ~exist(PathExpDeviceOut,'dir') 1667 [ tild,msg1]=mkdir(PathExpDeviceOut);1671 [~,msg1]=mkdir(PathExpDeviceOut); 1668 1672 if ~strcmp(msg1,'') 1669 1673 errormsg=['cannot create ' PathExpDeviceOut ': ' msg1]; % error message for directory creation … … 1710 1714 OutputDir=fullfile(PathExpDeviceOut,[Param.OutputSubDir Param.OutputDirExt]); % full name (with path) of output directory 1711 1715 if check_create % create output directory if it does not exist 1712 [ tild,msg1]=mkdir(OutputDir);1716 [~,msg1]=mkdir(OutputDir); 1713 1717 if ~strcmp(msg1,'') 1714 1718 errormsg=['cannot create ' OutputDir ': ' msg1]; % error message for directory creation … … 1784 1788 else 1785 1789 ref_j=first_j:incr_j:last_j; 1786 [ tild,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:)));1790 [~,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:))); 1787 1791 ref_i=ref_i-1; 1788 1792 ref_i=ref_i(ref_i>=first_i & ref_i<=last_i); … … 1792 1796 ref_i=first_i:incr_i:last_i; 1793 1797 if isempty(incr_j)% automatic finding of the existing j indices 1794 [ref_j,tild]=find(squeeze(SeriesData.i1_series{1}(1,:,:)));1798 ref_j=find(squeeze(SeriesData.i1_series{1}(1,:,:))); 1795 1799 ref_j=ref_j-1; 1796 1800 ref_j=ref_j(ref_j>=first_j & ref_j<=last_j); … … 1809 1813 else 1810 1814 answer=msgbox_uvmat('INPUT_TXT','estimate the CPU time(in minutes) for each value of index i:' ,''); 1811 CPUTime=str2 num(answer);1815 CPUTime=str2double(answer); 1812 1816 set(handles.num_CPUTime,'String',answer) 1813 1817 Param.Action.CPUTime=CPUTime; … … 2091 2095 cd(curdir) 2092 2096 else 2093 [ tild,msg1]=mkdir(DIR_CLUSTER);2097 [~,msg1]=mkdir(DIR_CLUSTER); 2094 2098 if ~strcmp(msg1,'') 2095 2099 errormsg=['cannot create ' DIR_CLUSTER ': ' msg1]; % error message for directory creation … … 2186 2190 cd(curdir) 2187 2191 else 2188 [ tild,msg1]=mkdir(DirSGE);2192 [~,msg1]=mkdir(DirSGE); 2189 2193 if ~strcmp(msg1,'') 2190 2194 errormsg=['cannot create ' DirSGE ': ' msg1]; % error message for directory creation … … 2211 2215 cmd=[cmd ActionFullName ' /softs/matlab ' filexml{imgsInJob(ii)} '\n']; 2212 2216 end 2213 [fid, message]= fopen([DirSGE '/job' num2str(currJobIndex) '.sh'], 'w');2217 fid = fopen([DirSGE '/job' num2str(currJobIndex) '.sh'], 'w'); 2214 2218 fprintf(fid, cmd); 2215 2219 fclose(fid); … … 2221 2225 fullfile([DirSGE '/job' num2str(currJobIndex) '.sh'])]; 2222 2226 fprintf(sge_command); % display in command line 2223 [ status, result] = system(sge_command);2227 [~, result] = system(sge_command); 2224 2228 fprintf(result); 2225 2229 currJobIndex = currJobIndex + 1; … … 2235 2239 command = ['python -m fluidimage.run_from_xml ' filexml{iprocess}]; 2236 2240 fprintf(['command:\n' command '\n\n']) 2237 [status, result] = call_command_clean(command);2241 % [status, result] = call_command_clean(command); 2238 2242 end 2239 2243 if exist(OutputDir,'dir') 2240 [ SUCCESS,MESSAGE,MESSAGEID] = fileattrib (OutputDir);2244 [~,MESSAGE] = fileattrib (OutputDir); 2241 2245 if MESSAGE.GroupWrite~=1 2242 2246 [success,msg] = fileattrib(OutputDir,'+w','g','s'); % allow writing access for the group of users, recursively in the folder … … 2393 2397 %% Put the first line of the selected Action fct as tooltip help 2394 2398 try 2395 [fid,errormsg]=fopen([fullfile(ActionPath,ActionName) '.m']);2399 fid=fopen([fullfile(ActionPath,ActionName) '.m']); 2396 2400 InputText=textscan(fid,'%s',1,'delimiter','\n'); 2397 2401 fclose(fid); … … 2877 2881 set(handles.FieldName,'String',[FieldListInit; FieldList; {'add_field...'}]); 2878 2882 if ~strcmp(GetFieldData.FieldOption,'civdata...') 2879 if ~isempty(regexp(FieldList{1},'^vec' ))2883 if ~isempty(regexp(FieldList{1},'^vec', 'once')) 2880 2884 set(handles.FieldName,'Value',1) 2881 2885 else … … 3031 3035 datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date); % dates of creation 3032 3036 end 3033 [ datenew,indsort2]=sort(datepair); % sort the multiplet by creation date3037 [~,indsort2]=sort(datepair); % sort the multiplet by creation date 3034 3038 ind_s=indsort2(1:end-1); % 3035 3039 ind_remove=[ind_remove ind_pairs(ind_s)]; % remove these indices, leave the last one … … 3058 3062 num_j1=meshgrid(num_j,ones(size(num_i1_line))); 3059 3063 num_j2=meshgrid(num_j,ones(size(num_i1_line))); 3060 [ xx,num_i1]=meshgrid(num_j,num_i1_line);3061 [ xx,num_i2]=meshgrid(num_j,num_i2_line);3064 [~,num_i1]=meshgrid(num_j,num_i1_line); 3065 [~,num_i2]=meshgrid(num_j,num_i2_line); 3062 3066 elseif isequal (mode,'series(Dj)')||isequal (mode,'bursts') 3063 3067 if isequal(mode,'bursts') %case of bursts (png_old or png_2D) … … 3200 3204 MaskTable=cell(NbView,2); 3201 3205 3202 RootPath=Param.InputTable{1,1};3206 %RootPath=Param.InputTable{1,1}; 3203 3207 first_j=[];% note that the function will propose to cover the whole range of indices 3204 3208 if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end 3205 last_j=[];3209 %last_j=[]; 3206 3210 if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end 3207 3211 PairString=''; … … 3214 3218 Param.InputTable{iview,5},Param.InputTable{iview,4},i1,i2,j1,j2); 3215 3219 3216 [FileInfo,VideoObject]=get_file_info(FirstFileName);3220 % [FileInfo,VideoObject]=get_file_info(FirstFileName); 3217 3221 3218 3222 … … 3422 3426 %% use a browser to choose the xml file containing the processing config 3423 3427 InputTable=get(handles.InputTable,'Data'); 3424 oldfile='';3425 if isempty(InputTable)3426 oldfile='';3427 else3428 3428 oldfile=InputTable{1,1}; % current path in InputTable 3429 end3430 3429 if isempty(oldfile) 3431 3430 % use a file name stored in prefdir -
trunk/src/series/beam_forming.m
r1179 r1184 1 %'beam_forming': create images from multi-array acoustic signal (cf. project Philippe Roux) 2 %------------------------------------------------------------------------ 3 % function ParamOut=beam_forming(Param) 4 %------------------------------------------------------------------------ 5 %%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%% 6 % 7 %OUTPUT 8 % ParamOut: sets options in the GUI series.fig needed for the function 9 % 10 %INPUT: 11 % In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series. 12 % In batch mode, Param is the name of the corresponding xml file containing the same information 13 % when Param.Action.RUN=0 (as activated when the current Action is selected 14 % in series), the function ouput paramOut set the activation of the needed GUI elements 15 % 16 % Param contains the elements:(use the menu bar command 'export/GUI config' in series to 17 % see the current structure Param) 18 % .InputTable: cell of input file names, (several lines for multiple input) 19 % each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension} 20 % .OutputSubDir: name of the subdirectory for data outputs 21 % .OutputDirExt: directory extension for data outputs 22 % .Action: .ActionName: name of the current activated function 23 % .ActionPath: path of the current activated function 24 % .ActionExt: fct extension ('.m', Matlab fct, '.sh', compiled Matlab fct 25 % .RUN =0 for GUI input, =1 for function activation 26 % .RunMode='local','background', 'cluster': type of function use 27 % 28 % .IndexRange: set the file or frame indices on which the action must be performed 29 % .FieldTransform: .TransformName: name of the selected transform function 30 % .TransformPath: path of the selected transform function 31 % .InputFields: sub structure describing the input fields withfields 32 % .FieldName: name(s) of the field 33 % .VelType: velocity type 34 % .FieldName_1: name of the second field in case of two input series 35 % .VelType_1: velocity type of the second field in case of two input series 36 % .Coord_y: name of y coordinate variable 37 % .Coord_x: name of x coordinate variable 38 % .ProjObject: %sub structure describing a projection object (read from ancillary GUI set_object) 39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 40 41 1 42 %======================================================================= 2 43 % Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France -
trunk/src/series/bed_scan.m
r1183 r1184 61 61 %======================================================================= 62 62 63 function ParamOut=bed_scan (Param)63 function ParamOut=bed_scan(Param) 64 64 65 65 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName or InputTable refreshed … … 67 67 ParamOut.NbViewMax=1;% max nbre of input file series (default , no limitation) 68 68 ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default) 69 ParamOut.WholeIndexRange='o ff';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)70 ParamOut.NbSlice= 1; %nbre of slices ('off' by default)69 ParamOut.WholeIndexRange='on';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) 70 ParamOut.NbSlice='off'; %nbre of slices ('off' by default) 71 71 ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default) 72 72 ParamOut.FieldName='one';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) … … 75 75 ParamOut.Mask='off';%can use mask option (option 'off'/'on', 'off' by default) 76 76 ParamOut.OutputDirExt='.bed';%set the output dir extension 77 ParamOut.OutputFileMode='NbSlice';% ='=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice 78 %check the type of the existence and type of the first input file: 79 Param.IndexRange.last_i=Param.IndexRange.first_i;%keep only the first index in the series 80 if isfield(Param.IndexRange,'first_j') 81 Param.IndexRange.last_j=Param.IndexRange.first_j; 82 end 83 filecell=get_file_series(Param); 84 if ~exist(filecell{1,1},'file') 85 msgbox_uvmat('WARNING','the first input file does not exist') 86 else 87 FileInfo=get_file_info(filecell{1,1}); 88 FileType=FileInfo.FileType; 89 if isempty(find(strcmp(FileType,{'image','multimage','mmreader','video'})))% =1 for images 90 msgbox_uvmat('ERROR',['bad input file type for ' mfilename ': an image is needed']) 91 end 92 end 93 return 77 ParamOut.OutputFileMode='NbInput_i';% ='=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice 78 return 94 79 end 95 80 … … 111 96 %% root input file names and nomenclature type (cell arrays with one element) 112 97 RootPath=Param.InputTable{1,1}; 113 98 SubDir=Param.InputTable{1,2}; 99 RootFile=Param.InputTable{1,3}; 100 NomType=Param.InputTable{1,4}; 101 FileExt=Param.InputTable{1,5}; 102 i_series=Param.IndexRange.first_i:Param.IndexRange.incr_i:Param.IndexRange.last_i; 103 j_series=Param.IndexRange.first_j:Param.IndexRange.incr_j:Param.IndexRange.last_j; 104 nbfield_i=numel(i_series); 105 nbfield_j=numel(j_series); 114 106 115 107 %% directory for output files … … 117 109 118 110 %% get the set of input file names (cell array filecell), and file indices 119 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);111 %[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 120 112 % filecell{iview,fileindex}: cell array representing the list of file names 121 113 % iview: line in the table corresponding to a given file series 122 % fileindex: file index within the file series, 123 % 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 114 % fileindex: file index within the file series, 115 % 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 124 116 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices 125 nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices) 126 nbfield_i=size(i1_series{1},2); %nb of fields for the i index 127 128 %% set of y positions 129 ycalib=[-51 -1 49];% calibration planes 130 y_scan=-51+(100/400)*(i1_series{1}-1);% transverse position given by the translating system: first view at y=-51, view 400 at y=+49 117 %nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices) 118 % nbfield_i=size(i1_series{1},2); %nb of fields for the i index 119 % 120 % nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices) 121 CheckVirtual=false; 122 if isfield(Param,'FileSeries')% virtual file indexing used (e.g. multitif images) 123 CheckVirtual=true; 124 end 125 126 %%%%%%%%%%%% END STANDARD PART %%%%%%%%%%%%fullfile( 127 % EDIT FROM HERE 128 %% load the initial scan 129 [RootRoot,CamName]=fileparts(RootPath); 130 RootRoot=fileparts(RootRoot); 131 CalibFolder=fullfile(RootRoot,'EXP_INIT',CamName); 132 File_init=fullfile(CalibFolder,'images.png.bed','Z_init.nc'); 133 Data_init=nc2struct(File_init); 134 %% set of y positions 135 136 nb_scan=400;% nbre of planes for a scan 137 if nbfield_j<400 138 nb_scan=nbfield_j; 139 end 140 %ycalib=[-51 -1 49];% calibration planes 141 y_scan=-51+0.25*(1:nb_scan);% transverse position given by the translating system: first view at y=-51, view 400 at y=+49 142 coord_x=0.25:0.25:450;%% coord x in phys coordinates for final projection 143 131 144 Mfiltre=ones(2,10)/20;%filter matrix for imnages 132 145 133 146 %% calibration data and timing: read the ImaDoc files 134 XmlData_A=xml2struct(fullfile(RootPath,'planeA.xml')); 135 XmlData_B=xml2struct(fullfile(RootPath,'planeB.xml')); 136 XmlData_C=xml2struct(fullfile(RootPath,'planeC.xml')); 137 ycalib=[-51 -1 49];% the three y positions for calibration 138 fx(1)=XmlData_A.GeometryCalib.fx_fy(1); 147 148 XmlData_A=xml2struct(fullfile(CalibFolder,'planeA.xml')); 149 XmlData_B=xml2struct(fullfile(CalibFolder,'planeB.xml')); 150 XmlData_C=xml2struct(fullfile(CalibFolder,'planeC.xml')); 151 ycalib=[-51 -1 49];% the three y positions for calibration= 152 fx(1)=XmlData_C.GeometryCalib.fx_fy(1); 139 153 fx(2)=XmlData_B.GeometryCalib.fx_fy(1); 140 fx(3)=XmlData_ C.GeometryCalib.fx_fy(1);141 fy(1)=XmlData_ A.GeometryCalib.fx_fy(2);154 fx(3)=XmlData_A.GeometryCalib.fx_fy(1); 155 fy(1)=XmlData_C.GeometryCalib.fx_fy(2); 142 156 fy(2)=XmlData_B.GeometryCalib.fx_fy(2); 143 fy(3)=XmlData_ C.GeometryCalib.fx_fy(2);144 Tx(1)=XmlData_ A.GeometryCalib.Tx_Ty_Tz(1);157 fy(3)=XmlData_A.GeometryCalib.fx_fy(2); 158 Tx(1)=XmlData_C.GeometryCalib.Tx_Ty_Tz(1); 145 159 Tx(2)=XmlData_B.GeometryCalib.Tx_Ty_Tz(1); 146 Tx(3)=XmlData_ C.GeometryCalib.Tx_Ty_Tz(1);147 Ty(1)=XmlData_ A.GeometryCalib.Tx_Ty_Tz(2);160 Tx(3)=XmlData_A.GeometryCalib.Tx_Ty_Tz(1); 161 Ty(1)=XmlData_C.GeometryCalib.Tx_Ty_Tz(2); 148 162 Ty(2)=XmlData_B.GeometryCalib.Tx_Ty_Tz(2); 149 Ty(3)=XmlData_ C.GeometryCalib.Tx_Ty_Tz(2);150 R11(1)=XmlData_ A.GeometryCalib.R(1,1);163 Ty(3)=XmlData_A.GeometryCalib.Tx_Ty_Tz(2); 164 R11(1)=XmlData_C.GeometryCalib.R(1,1); 151 165 R11(2)=XmlData_B.GeometryCalib.R(1,1); 152 R11(3)=XmlData_ C.GeometryCalib.R(1,1);153 R12(1)=XmlData_ A.GeometryCalib.R(1,2);166 R11(3)=XmlData_A.GeometryCalib.R(1,1); 167 R12(1)=XmlData_C.GeometryCalib.R(1,2); 154 168 R12(2)=XmlData_B.GeometryCalib.R(1,2); 155 R12(3)=XmlData_ C.GeometryCalib.R(1,2);156 R21(1)=XmlData_ A.GeometryCalib.R(2,1);169 R12(3)=XmlData_A.GeometryCalib.R(1,2); 170 R21(1)=XmlData_C.GeometryCalib.R(2,1); 157 171 R21(2)=XmlData_B.GeometryCalib.R(2,1); 158 R21(3)=XmlData_ C.GeometryCalib.R(2,1);159 R22(1)=XmlData_ A.GeometryCalib.R(2,2);172 R21(3)=XmlData_A.GeometryCalib.R(2,1); 173 R22(1)=XmlData_C.GeometryCalib.R(2,2); 160 174 R22(2)=XmlData_B.GeometryCalib.R(2,2); 161 R22(3)=XmlData_ C.GeometryCalib.R(2,2);162 pfx=polyfit(ycalib,fx,1);%get th e linear interpolation of each parameter of the three calibrations175 R22(3)=XmlData_A.GeometryCalib.R(2,2); 176 pfx=polyfit(ycalib,fx,1);%get thfield_ie linear interpolation of each parameter of the three calibrations 163 177 pfy=polyfit(ycalib,fy,1); 164 178 pTx=polyfit(ycalib,Tx,1); … … 169 183 p22=polyfit(ycalib,R22,1); 170 184 %get the calibration parameters at each position y by interpolation of the 3 calibration parameters 171 for img=1:nb field_i185 for img=1:nb_scan 172 186 Calib(img).fx_fy(1)=pfx(1)*y_scan(img)+pfx(2); 173 187 Calib(img).fx_fy(2)=pfy(1)*y_scan(img)+pfy(2); … … 184 198 end 185 199 186 %% check coincdence in time for several input file series 187 %not relevant for this function 188 189 %% coordinate transform or other user defined transform 190 %not relevant for this function 191 192 %%%%%%%%%%%% END STANDARD PART %%%%%%%%%%%% 193 % EDIT FROM HERE 200 201 194 202 195 203 %% Load the init bed scan 196 204 tic 197 nb_scan=10; 198 for img=1:nb_scan 199 img 200 a=flipud(imread(filecell{1,img}));%image of the initial bed 201 if img==1 202 x=1:size(a,2);%image absissa in pixel coordinates 205 %filecell=reshape(filecell,nbfield_j,nbfield_i) 206 % main loop 207 for ifield=1:nbfield_i 208 for img=1:nbfield_j% loop on positions 209 if CheckVirtual 210 [FileName,FrameIndex]=index2filename(Param.FileSeries,i_series(ifield),j_series(img),nbfield_j); 211 InputFile=fullfile(RootPath,SubDir,FileName); 212 else 213 InputFile=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,FileIndex,ifield,[],img); 214 FrameIndex=1; 215 end 216 a=flipud(read_image(InputFile,'multimage',[],FrameIndex)); 217 %a=flipud(imread(InputFile));%image of the initial bed [X_b_new(img,:),Z_b_new(img,:)]=phys_XYZ(Calib(img),[],x,Z_sb(img,:)) 218 if img==1 219 [nby,nbx]=size(a); 220 x_ima=1:nbx;%image absissa in pixel coordinates 221 X_phys=zeros(nb_scan,nbx); 222 Z_phys=zeros(nb_scan,nbx); 223 end 224 % filtering 225 a=filter2(Mfiltre,a);%smoothed image 226 amean=mean(a,2); 227 [~,ind_max]=max(amean);% get the max of the image averaged along x, to restrict the search region 228 ind_range=max(1,ind_max-30):min(nby,ind_max+30);% search band to find the line 229 z_ima=get_max(a(ind_range,:))+ind_range(1)-1;% get the max in the search band and shift to express it in indices of the original image 230 231 % [~,iy]=max(a);% find the max along the first coordinate Z_s_new=zeros(nb_scan,size(Z_s,2)); y, max values imax and the corresponding y index iy along the first coordinate y 232 z_ima=smooth(z_ima,20,'rloess');%smooth Z, the image index of max luminosity (dependning on x) 233 [X_phys(img,:),Z_phys(img,:)]=phys_XYZ(Calib(img),[],x_ima,z_ima'); 203 234 end 204 % filtering 205 a=filter2(Mfiltre,a);%smoothed image 206 [imax,iy]=max(a);% find the max along the first coordinate y, max values imax and the corresponding y index iy along the first coordinate y 207 Z_s(img,:)=smooth(iy,40,'rloess');%smooth Z, the image index of max luminosity (dependning on x) 208 Yima=y_scan(img)*ones(size(x));%positions Y transformed into a vector 209 X_new(img,:)=phys_XYZ(Calib(img),x,Yima,1); 210 %X_new(:,img)=phys_scan(x,y(img)); 211 end 212 213 toc 214 215 [X,Y]=meshgrid(x,y_scan); 216 217 218 %% Load the current bed scan 219 for img=1:nb_scan 220 b=flipud(imread(filecell{2,img}));%image of the current bed 221 b=filter2(Mfiltre,b); % filtering 222 [imaxb,iyb]=max(b); 223 Z_sb(img,:)=smooth(iyb,20,'rloess'); 224 end 225 226 %% bed change 227 dZ=Z_s-Z_sb;% displacement between current position and initial 228 dZ_new=zeros(nb_scan,size(dZ,2)); 229 for img=1:nb_scan 230 Yima=y_scan(img)*ones(1,size(dZ,2)); 231 [~,dZ_new(img,:)]=phys_XYZ(Calib(img),dZ(img,:),Yima,1); 232 % dZ_new(:,img)=phys_scanz(dZ(:,img),y(img)); 233 end 234 235 236 %% PLOTS 237 coord_x=X_new(end,1):0.1:X_new(end,end); 238 [Y_m,X_m]=meshgrid(y_scan,coord_x); 239 %Y_new=Y'; 240 dZ_mesh=griddata(X_new,Y,dZ_new,X_m,Y_m); 241 242 if checkrun 243 figure(1) 244 hold on 245 plot(x,Z_s+700) 246 % xlim([0 4096]) 247 % ylim([0 3000]) 248 249 figure(2) 250 hold on 251 plot(x,Z_sb+700) 252 xlim([0 4096]) 253 ylim([0 3000]) 254 255 figure(3) 256 surfc(X_m,Y_m,dZ_mesh) 257 shading interp; 258 colorbar; 259 caxis([0 3]); 260 261 figure 262 pcolor(X_m,Y_m,dZ_mesh); 263 colormap; 264 set(gca,'Xdir','reverse'); 265 caxis([0 3]); 266 shading flat 267 hold on 268 colorbar 269 title('Dz') 270 end 271 272 %save(fullfile(DirOut,'18OS_f.mat'),'dZ','dZ_new','X','Y','Z_s','Z_sb','y') 273 274 % save netcdf 275 Data.ListVarName={'coord_x','coord_y','dZ'}; 276 Data.VarDimName={'coord_x','coord_y',{'coord_y','coord_x'}}; 277 Data.VarAttribute{1}.Role='coord_x'; 278 Data.VarAttribute{1}.unit='cm'; 279 Data.VarAttribute{2}.Role='coord_y'; 280 Data.VarAttribute{2}.unit='cm'; 281 Data.VarAttribute{3}.Role='scalar'; 282 Data.VarAttribute{3}.unit='cm'; 283 Data.coord_x=[coord_x(1) coord_x(end)]; 284 Data.coord_y=[y(1) y(end)]; 285 Data.dZ=dZ_mesh'; 286 struct2nc(fullfile(DirOut,'dZ.nc'),Data) 287 288 %% gives the physical position x from the image position X and the physical position y of the laser plane 289 function F=phys_scan(X,y) 290 % linear fct of X whose coefficient depend on y in a quadratic way 291 F=(9.4*10^(-7)*y.^2-3.09*10^(-4)*y+0.07).*X +(-0.001023*y.^2+0.469*y+186.9); 292 293 %% gives the physical position z from the image position Z and the physical position y of the laser plane 294 function Fz=phys_scanz(Z,y) 295 % scale factor applied to Z depending on the physical position y of the laser plane 296 Fz=(-1.4587*10^(-5)*y.^2 + 0.001072*y+0.0833).*Z; %+(-2.1*10^(-6)*x.^2+5.1*10^(-4)*x+0.0735).*Z; 297 298 235 disp(['last file of ' num2str(ifield)]) 236 disp(FileName) 237 disp(FrameIndex) 238 239 %% interpolate on a regular grid 240 %coord_x=X_phys(end,1):0.1:X_phys(end,end);%% coord x in phys coordinates based in the last view plane (the last) 241 [X_m,Y_m]=meshgrid(coord_x,y_scan); 242 Y=y_scan'*ones(1,nbx);%initialisation of X, Y final topography map 243 244 Data.Z=griddata(X_phys,Y,Z_phys,X_m,Y_m);% dZ interpolated on the regular ph1ys grid X_m,Y_m 245 size(Data.Z) 246 size(Data_init.Z_init) 247 Data.dZ=Data.Z-Data_init.Z_init; 248 249 toc 250 251 % save netcdf 252 Data.ListVarName={'coord_x','y_scan','Z','dZ'}; 253 Data.VarDimName={'coord_x','y_scan',{'y_scan','coord_x'},{'y_scan','coord_x'}}; 254 Data.VarAttribute{1}.Role='coord_x'; 255 Data.VarAttribute{1}.unit='cm'; 256 Data.VarAttribute{2}.Role='coord_y'; 257 Data.VarAttribute{2}.unit='cm'; 258 Data.VarAttribute{3}.Role='scalar'; 259 Data.VarAttribute{3}.unit='cm'; 260 Data.VarAttribute{4}.Role='scalar'; 261 Data.VarAttribute{4}.unit='cm'; 262 Data.coord_x=coord_x; 263 Data.y_scan=y_scan; 264 struct2nc(fullfile(DirOut,['dZ_' num2str(ifield) '.nc']),Data) 265 end 266 267 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 268 function iy=get_max(a)% get the max with sub picel resolution 269 [a_max,iy]=max(a); 270 [Nby,Nbx]=size(a); 271 for ind_x=1:Nbx 272 if iy(ind_x)>1 && iy(ind_x)<Nby 273 a_plus=a(iy(ind_x)+1,ind_x); 274 a_min=a(iy(ind_x)-1,ind_x); 275 denom=2*a_max(ind_x)-a_plus-a_min; 276 if denom >0 277 iy(ind_x)=iy(ind_x)+0.5*(a_plus-a_min)/denom;%adjust the position of the max with a quadratic fit of the three points around the max 278 end 279 end 280 end -
trunk/src/uvmat.m
r1183 r1184 40 40 % .FileName_1: name of the current second field (used to detect a constant field during file scanning) 41 41 % .FileType: current file type, as defined by the fct get_file_type.m) 42 % .i1_series,.i2_series,.j1_series,.j1_series: series of i1,i2,j1,j2 indices detected in the input dir,set by the fct find_file_series42 % .i1_series,.i2_series,.j1_series,.j1_series: series of num_i1,num_i2,num_j1,num_j2 indices detected in the input dir,set by the fct find_file_series 43 43 % .MovieObject: current movie object 44 44 % .TimeUnit: unit for time … … 280 280 end 281 281 if isfield(input,'TimeIndex') 282 set(handles. i1,num2str(input.TimeIndex))282 set(handles.num_i1,num2str(input.TimeIndex)) 283 283 end 284 284 if isfield(input,'FieldsString') … … 2124 2124 i1_mod=floor(i1_mod/(NbField_j -1))+1; 2125 2125 end 2126 set(handles. i1,'String',num2str(i1_mod));%update the counters2127 set(handles. j1,'String',num2str(j1));%update the counters2126 set(handles.num_i1,'String',num2str(i1_mod));%update the counters 2127 set(handles.num_j1,'String',num2str(j1));%update the counters 2128 2128 check_index=true; 2129 2129 end … … 2131 2131 end 2132 2132 if ~check_index 2133 set(handles. i1,'String',num2str(i1));%update the counters2134 set(handles. i2,'String',num2str(i2));2135 set(handles. j1,'String',num2str(j1));2136 set(handles. j2,'String',num2str(j2));2133 set(handles.num_i1,'String',num2str(i1));%update the counters 2134 set(handles.num_i2,'String',num2str(i2)); 2135 set(handles.num_j1,'String',num2str(j1)); 2136 set(handles.num_j2,'String',num2str(j2)); 2137 2137 end 2138 2138 … … 2141 2141 function NomType_Callback(hObject, eventdata, handles) 2142 2142 %------------------------------------------------------------------------ 2143 i1=str2double(get(handles. i1,'String'));2144 i2=str2double(get(handles. i2,'String'));2145 j1=str2double(get(handles. j1,'String'));2146 j2=str2double(get(handles. j2,'String'));2143 i1=str2double(get(handles.num_i1,'String')); 2144 i2=str2double(get(handles.num_i2,'String')); 2145 j1=str2double(get(handles.num_j1,'String')); 2146 j2=str2double(get(handles.num_j2,'String')); 2147 2147 NomType=get(hObject,'String'); 2148 2148 if strcmp(NomType,'level') 2149 FileIndex=str2double(get(handles. i1,'String'));2149 FileIndex=str2double(get(handles.num_i1,'String')); 2150 2150 else 2151 2151 FileIndex=fullfile_uvmat('','','','',get(handles.NomType,'String'),i1,i2,j1,j2); … … 2159 2159 function NomType_1_Callback(hObject, eventdata, handles) 2160 2160 %------------------------------------------------------------------------ 2161 i1=str2double(get(handles. i1,'String'));2162 i2=str2double(get(handles. i2,'String'));2163 j1=str2double(get(handles. j1,'String'));2164 j2=str2double(get(handles. j2,'String'));2161 i1=str2double(get(handles.num_i1,'String')); 2162 i2=str2double(get(handles.num_i2,'String')); 2163 j1=str2double(get(handles.num_j1,'String')); 2164 j2=str2double(get(handles.num_j2,'String')); 2165 2165 NomType=get(hObject,'String'); 2166 2166 if strcmp(NomType,'level') 2167 FileIndex=str2double(get(handles. i1,'String'));2167 FileIndex=str2double(get(handles.num_i1,'String')); 2168 2168 else 2169 2169 FileIndex=fullfile_uvmat('','','','',get(handles.NomType_1,'String'),i1,i2,j1,j2); … … 2174 2174 2175 2175 %------------------------------------------------------------------------ 2176 % --- Executes on button press in InputFileREFRESH.2176 % --- Executes on press in button tagged 'InputFileREFRESH'. 2177 2177 function InputFileREFRESH_Callback(hObject, eventdata, handles) 2178 2178 %------------------------------------------------------------------------ … … 2180 2180 set(handles.uvmat,'Pointer','watch') % set the mouse pointer to 'watch' 2181 2181 drawnow 2182 % get the current input file name: 2183 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 2184 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 2185 %[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileInfo,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); 2182 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);% get the current input file name: 2186 2183 errormsg=''; 2187 if isempty(RootFile) 2184 if isempty(RootFile)% open the file browser if the input file is not defined 2188 2185 fileinput=uigetfile_uvmat('pick an input file',fullfile(RootPath,SubDir)); 2189 2186 hh=dir(fileinput); … … 2198 2195 end 2199 2196 end 2200 else 2201 % initiate the input file series and refresh the current field view: 2197 else % initiate the input file series and refresh the current field view: 2202 2198 [FileInfo,VideoObject]=get_file_info(fullfile(RootPath,SubDir,[RootFile FileIndices FileExt])); 2203 2199 errormsg=update_rootinfo(handles,RootPath,SubDir,[RootFile FileIndices FileExt],FileInfo,VideoObject,1); … … 2208 2204 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); 2209 2205 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 2210 [RootPath,SubDir,~,i1_series, i2_series,j1_series,j2_series,~,FileInfo,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);2206 [RootPath,SubDir,~,i1_series,~,~,~,~,FileInfo,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); 2211 2207 if isempty(i1_series) 2212 2208 fileinput=uigetfile_uvmat('pick an input file for the second line',fullfile(RootPath,SubDir)); … … 2311 2307 %[FilePath,FileName,FileExt]=fileparts(fileinput); 2312 2308 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 2313 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists2309 % the root name and indices may be corrected by including the first index num_i1 if a corresponding xml file exists 2314 2310 2315 2311 set(handles_RootPath,'String',RootPath); … … 2328 2324 if input_line==1 2329 2325 % fill file index counters if the first file series is opened 2330 set(handles. i1,'String',num2str(i1));2331 set(handles. i2,'String',num2str(i2));2332 set(handles. j1,'String',num2stra(j1,NomType));2333 set(handles. j2,'String',num2stra(j2,NomType));2326 set(handles.num_i1,'String',num2str(i1)); 2327 set(handles.num_i2,'String',num2str(i2)); 2328 set(handles.num_j1,'String',num2stra(j1,NomType)); 2329 set(handles.num_j2,'String',num2stra(j2,NomType)); 2334 2330 if isfield(FileInfo,'MaskFile') 2335 2331 if exist(FileInfo.MaskFile,'file') … … 2350 2346 end 2351 2347 else %read the current field index to synchronise with the first series 2352 i1_s=str2double(get(handles. i1,'String'));2353 i2_0=str2double(get(handles. i2,'String'));2348 i1_s=str2double(get(handles.num_i1,'String')); 2349 i2_0=str2double(get(handles.num_i2,'String')); 2354 2350 if ~isempty(i2_0) 2355 2351 i2_s=i2_0; … … 2357 2353 i2_s=i2; 2358 2354 end 2359 j1_0=stra2num(get(handles. j1,'String'));2355 j1_0=stra2num(get(handles.num_j1,'String')); 2360 2356 if ~isempty(j1_0) 2361 2357 j1_s=j1_0; … … 2363 2359 j1_s=j1; 2364 2360 end 2365 j2_0=stra2num(get(handles. j2,'String'));2361 j2_0=stra2num(get(handles.num_j2,'String')); 2366 2362 if ~isempty(j2_0) 2367 2363 j2_s=j2_0; … … 2444 2440 XmlFileName=find_imadoc(RootPath,SubDir);% search the appropriate ImaDoc xml file 2445 2441 [~,XmlName]=fileparts(XmlFileName); 2446 2447 2442 CheckIndexing=false;% test for virtual indexing of frames different from the file name index, false by default 2448 2443 if isempty(XmlFileName) %no ImaDoc xml file detected … … 2453 2448 set(handles.view_xml,'String','view xml') 2454 2449 drawnow 2455 [XmlData,warntext]=imadoc2struct(XmlFileName); 2450 [XmlData,warntext]=imadoc2struct(XmlFileName);% open xml file ImaDoc 2456 2451 if ~isempty(warntext) 2457 2452 msgbox_uvmat('WARNING',warntext) … … 2474 2469 end 2475 2470 if CheckIndexing 2476 set(handles.MenuRelabelFrames,'checked','on')% activate the relabel tool by default2471 set(handles.MenuRelabelFrames,'checked','on')% activate the relabel tool by default 2477 2472 else 2478 2473 set(handles.MenuRelabelFrames,'checked','off') … … 2488 2483 TimeUnit='';%default 2489 2484 TimeName='';%default 2485 state_j='off'; % no visualisation of the j index by default 2490 2486 2491 2487 %% get the file series … … 2497 2493 j1_series=[]; 2498 2494 j2_series=[]; 2499 nbfield =[];2495 nbfield_i=[]; 2500 2496 nbfield_j=[]; 2501 2497 FileInfo=XmlData.FileInfo; 2502 % if iscell(XmlData.FileSeries.FileName)(handles.i1,'String','1') 2503 set(handles.i1,'String','1')% the index does not correspond to file name index anymore 2504 set(handles.j1,'String','1') 2498 set(handles.num_i1,'String','1')% the index does not correspond to file name index anymore, set i=1, j=1 by default as s start 2499 set(handles.num_j1,'String','1') 2505 2500 else % scan the input folder to get the list of existing files and NomType 2506 2501 [~,~,~,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject]=... 2507 2502 find_file_series(fullfile(RootPath,SubDir),FileName); 2508 nbfield =max(max(max(i2_series)));% total number of fields (i index)2509 if isempty(nbfield )2510 nbfield =max(max(max(i1_series)));2503 nbfield_i=max(max(max(i2_series)));% total number of fields (i index) 2504 if isempty(nbfield_i) 2505 nbfield_i=max(max(max(i1_series))); 2511 2506 end 2512 2507 nbfield_j=max(max(max(j2_series)));% number of fields along j index … … 2515 2510 end 2516 2511 if ~isempty(j1_series)&& ~strcmp(NomType,'*')% the j index is used to label the frame in multimage series 2517 set(handles.j1,'String','1') 2512 set(handles.num_j1,'String','1') 2513 state_j='on'; 2518 2514 elseif strcmp(FileInfo.FieldType,'image') && ~isequal(FileInfo.NumberOfFrames,1) 2519 set(handles. i1,'String','1')2515 set(handles.num_i1,'String','1') 2520 2516 end 2521 2517 end … … 2525 2521 set(handles.NomType_1,'String',NomType) 2526 2522 end 2527 % if CheckIndexing2528 % % i1=str2double(get(handles.FileIndex,'String'));2529 % % if isnan(i1)2530 % % i1=1;2531 % % else2532 % % i1=(i1-XmlData.FileSeries.FirstFileIndex)*XmlData.FileSeries.NbFramePerFile+1;%frame index deduced from input file index2533 % % end2534 % % if strcmp(TimeName,'xml')% indices i and j2535 % % j1=mod(i1-1,nbfield_j)+1;2536 % % i1=floor((i1-1)/nbfield_j)+1;2537 % % set(handles.j1,'String',num2str(j1))2538 % % end2539 % % set(handles.i1,'String',num2str(i1))2540 %2541 % end2542 2523 2543 2524 … … 2562 2543 TimeName='xml';%Time possibly documented by the xml file (but priority to the opened file if available) 2563 2544 end 2564 2565 if ~CheckIndexing && isfield(FileInfo,'FrameRate')% frame rate given in the file (case of video data) 2566 TimeUnit='s'; 2567 if isempty(j1_series) %frame index along i 2568 XmlData.Time=zeros(FileInfo.NumberOfFrames+1,2); 2569 XmlData.Time(:,2)=(0:1/FileInfo.FrameRate:(FileInfo.NumberOfFrames)/FileInfo.FrameRate)'; 2570 set(handles.i1,'String','1')% set the frame index to 1 to start the movie 2545 if CheckIndexing 2546 i1=str2double(get(handles.FileIndex,'String')); 2547 if isnan(i1) 2548 i1=1; 2571 2549 else 2572 XmlData.Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/FileInfo.FrameRate:(FileInfo.NumberOfFrames)/FileInfo.FrameRate); 2550 FirstFileIndex=1; 2551 if isfield(XmlData.FileSeries,'FirstFileIndex') 2552 FirstFileIndex=XmlData.FileSeries.FirstFileIndex; 2553 end 2554 i1=(i1-FirstFileIndex)*XmlData.FileSeries.NbFramePerFile+1;%frame index deduced from input file index 2555 end 2556 if isfield(XmlData,'Time') && size(XmlData.Time,2)>1% 2557 nbfield_j=size(XmlData.Time,2)-1; 2558 nbfield_i=size(XmlData.Time,1)-1; 2559 j1=mod(i1-1,nbfield_j)+1; 2560 i1=floor((i1-1)/nbfield_j)+1; 2561 set(handles.num_j1,'String',num2str(j1)) 2562 state_j='on'; 2563 end 2564 set(handles.num_i1,'String',num2str(i1)) 2565 else 2566 if isfield(FileInfo,'FrameRate')% frame rate given in the file (case of video data) 2567 TimeUnit='s'; 2568 if isempty(j1_series) %frame index along i 2569 XmlData.Time=zeros(FileInfo.NumberOfFrames+1,2); 2570 XmlData.Time(:,2)=(0:1/FileInfo.FrameRate:(FileInfo.NumberOfFrames)/FileInfo.FrameRate)'; 2571 set(handles.num_i1,'String','1')% set the frame index to 1 to start the movie 2572 else 2573 XmlData.Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/FileInfo.FrameRate:(FileInfo.NumberOfFrames)/FileInfo.FrameRate); 2574 state_j='on'; 2575 end 2573 2576 end 2574 2577 end … … 2618 2621 %% store last index in handles.MaxIndex_i and .MaxIndex_j 2619 2622 last_i_cell=get(handles.MaxIndex_i,'String'); 2620 if isempty(nbfield )2623 if isempty(nbfield_i) 2621 2624 last_i_cell{input_line}=''; 2622 2625 else 2623 last_i_cell{input_line}=num2str(nbfield );2626 last_i_cell{input_line}=num2str(nbfield_i); 2624 2627 end 2625 2628 set(handles.MaxIndex_i,'String',last_i_cell) … … 2629 2632 else 2630 2633 last_j_cell{input_line}=num2str(nbfield_j); 2634 2631 2635 end 2632 2636 set(handles.MaxIndex_j,'String',last_j_cell); … … 2745 2749 end 2746 2750 otherwise 2747 set(handles_Fields,'Value',1) % set menu to 'image' 2751 set(handles_Fields,'Value',1) % set menu to 'image'j1_series 2748 2752 set(handles_Fields,'String',{'image'}) 2749 2753 %set(handles.Coord_x,'Value',1); … … 2757 2761 %% set index navigation options 2758 2762 scan_option='i';%default 2759 state_j='off'; %default2763 %state_j='off'; %default 2760 2764 if input_line==2 2761 2765 if get(handles.scan_j,'Value') 2762 2766 scan_option='j'; %keep the scan option for the second file series 2763 2767 end 2764 if strcmp(get(handles. j1,'Visible'),'on')2768 if strcmp(get(handles.num_j1,'Visible'),'on') 2765 2769 state_j='on'; 2766 2770 end … … 2799 2803 end 2800 2804 set(handles.scan_j,'Visible',state_j) 2801 set(handles. j1,'Visible',state_j)2802 set(handles. j2,'Visible',state_j)2805 set(handles.num_j1,'Visible',state_j) 2806 set(handles.num_j2,'Visible',state_j) 2803 2807 set(handles.MaxIndex_j,'Visible',state_j); 2804 2808 set(handles.j_text,'Visible',state_j); … … 2850 2854 2851 2855 %------------------------------------------------------------------------ 2852 function i1_Callback(hObject, eventdata, handles)2856 function num_i1_Callback(hObject, eventdata, handles) 2853 2857 %------------------------------------------------------------------------ 2854 2858 update_ij(handles,1) 2855 2859 2856 2860 %------------------------------------------------------------------------ 2857 function i2_Callback(hObject, eventdata, handles)2861 function num_i2_Callback(hObject, eventdata, handles) 2858 2862 %------------------------------------------------------------------------ 2859 2863 update_ij(handles,2) 2860 2864 2861 2865 %------------------------------------------------------------------------ 2862 function j1_Callback(hObject, eventdata, handles)2866 function num_j1_Callback(hObject, eventdata, handles) 2863 2867 %------------------------------------------------------------------------ 2864 2868 update_ij(handles,3) 2865 2869 2866 2870 %------------------------------------------------------------------------ 2867 function j2_Callback(hObject, eventdata, handles)2871 function num_j2_Callback(hObject, eventdata, handles) 2868 2872 %------------------------------------------------------------------------ 2869 2873 update_ij(handles,4) 2870 2874 2871 2875 %------------------------------------------------------------------------ 2872 %--- update the index display after action on edit boxes i1, i2, j1 orj22876 %--- update the index display after action on edit boxes num_i1, num_i2, num_j1 or num_j2 2873 2877 %------------------------------------------------------------------------ 2874 2878 function update_ij(handles,index_rank) … … 2878 2882 2879 2883 if strcmp(NomType,'level') 2880 index_string=get(handles. i1,'String');2884 index_string=get(handles.num_i1,'String'); 2881 2885 else 2882 2886 index_string=get(handles.FileIndex,'String'); 2883 2887 if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'FileSeries') 2884 i1=str2double(get(handles. i1,'String'));2885 j1=str2double(get(handles. j1,'String'));2888 i1=str2double(get(handles.num_i1,'String')); 2889 j1=str2double(get(handles.num_j1,'String')); 2886 2890 NbField_j_cell=get(handles.MaxIndex_j,'String'); 2887 2891 NbField_j=str2double(NbField_j_cell{1}); 2888 [RootFile,index_string,FrameIndex]=index2filename(UvData.XmlData{1}.FileSeries,i1,j1,NbField_j); 2892 RootFile=index2filename(UvData.XmlData{1}.FileSeries,i1,j1,NbField_j); 2893 index_string=''; 2889 2894 set(handles.RootFile,'String',RootFile) 2890 2895 else … … 2892 2897 switch index_rank 2893 2898 case 1 2894 index_string=fullfile_uvmat('','','','',NomType,stra2num(get(handles. i1,'String')),i2,j1,j2);2899 index_string=fullfile_uvmat('','','','',NomType,stra2num(get(handles.num_i1,'String')),i2,j1,j2); 2895 2900 case 2 2896 index_string=fullfile_uvmat('','','','',NomType,i1,stra2num(get(handles. i2,'String')),j1,j2);2901 index_string=fullfile_uvmat('','','','',NomType,i1,stra2num(get(handles.num_i2,'String')),j1,j2); 2897 2902 case 3 2898 index_string=fullfile_uvmat('','','','',NomType,i1,i2,stra2num(get(handles. j1,'String')),j2);2903 index_string=fullfile_uvmat('','','','',NomType,i1,i2,stra2num(get(handles.num_j1,'String')),j2); 2899 2904 case 4 2900 index_string=fullfile_uvmat('','','','',NomType,i1,i2,j1,stra2num(get(handles. j2,'String')));2905 index_string=fullfile_uvmat('','','','',NomType,i1,i2,j1,stra2num(get(handles.num_j2,'String'))); 2901 2906 end 2902 2907 end … … 2908 2913 NomType_1=get(handles.NomType_1,'String'); 2909 2914 index_string_1=get(handles.FileIndex_1,'String'); 2910 [ tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(index_string_1);% the index_string for the second series taken from FileIndex_12915 [~,~,~,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(index_string_1);% the index_string for the second series taken from FileIndex_1 2911 2916 switch index_rank 2912 2917 case 1 2913 index_string_1=fullfile_uvmat('','','','',NomType_1,stra2num(get(handles. i1,'String')),i2_1,j1_1,j2_1);2918 index_string_1=fullfile_uvmat('','','','',NomType_1,stra2num(get(handles.num_i1,'String')),i2_1,j1_1,j2_1); 2914 2919 case 2 2915 index_string_1=fullfile_uvmat('','','','',NomType_1,i1_1,stra2num(get(handles. i2,'String')),j1_1,j2_1);2920 index_string_1=fullfile_uvmat('','','','',NomType_1,i1_1,stra2num(get(handles.num_i2,'String')),j1_1,j2_1); 2916 2921 case 3 2917 index_string_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,stra2num(get(handles. j1,'String')),j2_1);2922 index_string_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,stra2num(get(handles.num_j1,'String')),j2_1); 2918 2923 case 4 2919 index_string_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,j1_1,stra2num(get(handles. j2,'String')));2924 index_string_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,j1_1,stra2num(get(handles.num_j2,'String'))); 2920 2925 end 2921 2926 set(handles.FileIndex_1,'String',index_string_1) … … 2947 2952 %------------------------------------------------------------------------ 2948 2953 mode=get(handles.slices,'String'); 2949 nb_slice_str=get(handles.num_NbSlice,'String');2950 2954 if strcmp(mode,'volume') 2951 z=stra2num(get(handles. j1,'String'));2952 else 2953 num=str2double(get(handles. i1,'String'));2955 z=stra2num(get(handles.num_j1,'String')); 2956 else 2957 num=str2double(get(handles.num_i1,'String')); 2954 2958 nbslice=str2double(get(handles.num_NbSlice,'String')); 2955 2959 z=mod(num-1,nbslice)+1; … … 2980 2984 FileXml=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']); 2981 2985 end 2982 heditxml=editxml(FileXml);2986 editxml(FileXml); 2983 2987 end 2984 2988 … … 2990 2994 if isequal(get(handles.CheckMask,'Value'),1) 2991 2995 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); 2992 if isempty(regexp(RootPath,'^http://' ))2996 if isempty(regexp(RootPath,'^http://', 'once'))% not opendap input file 2993 2997 fileinput=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line) 2994 2998 else … … 3029 3033 [MaskPath,FileName,FileExt]=fileparts(filemask); 3030 3034 Mask.File=filemask; 3031 [ RootPath,SubDir,RootFile,i1_series,i2,j1,j2,NomType]=find_file_series(MaskPath,[FileName FileExt]);3035 [~,~,~,i1_series,~,~,~,NomType]=find_file_series(MaskPath,[FileName FileExt]); 3032 3036 Mask.NbSlice=[];%default 3033 3037 Mask.VolumeScan=0;% TO UPDATE *** … … 3045 3049 msgbox_uvmat(['ERROR','error in displaying mask, ' errormsg]); 3046 3050 end 3047 testmask=1;3048 3051 end 3049 3052 else % desactivate mask display … … 3073 3076 if isfield(MaskInfo,'NbSlice')&& ~isempty(MaskInfo.NbSlice) 3074 3077 if isfield(MaskInfo,'VolumeScan') && MaskInfo.VolumeScan 3075 MaskIndex_i=str2double(get(handles. j1,'String'));3078 MaskIndex_i=str2double(get(handles.num_j1,'String')); 3076 3079 else 3077 MaskIndex_i=mod(str2double(get(handles. i1,'String'))-1,MaskInfo.NbSlice)+1;3080 MaskIndex_i=mod(str2double(get(handles.num_i1,'String'))-1,MaskInfo.NbSlice)+1; 3078 3081 end 3079 3082 MaskName=[MaskInfo.File '_' num2str(MaskIndex_i) '.png']; … … 3274 3277 UvData=get(handles.uvmat,'UserData'); 3275 3278 if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'FileSeries')% case of indexing documented by the xml file 3276 i1=str2double(get(handles. i1,'String'));3277 j1=str2double(get(handles. j1,'String'));%read the field indices (for movie, it is not given by the file name)3279 i1=str2double(get(handles.num_i1,'String')); 3280 j1=str2double(get(handles.num_j1,'String'));%read the field indices (for movie, it is not given by the file name) 3278 3281 i2=[];j2=[]; 3279 3282 else 3280 3283 [~,~,~,i1,i2,j1,j2]=fileparts_uvmat(InputFile.FileIndex);% check back the indices used 3281 3284 if isempty(i1)% no i index set by the input file name 3282 i1=str2double(get(handles. i1,'String'));%read the field indices (for movie, it is not given by the file name)3283 elseif isempty(j1) && strcmp(get(handles. j1,'Visible'),'on')3284 j1=str2double(get(handles. j1,'String'));%case of indexed movie3285 i1=str2double(get(handles.num_i1,'String'));%read the field indices (for movie, it is not given by the file name) 3286 elseif isempty(j1) && strcmp(get(handles.num_j1,'Visible'),'on') 3287 j1=str2double(get(handles.num_j1,'String'));%case of indexed movie 3285 3288 end 3286 3289 end … … 3290 3293 [~,~,~,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(InputFile.FileIndex_1);% the indices for the second series taken from FileIndex_1 3291 3294 if isempty(i1_1) 3292 i1_1=str2double(get(handles. i1,'String'));%read the field indices (for movie, it is not given by the file name)3293 elseif isempty(j1_1) && strcmp(get(handles. j1,'Visible'),'on')3294 j1_1=str2double(get(handles. j1,'String'));%case of indexed movie3295 i1_1=str2double(get(handles.num_i1,'String'));%read the field indices (for movie, it is not given by the file name) 3296 elseif isempty(j1_1) && strcmp(get(handles.num_j1,'Visible'),'on') 3297 j1_1=str2double(get(handles.num_j1,'String'));%case of indexed movie 3295 3298 end 3296 3299 else … … 3302 3305 set(handles.CheckFixPair,'Value',0) 3303 3306 end 3304 %CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty( i2)&& isempty(j2));3305 3306 % the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected)3307 %CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(num_i2)&& isempty(num_j2)); 3308 3309 % the pair num_i1-num_i2 or num_j1-num_j2 is imposed (check box CheckFixPair selected) 3307 3310 if isnumeric(increment) 3308 3311 if get(handles.scan_i,'Value')==1 % case of scanning along index i … … 3322 3325 end 3323 3326 3324 % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used3327 % the pair num_i1-num_i2 or num_j1-num_j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used 3325 3328 else 3326 3329 ref_i=i1; … … 3465 3468 3466 3469 %% update the index counters if the index move is successfull 3467 3468 3470 if isempty(errormsg) 3469 set(handles. i1,'String',num2stra(i1,NomType,1));3471 set(handles.num_i1,'String',num2stra(i1,NomType,1)); 3470 3472 if isequal(i2,i1) 3471 set(handles. i2,'String','');3473 set(handles.num_i2,'String',''); 3472 3474 else 3473 set(handles. i2,'String',num2stra(i2,NomType,1));3474 end 3475 set(handles. j1,'String',num2stra(j1,NomType,2));3475 set(handles.num_i2,'String',num2stra(i2,NomType,1)); 3476 end 3477 set(handles.num_j1,'String',num2stra(j1,NomType,2)); 3476 3478 if isequal(j2,j1) 3477 set(handles. j2,'String','');3479 set(handles.num_j2,'String',''); 3478 3480 else 3479 set(handles. j2,'String',num2stra(j2,NomType,2));3481 set(handles.num_j2,'String',num2stra(j2,NomType,2)); 3480 3482 end 3481 3483 if strcmp(NomType,'level') … … 3496 3498 set(handles.FileIndex_1,'String',indices_1); 3497 3499 end 3498 if isempty(i2), set(handles. i2,'String',''); end % suppress the second index display if not used3499 if isempty(j2), set(handles. j2,'String',''); end3500 if isempty(i2), set(handles.num_i2,'String',''); end % suppress the second index display if not used 3501 if isempty(j2), set(handles.num_j2,'String',''); end 3500 3502 end 3501 3503 … … 3508 3510 if ~get(handles.movie_pair,'value') 3509 3511 set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off' 3510 set(handles. i2,'String','')% the second i index display is suppressed3511 set(handles. j2,'String','')% the second j index display is suppressed3512 set(handles.num_i2,'String','')% the second i index display is suppressed 3513 set(handles.num_j2,'String','')% the second j index display is suppressed 3512 3514 set(handles.Dt_txt,'String','')% the time interval indication is suppressed 3513 3515 return … … 3523 3525 3524 3526 %% make movie until movie speed is set to 0 or STOP is activated 3525 hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER)3526 3527 set(handles.STOP,'Visible','on') 3527 3528 set(handles.speed,'Visible','on') … … 3541 3542 end 3542 3543 pause(1.02-get(handles.speed,'Value'));% wait for next image 3543 get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')3544 3544 end 3545 3545 set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red 3546 3546 set(handles.movie_pair,'Value',0) 3547 3547 set(handles.Dt_txt,'String','') 3548 3549 3548 set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back in red 3550 3549 3551 3550 3552 3551 %------------------------------------------------------------------------ 3553 % --- Executes on button press in InputFileREFRESH.3552 % --- Executes on press in button tagged 'REFRESH'. 3554 3553 function REFRESH_Callback(hObject, eventdata, handles) 3555 3554 %------------------------------------------------------------------------ … … 3558 3557 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);%read the features of the input file name (first line) 3559 3558 [~,~,~,~,i2,~,j2]=fileparts_uvmat(FileIndex);% check back the indices used 3560 if isempty(i2), set(handles. i2,'String',''); end % suppress the second i index display if not used3561 if isempty(j2), set(handles. j2,'String',''); end % suppress the second j index display if not used3562 if isempty(regexp(RootPath,'^http://','once')) 3559 if isempty(i2), set(handles.num_i2,'String',''); end % suppress the second i index display if not used 3560 if isempty(j2), set(handles.num_j2,'String',''); end % suppress the second j index display if not used 3561 if isempty(regexp(RootPath,'^http://','once'))% if the input is not opendap 3563 3562 filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line) 3564 3563 else … … 3571 3570 filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; %build the input file name (second line) 3572 3571 end 3573 num_i1=stra2num(get(handles. i1,'String'));3574 num_i2=stra2num(get(handles. i2,'String'));3575 num_j1=stra2num(get(handles. j1,'String'));3576 num_j2=stra2num(get(handles. j2,'String'));3577 [ tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1);% get the indices of the second series from the string FileIndex_13572 num_i1=stra2num(get(handles.num_i1,'String')); 3573 num_i2=stra2num(get(handles.num_i2,'String')); 3574 num_j1=stra2num(get(handles.num_j1,'String')); 3575 num_j2=stra2num(get(handles.num_j2,'String')); 3576 [~,~,~,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1);% get the indices of the second series from the string FileIndex_1 3578 3577 if isempty(j1_1)% case of movies, the index is not given by file index 3579 3578 j1_1=num_j1; 3580 3579 end 3581 % in case of movies the index is set by edit boxes i1 orj1 (case of movies indexed by index i)3580 % in case of movies the index is set by edit boxes num_i1 or num_j1 (case of movies indexed by index i) 3582 3581 errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); 3583 3582 ResizeFcn(handles.uvmat,[],handles) … … 3661 3660 frame_index=1;%default 3662 3661 if UvData.FileInfo{1}.NumberOfFrames>1 3662 % if strcmp(NomType,'*') 3663 % if num_i1>UvData.FileInfo{1}.NumberOfFrames 3664 % errormsg='specified frame index exceeds file content'; 3665 % return 3666 % else 3667 % frame_index=num_i1;%frame index from a single movies or multimage 3668 % end 3669 % else 3670 % if num_j1>UvData.FileInfo{1}.NumberOfFrames 3671 % errormsg='specified frame index exceeds file content'; 3672 % return 3673 % else 3674 % frame_index=num_j1;% frame index from a set of indexed movies 3675 % end 3676 % end 3663 3677 if strcmp(NomType,'*') 3664 if num_i1>UvData.FileInfo{1}.NumberOfFrames 3665 errormsg='specified frame index exceeds file content'; 3666 return 3667 else 3668 frame_index=num_i1;%frame index from a single movies or multimage 3669 end 3678 frame_index=num_i1;%frame index from a single movies or multimage 3670 3679 else 3671 if num_j1>UvData.FileInfo{1}.NumberOfFrames 3672 errormsg='specified frame index exceeds file content'; 3673 return 3674 else 3675 frame_index=num_j1;% frame index from a set of indexed movies 3676 end 3680 frame_index=num_j1;% frame index from a set of indexed movies 3677 3681 end 3678 3682 end … … 3988 3992 % TODO: look for time unit attribute 3989 3993 elseif ~isempty(regexp(TimeName,'^dim:', 'once')) 3990 abstime=str2double(get(handles. i1,'String'));3994 abstime=str2double(get(handles.num_i1,'String')); 3991 3995 TimeUnit='index'; 3992 3996 end … … 4873 4877 set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])% put file index in the root name 4874 4878 set(handles.NomType,'String','') 4875 set(handles. i1,'String','1')% set counter to 1 (now the time index in the input matrix)4879 set(handles.num_i1,'String','1')% set counter to 1 (now the time index in the input matrix) 4876 4880 MaxIndex_i=get(handles.MaxIndex_i,'String'); 4877 4881 MaxIndex_i{1}=num2str(GetFieldData.Time.TimeDimension); … … 4885 4889 set(handles.NomType,'String','*') 4886 4890 set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) 4887 set(handles. i1,'String','1')% set counter to 1 (now the time index in the input matrix)4891 set(handles.num_i1,'String','1')% set counter to 1 (now the time index in the input matrix) 4888 4892 MaxIndex_i=get(handles.MaxIndex_i,'String'); 4889 4893 MaxIndex_i{1}=num2str(GetFieldData.Time.TimeDimension); … … 5208 5212 UvData.FileName_1='';% desactivate the use of a constant second file 5209 5213 set(handles.uvmat,'UserData',UvData) 5210 num_i1=stra2num(get(handles. i1,'String'));5211 num_i2=stra2num(get(handles. i2,'String'));5212 num_j1=stra2num(get(handles. j1,'String'));5213 num_j2=stra2num(get(handles. j2,'String'));5214 num_i1=stra2num(get(handles.num_i1,'String')); 5215 num_i2=stra2num(get(handles.num_i2,'String')); 5216 num_j1=stra2num(get(handles.num_j1,'String')); 5217 num_j2=stra2num(get(handles.num_j2,'String')); 5214 5218 [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(['xx' FileIndex_1]); 5215 5219 errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); … … 6297 6301 % Hints: contents = cellstr(get(hObject,'String')) returns LogLinHisto contents as cell array 6298 6302 % contents{get(hObject,'Value')} returns selected item from LogLinHisto 6299 6300 6301 6302
Note: See TracChangeset
for help on using the changeset viewer.
