Home > functions > internal > dsImg2mdd.m

dsImg2mdd

PURPOSE ^

SYNOPSIS ^

function xp = dsImg2mdd(data_img,merge_covaried_axes,merge_sparse_axes,varargin)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function xp = dsImg2mdd(data_img,merge_covaried_axes,merge_sparse_axes,varargin)
0002 
0003     if nargin < 2
0004         merge_covaried_axes = true;
0005     end
0006     
0007     if nargin < 3
0008         merge_sparse_axes = true;
0009     end
0010     
0011 % % % % % % % % % % % % % % %  Merge data varied statements if necessary % % % % %
0012     if merge_covaried_axes && isfield(data_img(1),'varied')
0013         % Remove any data in data(1...N) that is empty (e.g. skipped by
0014         % the simulator)
0015         % (Not relevant for xp_img!!)
0016         
0017 
0018         
0019         % Identified covaried axes (note; this will fail if
0020         [Abasis,Abasisi, Asubs] = dsGetLinearIndependentDs(data_img);
0021         
0022         gt1 = cellfun(@(x) length(x) > 1, Asubs);  % Identified all linked indices with at least 2 varieds
0023         Asubs = Asubs(gt1);                  % Only perform the merge if there are at least 2 varieds to merge!
0024         
0025         
0026 
0027         % Merge eached linked_ind into a single varied statement
0028         vary_labels = data_img(1).varied; % data(1).simulator_options.vary;
0029         Nlinked = length(Asubs);
0030         variedname_merged = cell(1,Nlinked);
0031         varied_vals = cell(1,Nlinked);
0032         for j = 1:Nlinked
0033             [data_img, variedname_merged{j}, varied_vals{j} ] = dsMergeVarieds(data_img,vary_labels(Asubs{j}));
0034         end
0035         
0036         % Automerge any additional dimensions based on analysis of
0037         % sparseness
0038         
0039     end
0040     
0041     if merge_sparse_axes && isfield(data_img(1),'varied')
0042         [data_img, variedname_merged, varied_vals ] = dsAutoMergeVarieds(data_img);
0043     end
0044     
0045 % % % % % % % % % % % % % % % Merging is complete % % % % % % % %
0046 
0047     % Load into DynaSim structure
0048     [data_table,column_titles] = dsDataField2Table (data_img,'plot_files');
0049 
0050     % The entries in the first column contain the paths to the figure files.
0051     % There can be multiple figures associated with each simulation, which is
0052     % why these are cell arrays of strings.
0053     %disp(data_table{1}{1})
0054     %disp(data_table{1}{2})
0055 
0056     % Import the linear data into an MDD object
0057     xp = MDD;
0058     X = data_table{1}; axislabels = data_table(2:end);
0059     xp = xp.importDataTable(X, axislabels);
0060     xp = xp.importAxisNames(column_titles(2:end));
0061 
0062     % Squeeze out any empty dims that might have been introduced by the
0063     % above operations. This is necessary if xp was originally 2x1 (e.g.
0064     % varied1 x Dim 1) and then added populations and variables onto this
0065     % after Dim 1
0066     xp = xp.squeezeRegexp('Dim');
0067     
0068     % Set up metadata
0069     % Store metadata info (putting random info in here for time being)
0070     meta = struct;
0071     meta.datainfo(1:2) = MDDAxis;
0072     meta.datainfo(1).name = 'time(ms)';
0073     meta.datainfo(1).values = 1:10;
0074     meta.datainfo(2).name = 'cells';
0075         cell_names = [1:5];
0076         cell_names_str = cellfunu(@(s) ['Cell ' num2str(s)], num2cell(cell_names));
0077     if isfield(data_img(1),'varied')
0078         meta.dynasim.varied = data_img(1).varied;
0079     else
0080         % For case when nothing varied, insert some dummy data
0081         meta.dynasim.varied = {'Varied1'};
0082     end
0083     xp.meta = meta;
0084     
0085     
0086     
0087 end

Generated on Tue 12-Dec-2017 11:32:10 by m2html © 2005