Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
plotID_matlab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
plotID
plotID_matlab
Commits
3fa2c871
Commit
3fa2c871
authored
3 years ago
by
Lemmer, Jan
Browse files
Options
Downloads
Patches
Plain Diff
fix typos and add comments
parent
7ec3ff6a
No related branches found
No related tags found
2 merge requests
!43
Implements #73, cleans up example file,
,
!41
fix typos and add comments
Pipeline
#597464
failed
3 years ago
Stage: Run
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
+PlotID/Publish.m
+34
-29
34 additions, 29 deletions
+PlotID/Publish.m
+PlotID/TagPlot.m
+4
-3
4 additions, 3 deletions
+PlotID/TagPlot.m
+PlotID/createFileCopy.m
+2
-2
2 additions, 2 deletions
+PlotID/createFileCopy.m
PlotID_example.m
+17
-15
17 additions, 15 deletions
PlotID_example.m
with
57 additions
and
49 deletions
+PlotID/Publish.m
+
34
−
29
View file @
3fa2c871
...
...
@@ -4,18 +4,26 @@ function Publish(DataPaths,scriptPath, figure, options)
% DataPaths contains the path(s) to the research data, for multiple files
% use a cell array
% 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
% the simple call of scriptPath = [mfilename('fullpath'),'.m']
%
% Options:
% Location sets the storage location. 'local' sets the storage location
% to the current folder (an export folder will be created), 'server' is a
% to the current folder (an export folder will be created), 'manual' opens
% a explorer window, where you can choose the folder. If you define a export
% path in the config file, this will used per default.
% 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 an
%
'
ParentFolder
'
is the folder Name where the exported data is stored if an
% path is used, PlotId will use this path a storagePath
% 'ConfigFileName' is needed for handling multiple config files (see example)
% 'CSV' turns a summary table of all exports on or off
%
% DebugOptions:
% 'ShowMessage' and 'ForcePublish' are mainly for debugging.
% 'ShowMessage' will display Messages for every step of PlotID,
% 'ForcePublish' will publish even if one step was not successful (not recommended)
arguments
DataPaths
{
mustBeDataPath
}
% location of the data-file(s)
...
...
@@ -23,11 +31,11 @@ arguments
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'
options
.
ParentFolder
(
1
,:)
{
mustBeText
}
=
'
export'
options
.
ParentFolder
(
1
,:)
{
mustBeText
}
=
'
PlotID_export'
% name of the ParentFolder
options
.
ConfigFileName
(
1
,:)
{
mustBeText
}
=
'config.json'
%individual config names possible
options
.
CopyUserFCN
(
1
,
1
)
{
mustBeNumericOrLogical
}
=
true
options
.
CSV
(
1
,
1
)
{
mustBeNumericOrLogical
}
=
fals
e
options
.
ShowMessages
(
1
,
1
)
{
mustBeNumericOrLogical
}
=
true
options
.
CSV
(
1
,
1
)
{
mustBeNumericOrLogical
}
=
tru
e
options
.
ShowMessages
(
1
,
1
)
{
mustBeNumericOrLogical
}
=
false
options
.
ForcePublish
(
1
,
1
)
{
mustBeNumericOrLogical
}
=
false
%publish anyway
end
...
...
@@ -38,7 +46,7 @@ if ~iscell(DataPaths)
DataPaths
=
{
DataPaths
};
%Cell array
end
% strings will cause problems,
we
therfore
use
chars
% strings will cause problems, ther
e
fore chars
are used
for
i
=
1
:
numel
(
DataPaths
)
if
isstring
(
DataPaths
{
i
})
DataPaths
{
i
}
=
char
(
DataPaths
{
i
});
...
...
@@ -52,7 +60,7 @@ end
%catch multiple figures in fig
if
numel
(
figure
)
>
1
figure
=
figure
(
1
);
msg
=
[
'Publish is designed for hand
e
ling one figure at once'
newline
,
...
msg
=
[
'Publish is designed for handling one figure at once'
newline
,
...
'- publishes uses only the first figure.'
newline
,
...
'Consider an external for loop for multi figure export as provided in example.m'
];
warning
(
msg
);
...
...
@@ -68,7 +76,7 @@ end
ID
=
figure
.
Tag
;
if
isempty
(
ID
)
% no ID found,
U
ser dialog for
F
older name
% no ID found,
u
ser dialog for
f
older name
ID
=
inputdlg
([
'No ID defined- '
newline
,
...
'Please enter a folder name to continue:'
],
'Please enter a folder name'
);
ID
=
ID
{
1
};
...
...
@@ -80,7 +88,7 @@ end
%% read config file
% there is only one config Object (handleClass)
configObj
=
PlotID
.
config
(
options
.
ConfigFileName
);
% a
d
d user options
%
re
ad user options
from config and set them for Publish
if
isfield
(
configObj
.
configData
,
'options'
)
fldnames
=
fieldnames
(
configObj
.
configData
.
options
);
for
ii
=
1
:
numel
(
fldnames
)
...
...
@@ -89,10 +97,9 @@ if isfield(configObj.configData, 'options')
end
end
%
E
rror and MSG hand
e
ling
%
e
rror and MSG handling
object
dlgObj
=
PlotID
.
userDLG
(
ID
,
options
);
%% storage location
switch
options
.
Location
case
'local'
...
...
@@ -103,7 +110,7 @@ switch options.Location
scriptLocation
=
fileparts
(
scriptPath
);
storPath
=
fullfile
(
scriptLocation
,
options
.
ParentFolder
);
end
case
'exportPath'
%legacy
case
'exportPath'
if
isfolder
(
configObj
.
exportPath
)
storPath
=
configObj
.
exportPath
;
else
...
...
@@ -120,7 +127,7 @@ switch options.Location
storPath
=
configObj
.
configData
.
ServerPath
;
case
'manual'
%UI
storPath
=
uigetdir
();
case
'CI-Test'
case
'CI-Test'
%only for CI tests
storPath
=
fullfile
(
pwd
,
'CI_files'
,
options
.
ParentFolder
);
end
...
...
@@ -129,7 +136,7 @@ folderNameV = char(ID); %visible Folder
%% Create data directory
overwriteDir
=
false
;
% if invisible Folder exists, delete it (publish was not succesful
l
before)
% if invisible Folder exists, delete it (publish was not succes
s
ful before)
if
isfolder
(
fullfile
(
storPath
,
folderName
))
rmdir
(
fullfile
(
storPath
,
folderName
),
's'
)
end
...
...
@@ -145,7 +152,7 @@ if isfolder(fullfile(storPath,folderNameV))
return
;
%terminate
end
end
% create folder
% create
the
folder
if
~
mkdir
(
fullfile
(
storPath
,
folderName
))
dlgObj
.
error
(
'Directory could not be created - check remote path and permissions'
);
end
...
...
@@ -162,13 +169,13 @@ dlgObj.userMSG(msg);
if
options
.
CopyUserFCN
fList
=
fList
(
~
ismember
(
fList
,
scriptPath
));
% rmv script from list
fList
=
fList
(
~
contains
(
fList
,
'config.json'
));
% rmv config.json from list
fList
=
PlotID
.
removePltIdFiles
(
fList
);
% Do not copy files that are part of
p
lot
ID
fList
=
PlotID
.
removePltIdFiles
(
fList
);
% Do not copy files that are part of
P
lotID
if
~
isempty
(
fList
)
PlotID
.
createFileCopy
(
fList
,
folderName
,
storPath
,
ID
,
'userFcn'
);
end
end
%% Research data hand
e
ling
%% Research data handling
switch
options
.
Method
case
'centralized'
DataFolderName
=
'data'
;
...
...
@@ -259,12 +266,12 @@ catch
dlgObj
.
softError
(
'Plot export was not successful'
);
end
%% final renaming and error/warning hand
e
ling
% if no error o
r
curred or if force publish is activated, rename the hidden
%% final renaming and error/warning handling
% if no error o
c
curred or if force publish is activated, rename the hidden
% folder to a non hidden one, otherwise delete it.
if
dlgObj
.
success
||
options
.
ForcePublish
oldPath
=
fullfile
(
storPath
,
folderName
);
newPath
=
strrep
(
oldPath
,
'.'
,
''
);
%remov dot
newPath
=
strrep
(
oldPath
,
'.'
,
''
);
%remov
e
dot
if
overwriteDir
rmdir
(
newPath
,
's'
);
dlgObj
.
userMSG
([
'old export '
,
folderNameV
,
' deleted'
]);
...
...
@@ -272,8 +279,7 @@ if dlgObj.success || options.ForcePublish
status
=
movefile
(
oldPath
,
newPath
);
%rename directory
end
%% CSV EXport
% ToDo exclude in function
%% CSV export
if
options
.
CSV
T
=
table
();
T
.
research_Data
=
DataPaths
'
;
T
.
PlotID
(:)
=
{
ID
};
...
...
@@ -286,9 +292,8 @@ if options.CSV
end
if
status
disp
([
'publishing of '
,
ID
,
' to '
,
newPath
,
' done'
]);
%always displayed onsucess
else
% publish was not sucessfull!
%replace with error from userDLG Class
disp
([
'publishing of '
,
ID
,
' to '
,
newPath
,
' done'
]);
%always displayed on success
else
% publish was not successful!
dlgObj
.
error
([
'publishing of '
,
ID
,
' failed'
])
end
...
...
This diff is collapsed.
Click to expand it.
+PlotID/TagPlot.m
+
4
−
3
View file @
3fa2c871
...
...
@@ -2,15 +2,17 @@ function [figs, IDs] = TagPlot(figs, options)
%TagPlot adds IDs to figures
% The ID is placed visual on the figure window and as Tag (property of figure)
% TagPlot can tag multiple figures at once.
% If a single Plot is taged IDs is a char, otherwise it is a cell array of
% If a single Plot is tag
g
ed IDs is a char, otherwise it is a cell array of
% chars
% options.ProjectID is the project number (string or char), if empty the ID from the
% config file is used
%
% The ID is placed on the 'east' per default, if you want it somwhere
% The ID is placed on the 'east' per default, if you want it som
e
where
% else, use the 'Location' option. 'north','east','south','west' are
% predefined, otherwise use the 'custom' option and provide the desired
% 'Position' (relative to your x- and y-axis limits)
% 'ConfigFileName' is the config-file which is used for the ProjectID
% If you use multiple config files you need to use this option.
arguments
figs
(
1
,:)
{
mustBeFigure
}
options
.
ProjectID
(
1
,:)
{
mustBeText
}
=
''
...
...
@@ -76,7 +78,6 @@ for n = 1:numel(figs)
ylim
=
get
(
axes
,
'YLim'
);
xlim
=
get
(
axes
,
'XLim'
);
%ID
position
=
[
options
.
Position
(
1
),
options
.
Position
(
2
)];
text
(
axes
,
position
(
1
),
position
(
2
),
IDs
{
n
},
'Fontsize'
,
options
.
Fontsize
,
...
'Rotation'
,
Rotation
,
'VerticalAlignment'
,
'bottom'
,
'Color'
,
...
...
...
This diff is collapsed.
Click to expand it.
+PlotID/createFileCopy.m
+
2
−
2
View file @
3fa2c871
...
...
@@ -4,7 +4,7 @@ function [storagePaths, status, msg] = createFileCopy(filePaths,folderName,storP
% returns the storage paths were files were stored
if
~
iscell
(
filePaths
)
%fixes Issue if
F
ilepath is a char and not a cell array
%fixes Issue if
f
ilepath is a char and not a cell array
filePaths
=
{
filePaths
};
end
...
...
@@ -72,7 +72,7 @@ try
msg
=
([
type
,
' successfully published'
]);
catch
status
=
false
;
warning
([
type
,
' export was not sucessful'
])
warning
([
type
,
' export was not suc
c
essful'
])
if
exist
(
'errorMSG'
)
error
(
errorMSG
);
end
...
...
This diff is collapsed.
Click to expand it.
PlotID_example.m
+
17
−
15
View file @
3fa2c871
%% Example Script
% This Script is men
t
to demonstrate the capabilities of the PlotID tool.
% This Script is men
d
to demonstrate the capabilities of the PlotID tool.
% please run Initilisation.m before first time use
%% Clear and set Environment
%% Clear and set environment
clear
;
clc
;
close
all
;
addpath
(
'Examples'
);
...
...
@@ -14,9 +15,9 @@ addpath('Examples');
fig1
=
figure
;
plot
(
x
,
y
,
'-k'
);
box
off
;
set
(
gca
,
'TickDir'
,
'out'
,
'YLim'
,
[
0
,
4
]);
%
% Basic Usage
% PlotID Implementation starts here.
%% 1. Tag the plot
%
-------------- PlotID Implementation starts here. -------------------------
%%
-----
1. Tag the plot
-----
% TagPlot adds visible ID(s) to the figure(s) and to the figures property 'Tag'
% every time you run tagPlot you will get an new ID
...
...
@@ -39,9 +40,9 @@ fig2 = figure; plot(x,y,'-k'); box off; set(gca, 'TickDir', 'out', 'YLim', [0,4]
% You can find the description to all options in the readme
%% 2. Publishing
% Second part of
p
lotID
% Exports your
P
lot, the research
D
ata and the associated scripts to a
%%
----
2. Publishing
-----
% Second part of
P
lotID
% Exports your
p
lot, the research
d
ata and the associated scripts to a
% folder named with your ID
% The functions needs the file location of the script, the location of the
...
...
@@ -55,18 +56,19 @@ fig2 = figure; plot(x,y,'-k'); box off; set(gca, 'TickDir', 'out', 'YLim', [0,4]
scriptPath
=
[
mfilename
(
'fullpath'
),
'.m'
];
% file paths of the datasets used for the plot (don't forget the extension)
% note: use absolute paths for best practice
% datapath = 'test_data.mat';
locations
=
datapath
;
%call publish
PlotID
.
Publish
(
locations
,
scriptPath
,
fig2
)
% your plot, script and all the data that your provide are now published
% Your plot, script and all the data that your provide are now published.
% ---------------------------------
%% Further examples and help
% You find more examples in the Examples folder:
% Advanced usage
% Working with HDF5-files
% Using a central data folder
% How to use advanced config-files
\ No newline at end of file
% - Advanced usage
% - Working with HDF5-files
% - Using a central data folder
% - How to use advanced config-files
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment