diff --git a/+PlotID/Publish.m b/+PlotID/Publish.m index f7c55a298a4e45ba0ad32b60523c5cfb35f850c2..b701698a1685bd6ccc47a4d9ec185a83a40a7c30 100644 --- a/+PlotID/Publish.m +++ b/+PlotID/Publish.m @@ -1,4 +1,4 @@ -function Publish(DataPaths,scriptPath, ID, figure, options) +function Publish(DataPaths,scriptPath, figure, options) %%Publish(DataPaths,scriptPath, ID, figure, options) saves plot, data and measuring script % % DataPaths contains the path(s) to the research data, for multiple files @@ -20,7 +20,6 @@ function Publish(DataPaths,scriptPath, ID, figure, options) arguments DataPaths {mustBeDataPath} % location of the data-file(s) scriptPath (1,:) {mustBeFile} % location of the matlab script - ID (1,:) {mustBeNonzeroLengthText} % ID must be provided figure (1,:) {mustBeFigure} % Checks if figure is a figure object options.Location {mustBeMember(options.Location ,{'local','server','manual','CI-Test'})} = 'local' % storage path options.Method {mustBeMember(options.Method ,{'individual','centralized'})} = 'individual' @@ -29,6 +28,7 @@ arguments options.CSV (1,1) {mustBeNumericOrLogical} = false end +%% argument validation %catch multiple figures in fig if numel(figure) > 1 figure = figure(1); @@ -38,6 +38,20 @@ if numel(figure) > 1 warning(msg); end +%get ID from Figure + +ID = figure.Tag; +if isempty(ID) + % no ID found, User dialog for Folder name + ID = inputdlg(['No ID defined- ' newline,... + 'Please enter a folder name to continue:'],'Please enter a folder name'); + ID = ID{1}; + msg = ['No ID found - consider to use the TagPlot function before ',... + 'you publish ', newline, 'your files will be stored in ' , ID]; + warning(msg); +end + + %% read config file try txt = fileread('config.json'); diff --git a/CI_files/default_test.m b/CI_files/default_test.m index 110a1ba207ffb9984c3ed9b5222f7edefa4e9b75..ede005b2437db6ff8435939ed22118d9bacc24c6 100644 --- a/CI_files/default_test.m +++ b/CI_files/default_test.m @@ -56,7 +56,7 @@ try % file name of the data rdata = {dataset1,dataset2} ; % don't forget the extension - PlotID.Publish(rdata,script, ID, figs, 'Location', 'CI-Test') + PlotID.Publish(rdata,script, figs, 'Location', 'CI-Test') result = true; % clean up diff --git a/README.md b/README.md index 85a19827dfe9ae3a4b53ee1af392c5bd47ba8a5e..8204d768d5a8083238850def6029b92ba4e69960 100644 --- a/README.md +++ b/README.md @@ -15,17 +15,17 @@ Feel free to give feedback and feature requests or to take part in the developme 1. tagging the plot `[figs, IDs] = plotId.TagPlot(figs, options)` +You should either set a ProjectID in the config.json (copy & rename the 'example-config.json' to 'config.json'), or pass it as option 'ProjectID' to the TagPlot function. - -2. publishing the plot and the associated data -`plotID.Publish(DataPaths,scriptPath, ID, figure, options)` +2. publish the plot and the associated data +`plotID.Publish(DataPaths,scriptPath, figure, options)` `scriptPath` contains the path to the script, this can be provided with the simple call of `scriptPath = [mfilename('fullpath'),'.m']`, note that **the extension is mandatory.** `DataPaths` contains the path(s) to the research data, for multiple files you can use a cell arrays (they must be at the path). - -You should either set a ProjectID in the config.json (copy & rename the 'example-config.json' to 'config.json'), or pass it as option 'ProjectID' to the TagPlot function. +`figure` is the figure that should be published. + # PlotID.TagPlot() `[figs, IDs] = TagPlot(figs, options)` @@ -64,7 +64,7 @@ FriendlyID Changes the Hex Number to a human friendly *datetime* and *dateStr*. # PlotID.Publish() -`Publish(DataPaths,scriptPath, ID, figure, options)` \ +`Publish(DataPaths,scriptPath, figure, options)` \ Publishes saves plot, data and measuring script Location sets the storage location. 'local' sets the storage location to the current folder (an export folder will be created), 'server' is a remote path, that is defined in the config file. Two Methods are implemented 'individual' stores the data for each plot while 'centralized' uses a data folder and uses reference links to the original data (hdf5 only). ParentFolder is the folder Name where the exported data is stored if a path is used, PlotId will use this path a storagePath diff --git a/example.m b/example.m index df343c0e1d4607019a4f57fab6e4370217804991..de981f8dab90a75f801f7314aafc33d1bfbbb660 100644 --- a/example.m +++ b/example.m @@ -78,7 +78,7 @@ locations = {dataset1,dataset2} ; % don't forget the extension %locations = {'test_data.mat', 'falsch'}; %call publishing -PlotID.Publish(locations,scriptPath, ID, fig(1), 'Location', 'local' ,'Method','individual') +PlotID.Publish(locations,scriptPath, fig(1), 'Location', 'local' ,'Method','individual') %% Example 2: multiple plots plot, all based on dataset2 (hdf5) % for individual data-sets, use an appropriate array @@ -99,7 +99,7 @@ rdata = dataset2 ; % don't forget the extension % publsihing via a for-loop for i=1: numel(fig) - PlotID.Publish(rdata, script, IDs{i}, fig(i), 'Location', 'local',... + PlotID.Publish(rdata, script, fig(i), 'Location', 'local',... 'Method','individual'); end @@ -117,4 +117,4 @@ plot(x1,y1,'-r'); [fig2, ID] = PlotID.TagPlot(fig2,'ProjectID', ProjectID); -PlotID.Publish(locations,scriptPath, ID, fig2, 'Location', 'local','Method','centralized') +PlotID.Publish(locations,scriptPath, fig2, 'Location', 'local','Method','centralized')