| 1 | %'check_field_series': checks the existence and type of the input file series |
|---|
| 2 | %------------------------------------------------------------------------ |
|---|
| 3 | % function GUIParam=check_data_files(Param) |
|---|
| 4 | % |
|---|
| 5 | %%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 6 | %OUTPUT |
|---|
| 7 | % GUISeriesParam=list of options in the GUI series.fig needed for the function |
|---|
| 8 | % |
|---|
| 9 | %INPUT: |
|---|
| 10 | % In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series. |
|---|
| 11 | % In batch mode, Param is the name of the corresponding xml file containing the same information |
|---|
| 12 | % In the absence of input (as activated when the current Action is selected |
|---|
| 13 | % in series), the function ouput GUI_input set the activation of the needed GUI elements |
|---|
| 14 | |
|---|
| 15 | function GUIParam=check_field_series(Param) |
|---|
| 16 | |
|---|
| 17 | GUIParam=[]; |
|---|
| 18 | |
|---|
| 19 | %% input preparation mode (no RUN) |
|---|
| 20 | if isstruct(Param) && isequal(Param.Action.RUN,0) |
|---|
| 21 | GUIParam.OutputSubDirMode='auto'; %(options 'none'/'custom'/'auto'/'first'/'last','auto' by default) |
|---|
| 22 | GUIParam.OutputDirExt='.check_fields';%set the output dir extension |
|---|
| 23 | msgbox_uvmat('CONFIMATION','This function will check the series of input fields') |
|---|
| 24 | return |
|---|
| 25 | end |
|---|
| 26 | %------------------------------------------------------------------------ |
|---|
| 27 | |
|---|
| 28 | %% read input parameters from an xml file if input is a file name (batch mode) |
|---|
| 29 | if ischar(Param) |
|---|
| 30 | Param=xml2struct(Param);% read Param as input file (batch case) |
|---|
| 31 | end |
|---|
| 32 | |
|---|
| 33 | %% root input file(s) and type |
|---|
| 34 | RootPath=Param.InputTable{1,1}; |
|---|
| 35 | SubDir=Param.InputTable{1,2}; |
|---|
| 36 | RootFile=Param.InputTable{1,3}; |
|---|
| 37 | NomType=Param.InputTable{1,4}; |
|---|
| 38 | FileExt=Param.InputTable{1,5}; |
|---|
| 39 | |
|---|
| 40 | %% scans the series indexed with i and j |
|---|
| 41 | i_index=Param.IndexRange.first_i:Param.IndexRange.incr_i:Param.IndexRange.last_i; |
|---|
| 42 | j_index=Param.IndexRange.first_j:Param.IndexRange.incr_j:Param.IndexRange.last_j; |
|---|
| 43 | FileCell=cell(numel(j_index),numel(i_index));%initiate cell array of input file names |
|---|
| 44 | for ifile=1:numel(i_index) |
|---|
| 45 | for jfile=1:numel(j_index) |
|---|
| 46 | FullFileName=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i_index(ifile),[],j_index(jfile)); |
|---|
| 47 | FileName=fullfile_uvmat('','',RootFile,FileExt,NomType,i_index(ifile),[],j_index(jfile));%name without path |
|---|
| 48 | if exist(FullFileName,'file') |
|---|
| 49 | FileInfo=get_file_info(FullFileName);% get the info on the file |
|---|
| 50 | FileCell{jfile,ifile}=[FileName ': ' FileInfo.FileType]; |
|---|
| 51 | else |
|---|
| 52 | FileCell{jfile,ifile}=[FileName ': missing']; |
|---|
| 53 | end |
|---|
| 54 | end |
|---|
| 55 | end |
|---|
| 56 | |
|---|
| 57 | %% transform cell arrays into text and display in workspace |
|---|
| 58 | OutputText = strjoin(FileCell, '\n'); %transform cell arrays into text |
|---|
| 59 | disp(OutputText) %display the list of files |
|---|
| 60 | |
|---|
| 61 | %% save the list in the appropriate output folder |
|---|
| 62 | OutputPath=fullfile(Param.OutputPath,Param.Experiment,Param.Device); |
|---|
| 63 | OutputSubDir=[Param.OutputSubDir Param.OutputDirExt]; |
|---|
| 64 | FullOutputFile=fullfile_uvmat(OutputPath,OutputSubDir,RootFile,'.txt','1-2',i_index(1),i_index(end)) |
|---|
| 65 | writelines(OutputText,FullOutputFile); |
|---|
| 66 | |
|---|
| 67 | 'END' |
|---|
| 68 | |
|---|