Changeset 1002 for trunk/src/series/extract_multitif.m
- Timestamp:
- Feb 28, 2017, 10:41:54 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/extract_multitif.m
r977 r1002 59 59 %======================================================================= 60 60 61 function ParamOut=extract_multitif (Param)61 function ParamOut=extract_multitif_parallel(Param) 62 62 63 63 %%%%%%%%%%%%%%%%% INPUT PREPARATION MODE (no RUN) %%%%%%%%%%%%%%%%% … … 65 65 ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default) 66 66 ParamOut.WholeIndexRange='on';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) 67 ParamOut.NbSlice= 1; % impose calculation in a single process (no parallel processing to avoid 'holes'))67 ParamOut.NbSlice='off'; % impose calculation in a single process (no parallel processing to avoid 'holes')) 68 68 ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default) 69 69 ParamOut.FieldName='off';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) … … 73 73 ParamOut.OutputDirExt='.png';%set the output dir extension 74 74 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 75 ParamOut.CheckOverwriteVisible='on'; % manage the overwrite of existing files (default=1)75 ParamOut.CheckOverwriteVisible='on'; % manage the overwrite of existing files (default=1) 76 76 %% root input file(s) and type 77 77 % check the existence of the first file in the series … … 95 95 return 96 96 end 97 xmlinput=uigetfile_uvmat('pick xml file for timing',fileparts(fileparts(FirstFileName)),'.xml'); 98 [tild,ParamOut.ActionInput.XmlFile]=fileparts(xmlinput); 99 ParamOut.ActionInput.XmlFile 100 97 ParamOut.ActionInput.XmlFile=uigetfile_uvmat('pick xml file for timing',fileparts(fileparts(FirstFileName)),'.xml'); 101 98 return 102 99 end … … 111 108 checkrun=0; 112 109 else 113 hseries=findobj(allchild(0),'Tag','series');114 RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series115 WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series110 hseries=findobj(allchild(0),'Tag','series'); 111 RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series 112 WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series 116 113 end 117 114 118 115 %% list of input images 119 DirImages=fullfile(Param.InputTable{1,1},Param.InputTable{1,2});120 ListStruct=dir(DirImages); 121 ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray122 check_bad=strcmp('.',ListCells(1,:))|strcmp('..',ListCells(1,:));%detect the dir '.' to exclude it123 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files124 ListFile=ListCells(1,find(~check_dir & ~check_bad));116 % DirImages=fullfile(Param.InputTable{1,1},Param.InputTable{1,2}); 117 % ListStruct=dir(DirImages); 118 % ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray 119 % check_bad=strcmp('.',ListCells(1,:))|strcmp('..',ListCells(1,:));%detect the dir '.' to exclude it 120 % check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 121 % ListFile=ListCells(1,find(~check_dir & ~check_bad)); 125 122 126 123 %% check file names 127 RootName=regexprep(ListFile{1},'.tif$','') 128 for ilist=2:numel(ListFile) 129 rank=regexprep(ListFile{ilist},'.tif$',''); 130 rank=regexprep(rank,['^' RootName '@'],''); 131 if ~isequal(str2num(rank),ilist-1) 132 disp(['error in the list of input file # ' num2str(ilist-1)]) 133 return 134 end 135 end 124 % RootName=regexprep(ListFile{1},'.tif$','') 125 % rank(1)=1; 126 % for ilist=2:numel(ListFile) 127 % rank_str=regexprep(ListFile{ilist},'.tif$',''); 128 % rank(ilist)=regexprep(rank_str,['^' RootName '@'],''); 129 % % if ~isequal(str2num(rank),ilist-1) 130 % % disp(['error in the list of input file # ' num2str(ilist-1)]) 131 % % return 132 % % end 133 % end 136 134 137 135 %% output directory 138 OutputDir=fullfile(Param.InputTable{1,1},[Param.OutputSubDir Param.OutputDirExt]); 139 140 %% Timing 141 XmlInputFile=fullfile(Param.InputTable{1,1},[Param.ActionInput.XmlFile '.xml']) 142 XmlInput=imadoc2struct(XmlInputFile,'Camera'); 136 OutputDir=fullfile(Param.InputTable{1,1},[Param.OutputSubDir Param.OutputDirExt]); 137 138 %% Timing 139 XmlInputFile=Param.ActionInput.XmlFile; 140 [XmlInput,errormsg]=imadoc2struct(XmlInputFile,'Camera'); 141 if ~isempty(errormsg) 142 disp(['bad xml input file: ' errormsg]) 143 return 144 end 145 ImagesPerLevel=size(XmlInput.Time,2)-1;%100;%use the xmlinformation to get the nbre of j indices 146 147 %% create the xml file of PCO camera if it does not exist 148 Newxml=fullfile(Param.InputTable{1,1},[Param.InputTable{1,2} '.xml']); 149 if ~exist(Newxml,'file') 150 XmlInput.Camera.CameraName='PCO'; 151 XmlInput=rmfield(XmlInput,'Time'); 152 XmlInput=rmfield(XmlInput,'TimeUnit'); 153 t=struct2xml(XmlInput); 154 t=set(t,1,'name','ImaDoc'); 155 save(t,Newxml); 156 end 143 157 144 158 %% Main loop 145 159 146 ImagesPerLevel=size(XmlInput.Time,2)-1;%100; 147 count=0;160 161 % count=0; 148 162 %count=316;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%CORRECTION EXP08: 4684 images -> start at 316 start 67->_11_1 149 163 %count=1934%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%CORRECTION EXP07: 3066 images 150 %% loop on the files 151 for ifile=1:numel(ListFile) 152 update_waitbar(WaitbarHandle,ifile/numel(ListFile)) 153 if ~isempty(RUNHandle)&& ~strcmp(get(RUNHandle,'BusyAction'),'queue')154 disp('program stopped by user')155 break 156 end157 ImageName=fullfile( DirImages,ListFile{ifile});164 %% loop on the files 165 % include the first tiff file with no index in the first iteration 166 if Param.IndexRange.first_i==1% first slice of processing 167 firstindex=0; 168 count=0; 169 else 170 firstindex=Param.IndexRange.first_i; 171 ImageName=fullfile(Param.InputTable{1,1},Param.InputTable{1,2},'im.tif'); 158 172 NbFrames=numel(imfinfo(ImageName)); 159 % loop on the frames within the tiff file 160 for iframe=1:NbFrames 173 count=Param.IndexRange.first_i*NbFrames; 174 end 175 for ifile=firstindex:Param.IndexRange.last_i 176 if firstindex==0 && ifile==0% first slice of processing 177 ImageName=fullfile(Param.InputTable{1,1},Param.InputTable{1,2},'im.tif') 178 else 179 ImageName=fullfile(Param.InputTable{1,1},Param.InputTable{1,2},['im@' num2str(ifile,'%04d') '.tif']) 180 end 181 NbFrames=numel(imfinfo(ImageName)); 182 for iframe=1:NbFrames 183 iframe 161 184 if isequal(ImagesPerLevel,1)% mode series 162 i_index=count+1;163 185 OutputFile=fullfile(OutputDir,['img_' num2str(count+1) '.png']); 164 186 else % indices i and j … … 178 200 end 179 201 180 % for ifile=1:numel(ListFile) 181 % update_waitbar(WaitbarHandle,ifile/numel(ListFile)) 182 % if ~isempty(RUNHandle)&& ~strcmp(get(RUNHandle,'BusyAction'),'queue') 183 % disp('program stopped by user') 184 % break 185 % end 186 % ImageName=fullfile(DirImages,ListFile{ifile}); 187 % NbFrames=numel(imfinfo(ImageName)); 188 % % loop on the frames within the tiff file 189 % for iframe=1:NbFrames 190 % A=imread(ImageName,iframe); 191 % 192 % if isequal(ImagesPerLevel,1)% mode series 193 % i_index=count+1; 194 % OutputFile=fullfile(OutputDir,['img_' num2str(count+1) '.png']); 195 % else % indices i and j 196 % i_index=fix(count/ImagesPerLevel)+1; 197 % j_index=mod(count,ImagesPerLevel)+1; 198 % OutputFile=fullfile(OutputDir,['img_' num2str(i_index) '_' num2str(j_index) '.png']); 199 % end 200 % imwrite(A,OutputFile,'BitDepth',16) 201 % count=count+1; 202 % end 203 % end 204 205 %% create the xml file of PCO camera 206 XmlInput.Camera.CameraName='PCO'; 207 t=struct2xml(XmlInput.Camera); 208 t=set(t,1,'name','ImaDoc'); 209 save(t,fullfile(Param.InputTable{1,1},'PCO.xml')) 210 211 %% remove initial files if transfer OK 212 % if i_index== (size(XmlInput.Time,1)-1) 213 % 214 % [SUCCESS,MESSAGE]=rmdir(DirImages,'s') 215 % 216 % end 202 203
Note: See TracChangeset
for help on using the changeset viewer.