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
69b991ff
Commit
69b991ff
authored
3 years ago
by
Lemmer, Jan
Browse files
Options
Downloads
Patches
Plain Diff
Add comments, remove some commandline outputs
parent
1514c3e6
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!13
PreRelease_V0.1
,
!12
PreRelease_V0.1
Pipeline
#564170
canceled
3 years ago
Stage: Run
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
+PlotID/Publish.m
+4
-3
4 additions, 3 deletions
+PlotID/Publish.m
+PlotID/createFileCopy.m
+67
-67
67 additions, 67 deletions
+PlotID/createFileCopy.m
example.m
+26
-27
26 additions, 27 deletions
example.m
with
97 additions
and
97 deletions
+PlotID/Publish.m
+
4
−
3
View file @
69b991ff
...
...
@@ -17,7 +17,7 @@ arguments
options
.
Method
{
mustBeMember
(
options
.
Method
,{
'individual'
,
'centralized'
})}
=
'individual'
options
.
ParentFolder
(
1
,:)
{
mustBeText
}
=
'export'
options
.
CopyUserFCN
(
1
,
1
)
{
mustBeNumericOrLogical
}
=
true
options
.
CSV
(
1
,
1
)
{
mustBeNumericOrLogical
}
=
false
options
.
CSV
(
1
,
1
)
{
mustBeNumericOrLogical
}
=
false
end
%catch multiple figures in fig
...
...
@@ -29,7 +29,7 @@ if numel(figure) > 1
warning
(
msg
);
end
%read config file
%
%
read config file
try
txt
=
fileread
(
'config.json'
);
config
=
jsondecode
(
txt
);
...
...
@@ -41,6 +41,7 @@ catch
configError
=
true
;
end
%% storage location
switch
options
.
Location
case
'local'
if
contains
(
options
.
ParentFolder
,
{
'/'
,
'\'
})
...
...
@@ -66,7 +67,7 @@ elseif mkdir(fullfile(storPath,folderName))
else
error
(
'Directory could not be created - check remote path and permissions'
);
end
disp
(
'P
ublishing started'
);
disp
(
[
'p
ublishing
of '
,
ID
,
'
started'
]
);
%% Create a Copy of the script, config and user functions(optional)
% script
...
...
This diff is collapsed.
Click to expand it.
+PlotID/createFileCopy.m
+
67
−
67
View file @
69b991ff
...
...
@@ -2,78 +2,78 @@ function [storagePaths] = createFileCopy(filePaths,folderName,storPath,ID,type)
% Creates a copy of the files (can be used for multiple paths in a cell array)
% folderName is the name of the exporting folder
% returns the storage paths were files were stored
disp
([
'start to copy '
,
type
]);
if
~
iscell
(
filePaths
)
%fixes Issue if Filepath is a char and not a cell array
filePaths
=
{
filePaths
};
end
if
~
iscell
(
filePaths
)
%fixes Issue if Filepath is a char and not a cell array
filePaths
=
{
filePaths
};
end
try
storagePaths
=
cell
(
numel
(
filePaths
,
1
));
for
i
=
1
:
numel
(
filePaths
)
FileNameAndLocation
=
filePaths
{
i
};
[
~
,
name
,
ext
]
=
fileparts
(
filePaths
{
i
});
% get the extension
switch
type
case
'data'
newfile
=
sprintf
([
name
,
ext
]);
%keep original name
%old behaviour
%sufix = '_data';
%newfile = sprintf([ID, sufix, '_' , num2str(i) ,ext]);
case
'dataCentral'
%keep original name
newfile
=
sprintf
([
name
,
ext
]);
case
'script'
sufix
=
'_script'
;
newfile
=
sprintf
([
ID
,
sufix
,
ext
]);
case
'userFcn'
%keep original name
newfile
=
sprintf
([
name
,
ext
]);
otherwise
error
([
type
,
' is not a valid type for createFileCopy'
])
end
%switch
RemotePath
=
fullfile
(
storPath
,
folderName
,
newfile
);
try
storagePaths
=
cell
(
numel
(
filePaths
,
1
));
for
i
=
1
:
numel
(
filePaths
)
FileNameAndLocation
=
filePaths
{
i
};
[
~
,
name
,
ext
]
=
fileparts
(
filePaths
{
i
});
% get the extension
switch
type
case
'data'
newfile
=
sprintf
([
name
,
ext
]);
%keep original name
%old behaviour
%sufix = '_data';
%newfile = sprintf([ID, sufix, '_' , num2str(i) ,ext]);
case
'dataCentral'
%keep original name
newfile
=
sprintf
([
name
,
ext
]);
case
'script'
sufix
=
'_script'
;
newfile
=
sprintf
([
ID
,
sufix
,
ext
]);
case
'userFcn'
%keep original name
newfile
=
sprintf
([
name
,
ext
]);
otherwise
error
([
type
,
' is not a valid type for createFileCopy'
])
end
%switch
RemotePath
=
fullfile
(
storPath
,
folderName
,
newfile
);
% Check if remote file already exists
count
=
0
;
while
isfile
(
RemotePath
)
&&
ismember
(
type
,{
'data'
,
'dataCentral'
})
% Add a Sufix number to new file name
% TODO add more inteligent way then a simple sufix
count
=
count
+
1
;
[
~
,
name
,
ext
]
=
fileparts
(
RemotePath
);
if
count
<
2
RemotePath
=
fullfile
(
storPath
,
folderName
,
...
[
name
,
'_'
,
num2str
(
count
),
ext
]);
else
RemotePath
=
fullfile
(
storPath
,
folderName
,
...
[
name
(
1
:
end
-
length
(
num2str
(
count
))),
num2str
(
count
),
ext
]);
end
[
~
,
name
,
~
]
=
fileparts
(
RemotePath
);
msg
=
[
'Filename '
,
name
,
...
' already exists in the data folder'
newline
,
...
' PlotID will add an suffix if you continue.'
newline
,
...
' This can cause serious confusions.'
];
warning
(
msg
);
m
=
input
(
'Do you want to continue, Y/N [Y]:'
,
's'
);
if
ismember
(
m
,{
'N'
,
'n'
})
errorMSG
=
[
'Filename already exists in data folder.'
newline
,
...
' Rename the File and restart PlotID.'
];
error
();
end
count
=
0
;
while
isfile
(
RemotePath
)
&&
ismember
(
type
,{
'data'
,
'dataCentral'
})
% Add a Sufix number to new file name
% TODO add more inteligent way then a simple sufix
count
=
count
+
1
;
[
~
,
name
,
ext
]
=
fileparts
(
RemotePath
);
if
count
<
2
RemotePath
=
fullfile
(
storPath
,
folderName
,
...
[
name
,
'_'
,
num2str
(
count
),
ext
]);
else
RemotePath
=
fullfile
(
storPath
,
folderName
,
...
[
name
(
1
:
end
-
length
(
num2str
(
count
))),
num2str
(
count
),
ext
]);
end
[
~
,
name
,
~
]
=
fileparts
(
RemotePath
);
msg
=
[
'Filename '
,
name
,
...
' already exists in the data folder'
newline
,
...
' PlotID will add an suffix if you continue.'
newline
,
...
' This can cause serious confusions.'
];
warning
(
msg
);
m
=
input
(
'Do you want to continue, Y/N [Y]:'
,
's'
);
if
ismember
(
m
,{
'N'
,
'n'
})
errorMSG
=
[
'Filename already exists in data folder.'
newline
,
...
' Rename the File and restart PlotID.'
];
error
();
end
copyfile
(
FileNameAndLocation
,
RemotePath
);
storagePaths
{
i
}
=
RemotePath
;
end
disp
([
type
,
' sucessfully published'
]);
catch
warning
([
type
,
' export was not sucessful'
])
copyfile
(
FileNameAndLocation
,
RemotePath
);
storagePaths
{
i
}
=
RemotePath
;
end
disp
([
type
,
' sucessfully published'
]);
catch
warning
([
type
,
' export was not sucessful'
])
if
exist
(
'errorMSG'
)
error
(
errorMSG
);
end
%try
end
end
end
%try
end
%function
This diff is collapsed.
Click to expand it.
example.m
+
26
−
27
View file @
69b991ff
...
...
@@ -3,40 +3,32 @@
%% Clear Environment
clear
;
clc
;
close
all
;
addpath
(
'CI_files'
);
% Test scripts
try
delete
testdata2
.
h5
;
end
%% Set ProjectID
% ProjectID can also be set in the config file
% TODO: decide how projectID and optionally ORCID will be implemented
% ORCID placed on startup (alternative?) - projectID as persistent
% otherwise dialogue?
% Leave empty for using the ID from the config file
ProjectID
=
'FST03'
;
ProjectID
=
'Example'
;
%% Data
%
Creating Random Data to use as data-fi
le
%
only necessary for this examp
le
x
=
linspace
(
0
,
7
);
y
=
rand
(
1
,
100
)
+
2
;
% Creating Random Data to use as data-file
x
=
linspace
(
0
,
7
);
y
=
rand
(
1
,
100
)
+
2
;
dataset1
=
'test_data.mat'
;
% Use absolute paths for good practise
dataset1
=
fullfile
(
pwd
,
dataset1
);
save
(
dataset1
,
'x'
,
'y'
);
% some data for the .h5 file
x1
=
linspace
(
0
,
2
*
pi
);
y1
=
sin
(
x1
)
+
2
;
% some data as .h5
x1
=
linspace
(
0
,
2
*
pi
);
y1
=
sin
(
x1
)
+
2
;
% define file path & name
% define filepath & name
dataset2
=
'testdata2.h5'
;
dataset2
=
fullfile
(
pwd
,
dataset2
);
fpath
=
dataset2
;
...
...
@@ -49,14 +41,14 @@ h5write(fpath, "/y1", y1)
%% function calls
% Place for post-processing of the data, or additional related code.
a
=
1
;
% example_fcn is a dummy function to show the functionality
a
=
example_fcn
(
a
);
%p = betacdf(0.5,1,1); % to test
T
oolboxes
a
=
1
;
a
=
example_fcn
(
a
);
%p = betacdf(0.5,1,1); % to test
t
oolboxes
%% Plotting
% This is still part of a normal script to produce plots.
% Make sure to save each figure in a variable to pass to PlotID-functions.
% Make sure to save each figure in a variable
% to pass it to PlotID-functions.
fig
(
1
)
=
figure
;
plot
(
x
,
y
,
'-k'
);
box
off
;
hold
on
;
...
...
@@ -73,17 +65,19 @@ set(gca, 'TickDir', 'out', 'YLim', [0,4]);
%% Publishing
% Second part of plotID
% The functions needs the file location, the location of the data and the
% figure and can take several options.
% TODO add explanations for Options
% The functions needs the file location of the script, the location of the
% data and the figure and can take several options (see readme).
path
.
script
=
mfilename
(
'fullpath'
);
% filename of the m.script
% file names of the datasets
%(defined above:) dataset1 = 'test_data.mat'; dataset2 = 'testdata2.h5'
path
.
rdata
=
{
dataset1
,
dataset2
}
;
% don't forget the extension
%call publishing
PlotID
.
Publish
(
path
,
ID
,
fig
(
1
),
'Location'
,
'local'
,
'Method'
,
'individual'
)
%% Example 2: multiple plots plot, all based on data
-
set2 (hdf5)
%% Example 2: multiple plots plot, all based on dataset2 (hdf5)
% for individual data-sets, use an appropriate array
fig
(
2
)
=
figure
;
...
...
@@ -100,13 +94,18 @@ path.script = mfilename('fullpath'); % filename of the m.script
% file names of the datasets
path
.
rdata
=
{
dataset2
}
;
% don't forget the extension
% publsihing via for-loop
% publsihing via
a
for-loop
for
i
=
1
:
numel
(
fig
)
PlotID
.
Publish
(
path
,
IDs
{
i
},
fig
(
i
),
'Location'
,
'server'
,
'Method'
,
'individual'
);
PlotID
.
Publish
(
path
,
IDs
{
i
},
fig
(
i
),
'Location'
,
'local'
,
...
'Method'
,
'individual'
);
end
%% Second Plot with identical data to test centralized method
% ToDO Add better description
% A central data folder is used for saving the research data files, the
% subfolders contain linked hdf5-files (if hdf5 is used). This is
% recommended, if many plots are made from the same data set. Attention,
% the linked HDF5 will not work when a subfolder was moved or the data
% folder was deleted
fig2
=
figure
;
plot
(
x
,
y
,
'-k'
);
...
...
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