0001 function [data,studyinfo] = dsImportPlots(file,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 options=dsCheckOptions(varargin,{...
0022 'verbose_flag',1,{0,1},...
0023 'process_id',[],[],...
0024 'time_limits',[],[],...
0025 'variables',[],[],...
0026 'simIDs',[],[],...
0027 },false);
0028
0029 if ischar(options.variables)
0030 options.variables = {options.variables};
0031 end
0032
0033
0034 if ischar(file) && isdir(file)
0035 study_dir = file;
0036 clear file
0037 file.study_dir = study_dir;
0038 end
0039
0040 if isstruct(file) && isfield(file,'study_dir')
0041
0042
0043 studyinfo = dsCheckStudyinfo(file.study_dir,'process_id',options.process_id, varargin{:});
0044
0045
0046 if ~isempty(options.simIDs)
0047 [~,~,simsInds] = intersect(options.simIDs, [studyinfo.simulations.sim_id]);
0048 end
0049
0050
0051 for i = 1:length(studyinfo.simulations)
0052 for j = 1:length(studyinfo.simulations(i).result_files)
0053 rf_orig = studyinfo.simulations(i).result_files{j};
0054 if ~exist(rf_orig,'file')
0055 [~,fname,fext] = fileparts(rf_orig);
0056 rf_new = fullfile(file.study_dir,'plots',[fname,fext]);
0057 end
0058 studyinfo.simulations(i).result_files{j} = rf_new;
0059 end
0060 end
0061
0062
0063 if isempty(options.simIDs)
0064 result_firsts = arrayfun(@(s) s.result_files{1},studyinfo.simulations,'UniformOutput',0);
0065 sim_info = studyinfo.simulations;
0066 else
0067 result_firsts = arrayfun(@(s) s.result_files{1},studyinfo.simulations(simsInds),'UniformOutput',0);
0068 sim_info = studyinfo.simulations(simsInds);
0069 end
0070
0071
0072 success = cellfun(@(x) ~isempty(dir([x '*'])),result_firsts);
0073 sim_info = sim_info(success);
0074
0075 tmp_data = struct;
0076 for i = 1:length(sim_info)
0077 modifications=sim_info(i).modifications;
0078 tmp_data = dsModifications2Vary(tmp_data,modifications);
0079 if ~isempty(modifications)
0080 tmp_data = dsModifications2Vary(tmp_data,modifications);
0081 end
0082
0083
0084 result_files = sim_info(i).result_files;
0085
0086
0087 result_files2 = cellfun(@(x) ls([x, '*']),result_files,'UniformOutput',0);
0088 result_files3 = cellfun(@(x) x(1:end-1),result_files2,'UniformOutput',0);
0089 tmp_data.plot_files = result_files3;
0090
0091 data(i) = tmp_data;
0092
0093 end
0094 end
0095
0096 end