From a8b6d113a9e964bd644cb972612fdc34d17b7ecd Mon Sep 17 00:00:00 2001
From: Jan Lemmer <jan.lemmer@fst.tu-darmstadt.de>
Date: Tue, 24 Aug 2021 12:12:47 +0200
Subject: [PATCH] Add Package Definition, Closes #27

---
 {fcn_core => +PlotID}/CreateID.m              |  48 ++--
 {fcn_core => +PlotID}/Publish.m               | 230 +++++++++---------
 {fcn_core => +PlotID}/TagPlot.m               | 166 ++++++-------
 {fcn_help => +PlotID}/createFileCopy.m        | 104 ++++----
 {fcn_help => +PlotID}/createLinkedHDF5.m      |  40 +--
 {fcn_help => +PlotID}/fileCompare.m           |  98 ++++----
 fcn_help/FriendlyID.m => +PlotID/friendlyID.m |   2 +-
 {fcn_help => +PlotID}/removePltIdFiles.m      |  38 +--
 CI_files/default_test.m                       |   5 +-
 example.m                                     |  14 +-
 10 files changed, 371 insertions(+), 374 deletions(-)
 rename {fcn_core => +PlotID}/CreateID.m (97%)
 rename {fcn_core => +PlotID}/Publish.m (85%)
 rename {fcn_core => +PlotID}/TagPlot.m (95%)
 rename {fcn_help => +PlotID}/createFileCopy.m (97%)
 rename {fcn_help => +PlotID}/createLinkedHDF5.m (96%)
 rename {fcn_help => +PlotID}/fileCompare.m (96%)
 rename fcn_help/FriendlyID.m => +PlotID/friendlyID.m (91%)
 rename {fcn_help => +PlotID}/removePltIdFiles.m (86%)

diff --git a/fcn_core/CreateID.m b/+PlotID/CreateID.m
similarity index 97%
rename from fcn_core/CreateID.m
rename to +PlotID/CreateID.m
index 2579717..570a187 100644
--- a/fcn_core/CreateID.m
+++ b/+PlotID/CreateID.m
@@ -1,24 +1,24 @@
-function [ID] = CreateID(method)
-%CreateID Creates an identifier (char)
-%   Creates an (sometimes unique) identifier based on the selected method
-%   if no method is selected method 1 will be the default method
-arguments
-    method (1,1) {mustBeNumeric} = 1
-end
-
-switch method 
-    case 1 % UNIX Time in seconds as HEX
-        ID = posixtime(datetime('now')); %get current Unix time
-        ID = dec2hex(int32(ID)); % get it as Hex
-        pause(1); %Pausing for unique IDs
-    case 2 % random UUID from Java 128 bit
-        %Static factory to retrieve a type 4 (pseudo randomly generated) UUID.
-        % The UUID is generated using a cryptographically strong pseudo
-        % random number generator.
-        temp =  java.util.UUID.randomUUID;
-        ID = temp.toString;           
-     otherwise
-        error('The requested method is not defined yet');
-end
-
-end
+function [ID] = CreateID(method)
+%CreateID Creates an identifier (char)
+%   Creates an (sometimes unique) identifier based on the selected method
+%   if no method is selected method 1 will be the default method
+arguments
+    method (1,1) {mustBeNumeric} = 1
+end
+
+switch method 
+    case 1 % UNIX Time in seconds as HEX
+        ID = posixtime(datetime('now')); %get current Unix time
+        ID = dec2hex(int32(ID)); % get it as Hex
+        pause(1); %Pausing for unique IDs
+    case 2 % random UUID from Java 128 bit
+        %Static factory to retrieve a type 4 (pseudo randomly generated) UUID.
+        % The UUID is generated using a cryptographically strong pseudo
+        % random number generator.
+        temp =  java.util.UUID.randomUUID;
+        ID = temp.toString;           
+     otherwise
+        error('The requested method is not defined yet');
+end
+
+end
diff --git a/fcn_core/Publish.m b/+PlotID/Publish.m
similarity index 85%
rename from fcn_core/Publish.m
rename to +PlotID/Publish.m
index 7598802..01eb66b 100644
--- a/fcn_core/Publish.m
+++ b/+PlotID/Publish.m
@@ -1,115 +1,115 @@
-function Publish(DataPaths, ID, 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).
-
-arguments
-   DataPaths
-   ID (1,:) {mustBeNonzeroLengthText} % ID must be provided
-   figure (1,:) {mustBeFigure} % Checks if figure is a figure object
-   options.Location {mustBeMember(options.Location ,['local','server','CI-Test'])} = 'local' % storage path
-   options.Method {mustBeMember(options.Method ,['individual','centraliced'])} = 'individual'
-   options.CopyUserFCN (1,1) {mustBeNumericOrLogical} = true 
-end
-
-%catch multiple figures in fig
-if numel(figure) > 1
-    figure = figure(1);
-    msg = ['Publish is designed for handeling 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);
-end
-
-switch options.Location 
-    case 'local'
-         storPath = fullfile(pwd,'export');
-    case 'server' %from config File
-         txt = fileread('config.json');
-         config = jsondecode(txt);
-         storPath = config.ServerPath;
-    case 'CI-Test'
-        storPath = fullfile(pwd,'CI_files','export');
-end
-folderName = char(ID);
-
-%% Create Data-Directory
-addpath(storPath); % ToDo necessary? - 
-if isfolder(fullfile(storPath,folderName))
-   error(['Folder ',folderName, ' exists - Plot was already published ']);
-elseif mkdir(fullfile(storPath,folderName))
-else
-    error('Directory could not be created - check remote path and permissions');
-end
-
-disp('Publishing started');
-
-%% Create a Copy of the script and User functions(optional)
-createFileCopy({[DataPaths.script,'.m']},folderName,storPath,ID, 'script');
-
-if options.CopyUserFCN
-   [fList,pList] = matlab.codetools.requiredFilesAndProducts(DataPaths.script);
-   % plist contains the required MATLAB Toolboxes, maybe usefull in future
-   fList = fList(~ismember(fList,[DataPaths.script,'.m'])); % rmv script from list
-   fList = removePltIdFiles(fList); % Do not copy files that are part of plot ID
-   if ~isempty(fList)
-       createFileCopy(fList,folderName,storPath,ID,'userFcn');
-   end
-end
-
-%% Research data handeling
-switch options.Method
-    case 'centraliced' % Work in progresss!!!
-        % check if data folder exists
-        if ~isfolder(fullfile(storPath,'data'))
-            mkdir(fullfile(storPath,'data'));
-        end
-        %list all files
-        fList = dir(fullfile(storPath,'data', '**\*.*'));  %get list of files and folders in any subfolder
-        fList = fList(~[fList.isdir]);  %remove folders from list
-        fList = struct2table(fList);
-        
-        % Check if the new plot is based on the original data-set    
-            % copy the data(once)
-        for i=1:numel(DataPaths.rdata)            
-            % check if identical file exists (status = 1)
-            [~, idx] = fileCompare(DataPaths.rdata{i},fList);
-            % create Linked HDF5 files for identical files
-            if any(idx)
-            sourcePath = fList.name{idx}; % If there are multiple copies already, this only picks the last entry
-            if contains(sourcePath,{'.h5','.hdf5'}) % Linking only for HDF5
-                createLinkedHDF5(sourcePath,storPath,ID);
-            end
-            else % no identical file exists
-               createFileCopy(DataPaths.rdata{i},'data',storPath,ID,'dataCentral');
-            end
-        end
-    case 'individual'
-        % Create a copy of the research data    
-        createFileCopy(DataPaths.rdata,folderName,storPath,ID, 'data');
-end
-%% Export the Plot
-%try 
-       PlotName = [ID,'_plot']; % plotname
-       RemotePath = fullfile(storPath ,folderName, PlotName);
-       % Matlab figure
-       savefig(figure,RemotePath);
-       % the png should only be a preview
-       exportgraphics(figure,[RemotePath,'.png'],'Resolution',300);
-%   end
-% catch 
-%     warning('Plot export was not successful')
-% end
-
-disp(['publishing of ', ID , ' done']);
-
-end %function
-
-function tf = mustBeFigure(h)
-%checks if input is a figure object
-  tf = strcmp(get(h, 'type'), 'figure') & isa(h, 'matlab.ui.Figure');  
-end
+function Publish(DataPaths, ID, 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).
+
+arguments
+   DataPaths
+   ID (1,:) {mustBeNonzeroLengthText} % ID must be provided
+   figure (1,:) {mustBeFigure} % Checks if figure is a figure object
+   options.Location {mustBeMember(options.Location ,['local','server','CI-Test'])} = 'local' % storage path
+   options.Method {mustBeMember(options.Method ,['individual','centraliced'])} = 'individual'
+   options.CopyUserFCN (1,1) {mustBeNumericOrLogical} = true 
+end
+
+%catch multiple figures in fig
+if numel(figure) > 1
+    figure = figure(1);
+    msg = ['Publish is designed for handeling 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);
+end
+
+switch options.Location 
+    case 'local'
+         storPath = fullfile(pwd,'export');
+    case 'server' %from config File
+         txt = fileread('config.json');
+         config = jsondecode(txt);
+         storPath = config.ServerPath;
+    case 'CI-Test'
+        storPath = fullfile(pwd,'CI_files','export');
+end
+folderName = char(ID);
+
+%% Create Data-Directory
+addpath(storPath); % ToDo necessary? - 
+if isfolder(fullfile(storPath,folderName))
+   error(['Folder ',folderName, ' exists - Plot was already published ']);
+elseif mkdir(fullfile(storPath,folderName))
+else
+    error('Directory could not be created - check remote path and permissions');
+end
+
+disp('Publishing started');
+
+%% Create a Copy of the script and User functions(optional)
+PlotID.createFileCopy({[DataPaths.script,'.m']},folderName,storPath,ID, 'script');
+
+if options.CopyUserFCN
+   [fList,pList] = matlab.codetools.requiredFilesAndProducts(DataPaths.script);
+   % plist contains the required MATLAB Toolboxes, maybe usefull in future
+   fList = fList(~ismember(fList,[DataPaths.script,'.m'])); % rmv script from list
+   fList = PlotID.removePltIdFiles(fList); % Do not copy files that are part of plot ID
+   if ~isempty(fList)
+       PlotID.createFileCopy(fList,folderName,storPath,ID,'userFcn');
+   end
+end
+
+%% Research data handeling
+switch options.Method
+    case 'centraliced' % Work in progresss!!!
+        % check if data folder exists
+        if ~isfolder(fullfile(storPath,'data'))
+            mkdir(fullfile(storPath,'data'));
+        end
+        %list all files
+        fList = dir(fullfile(storPath,'data', '**\*.*'));  %get list of files and folders in any subfolder
+        fList = fList(~[fList.isdir]);  %remove folders from list
+        fList = struct2table(fList);
+        
+        % Check if the new plot is based on the original data-set    
+            % copy the data(once)
+        for i=1:numel(DataPaths.rdata)            
+            % check if identical file exists (status = 1)
+            [~, idx] = PlotID.fileCompare(DataPaths.rdata{i},fList);
+            % create Linked HDF5 files for identical files
+            if any(idx)
+            sourcePath = fList.name{idx}; % If there are multiple copies already, this only picks the last entry
+            if contains(sourcePath,{'.h5','.hdf5'}) % Linking only for HDF5
+                PlotID.createLinkedHDF5(sourcePath,storPath,ID);
+            end
+            else % no identical file exists
+               PlotID.createFileCopy(DataPaths.rdata{i},'data',storPath,ID,'dataCentral');
+            end
+        end
+    case 'individual'
+        % Create a copy of the research data    
+        PlotID.createFileCopy(DataPaths.rdata,folderName,storPath,ID, 'data');
+end
+%% Export the Plot
+%try 
+       PlotName = [ID,'_plot']; % plotname
+       RemotePath = fullfile(storPath ,folderName, PlotName);
+       % Matlab figure
+       savefig(figure,RemotePath);
+       % the png should only be a preview
+       exportgraphics(figure,[RemotePath,'.png'],'Resolution',300);
+%   end
+% catch 
+%     warning('Plot export was not successful')
+% end
+
+disp(['publishing of ', ID , ' done']);
+
+end %function
+
+function tf = mustBeFigure(h)
+%checks if input is a figure object
+  tf = strcmp(get(h, 'type'), 'figure') & isa(h, 'matlab.ui.Figure');  
+end
diff --git a/fcn_core/TagPlot.m b/+PlotID/TagPlot.m
similarity index 95%
rename from fcn_core/TagPlot.m
rename to +PlotID/TagPlot.m
index 0032a89..26aee3e 100644
--- a/fcn_core/TagPlot.m
+++ b/+PlotID/TagPlot.m
@@ -1,83 +1,83 @@
-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
-%   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
-%   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)
-arguments
-    figs (1,:) {mustBeFigure}
-    options.ProjectID (1,:) {mustBeText}= ''
-    options.Fontsize (1,1) {mustBeInteger} = 8 
-    options.Location (1,:) {mustBeText} = 'east'
-    options.Position (1,2) {mustBeVector} = [1,0.4] % default for east
-    options.Rotation (1,1) {mustBeInteger} = 0  
-end
-
-if isempty(options.ProjectID)
-   txt = fileread('config.json');
-   config = jsondecode(txt);
-   if ~isempty(config.ProjectID)
-       options.ProjectID = config.ProjectID;
-   else
-       warning('no project options.ProjectID defined')
-   end
-end
-
-switch options.Location
-    case 'north'
-        options.Position = [0.4,0.95];
-        options.Rotation = 0;
-    case 'east'
-        options.Position = [1,0.4];
-        options.Rotation = 90;
-    case 'south'
-        options.Position = [0.4,.02];
-        options.Rotation = 0;
-    case 'west'
-        options.Position = [.05,0.4];
-        options.Rotation = 90;
-    case 'custom'
-        % Check if Position is valid
-        if ~all(0 <= options.Position & options.Position <= 1)
-           options.Position = [1,0.4];
-           warning('options.Position is not valid, TagPlot default values instead');
-        end
-    otherwise % set default position
-        warning([options.Location, ' is not a defined location, TagPlot uses location east instead']);
-        options.Location = 'east'; options.Position = [1,0.4];
-end
-
-IDs = cell(numel(figs),1);
-
-for n = 1:numel(figs)
-    IDs{n} = CreateID; % Create ID
-    IDs{n} = [options.ProjectID,'-',IDs{n}]; % add options.ProjectID
-    axes = get(figs(n),'CurrentAxes'); % Axes object for text annotation
-    % Limits for relative Positioning
-    ylim =get(axes,'YLim');
-    xlim =get(axes,'XLim');
-    %ID
-    position = [options.Position(1)*xlim(2), options.Position(2)*ylim(2)];
-    text(axes,position(1),position(2), IDs{n},'Fontsize',options.Fontsize,...
-    'Rotation',options.Rotation, 'VerticalAlignment','bottom','Color',...
-        0.65*[1 1 1],'BackgroundColor','w');
-    set(figs(n),'Tag', IDs{n});    
-end
-
-if numel(figs) == 1
-   % use char instead of a cell arry for a single ID
-   IDs = IDs{1}; 
-end
-
-end
-
-function tf = mustBeFigure(h) %checks if input is a figure object
-  tf = strcmp(get(h, 'type'), 'figure') & isa(h, 'matlab.ui.Figure');
-end
+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
+%   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
+%   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)
+arguments
+    figs (1,:) {mustBeFigure}
+    options.ProjectID (1,:) {mustBeText}= ''
+    options.Fontsize (1,1) {mustBeInteger} = 8 
+    options.Location (1,:) {mustBeText} = 'east'
+    options.Position (1,2) {mustBeVector} = [1,0.4] % default for east
+    options.Rotation (1,1) {mustBeInteger} = 0  
+end
+
+if isempty(options.ProjectID)
+   txt = fileread('config.json');
+   config = jsondecode(txt);
+   if ~isempty(config.ProjectID)
+       options.ProjectID = config.ProjectID;
+   else
+       warning('no project options.ProjectID defined')
+   end
+end
+
+switch options.Location
+    case 'north'
+        options.Position = [0.4,0.95];
+        options.Rotation = 0;
+    case 'east'
+        options.Position = [1,0.4];
+        options.Rotation = 90;
+    case 'south'
+        options.Position = [0.4,.02];
+        options.Rotation = 0;
+    case 'west'
+        options.Position = [.05,0.4];
+        options.Rotation = 90;
+    case 'custom'
+        % Check if Position is valid
+        if ~all(0 <= options.Position & options.Position <= 1)
+           options.Position = [1,0.4];
+           warning('options.Position is not valid, TagPlot default values instead');
+        end
+    otherwise % set default position
+        warning([options.Location, ' is not a defined location, TagPlot uses location east instead']);
+        options.Location = 'east'; options.Position = [1,0.4];
+end
+
+IDs = cell(numel(figs),1);
+
+for n = 1:numel(figs)
+    IDs{n} = PlotID.CreateID; % Create ID
+    IDs{n} = [options.ProjectID,'-',IDs{n}]; % add options.ProjectID
+    axes = get(figs(n),'CurrentAxes'); % Axes object for text annotation
+    % Limits for relative Positioning
+    ylim =get(axes,'YLim');
+    xlim =get(axes,'XLim');
+    %ID
+    position = [options.Position(1)*xlim(2), options.Position(2)*ylim(2)];
+    text(axes,position(1),position(2), IDs{n},'Fontsize',options.Fontsize,...
+    'Rotation',options.Rotation, 'VerticalAlignment','bottom','Color',...
+        0.65*[1 1 1],'BackgroundColor','w');
+    set(figs(n),'Tag', IDs{n});    
+end
+
+if numel(figs) == 1
+   % use char instead of a cell arry for a single ID
+   IDs = IDs{1}; 
+end
+
+end
+
+function tf = mustBeFigure(h) %checks if input is a figure object
+  tf = strcmp(get(h, 'type'), 'figure') & isa(h, 'matlab.ui.Figure');
+end
diff --git a/fcn_help/createFileCopy.m b/+PlotID/createFileCopy.m
similarity index 97%
rename from fcn_help/createFileCopy.m
rename to +PlotID/createFileCopy.m
index 4bf198e..f8fb6f8 100644
--- a/fcn_help/createFileCopy.m
+++ b/+PlotID/createFileCopy.m
@@ -1,52 +1,52 @@
-function [] = 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
-    disp(['start to copy ', type]);  
-    
-    if ~iscell(filePaths)
-        %fixes Issue if Filepath is a char and not a cell array
-        filePaths = {filePaths};
-    end
-        
-    try        
-        for i = 1:numel(filePaths)
-            FileNameAndLocation = filePaths{i};
-            [~,name,ext] = fileparts(filePaths{i}); % get the extension
-                          
-            switch type
-                case 'data'
-                    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 
-            
-            % Write the file
-            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
-                count = count + 1;
-                [~,name,ext] = fileparts(RemotePath);
-                RemotePath = fullfile(storPath,folderName,...
-                    [name,'_',num2str(count),ext]);
-            end
-            copyfile(FileNameAndLocation,RemotePath);
-        end
-        disp([type, ' sucessfully published']);
-    catch
-        warning([type,' export was not sucessful'])
-   end %try
-end
-
+function [] = 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
+    disp(['start to copy ', type]);  
+    
+    if ~iscell(filePaths)
+        %fixes Issue if Filepath is a char and not a cell array
+        filePaths = {filePaths};
+    end
+        
+    try        
+        for i = 1:numel(filePaths)
+            FileNameAndLocation = filePaths{i};
+            [~,name,ext] = fileparts(filePaths{i}); % get the extension
+                          
+            switch type
+                case 'data'
+                    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 
+            
+            % Write the file
+            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
+                count = count + 1;
+                [~,name,ext] = fileparts(RemotePath);
+                RemotePath = fullfile(storPath,folderName,...
+                    [name,'_',num2str(count),ext]);
+            end
+            copyfile(FileNameAndLocation,RemotePath);
+        end
+        disp([type, ' sucessfully published']);
+    catch
+        warning([type,' export was not sucessful'])
+   end %try
+end
+
diff --git a/fcn_help/createLinkedHDF5.m b/+PlotID/createLinkedHDF5.m
similarity index 96%
rename from fcn_help/createLinkedHDF5.m
rename to +PlotID/createLinkedHDF5.m
index 2738fd1..ea59760 100644
--- a/fcn_help/createLinkedHDF5.m
+++ b/+PlotID/createLinkedHDF5.m
@@ -1,20 +1,20 @@
-function [status] = createLinkedHDF5(SourceFile,TargetPath,ID)
-%createLinkedHDF5 creates a HDF file that references the Sourcefile
-%   TargetPath is the storage location, ID the foldername
-%   Status returns true if the function was sucessfull
-
-plist_id = 'H5P_DEFAULT';
-
-% try
-    fid = H5F.create(fullfile(TargetPath,ID,[ID,'_data.h5']));
-    %create External Link to Sourcefile in the Group linkToExternal
-    H5L.create_external(['..\data\',SourceFile],'/',fid, SourceFile ,plist_id,plist_id);
-    H5F.close(fid);
-    status = 1;
-% catch
-%     warning('No linked HDF file was created');
-%     status = 0;
-% end
-
-end
-
+function [status] = createLinkedHDF5(SourceFile,TargetPath,ID)
+%createLinkedHDF5 creates a HDF file that references the Sourcefile
+%   TargetPath is the storage location, ID the foldername
+%   Status returns true if the function was sucessfull
+
+plist_id = 'H5P_DEFAULT';
+
+% try
+    fid = H5F.create(fullfile(TargetPath,ID,[ID,'_data.h5']));
+    %create External Link to Sourcefile in the Group linkToExternal
+    H5L.create_external(['..\data\',SourceFile],'/',fid, SourceFile ,plist_id,plist_id);
+    H5F.close(fid);
+    status = 1;
+% catch
+%     warning('No linked HDF file was created');
+%     status = 0;
+% end
+
+end
+
diff --git a/fcn_help/fileCompare.m b/+PlotID/fileCompare.m
similarity index 96%
rename from fcn_help/fileCompare.m
rename to +PlotID/fileCompare.m
index 8026faa..91cabb0 100644
--- a/fcn_help/fileCompare.m
+++ b/+PlotID/fileCompare.m
@@ -1,49 +1,49 @@
-function [status, id] = fileCompare(filename,fileList)
-%fileCompare checks if file1 is (binary) identical to a file in filelist
-% it returns a sttus and the id of the identical file
-% the functions uses the windows system function fc or the unix function
-% diff
-
-if isempty(fileList)
-   % no comparison necessary
-    status =false;
-    id = 0;
-    return
-end
-
-[~,~,ext1] = fileparts(filename); 
-id = zeros(height(fileList),1);
-
-for i=1:height(fileList)
-    [~,~,ext2] = fileparts(fileList{i,'name'});
-
-    if ~isequal(ext1,ext2)
-        %warning('File extension are not identical');
-        status = false;
-        continue
-    end
-
-    filepath = fullfile(fileList{i,'folder'},fileList{i,'name'});
-    if ispc
-        [status,~] = system(['fc ' filename ' ' char(filepath)]);
-        % 0 -> identical, 1 -> not identical
-         status = ~status; % false (not identical), true(identical)
-                   
-    elseif isunix %untested!
-        [status,~] = system(['diff ' filename ' ' filepath]);
-    else
-        warning('Platform not supported')
-    end
-    
-    if status == 1        
-        id(i) = 1;
-    else 
-        % Status can also be any other number e.g. 2 
-        id(i) = 0;
-    end
-    
-    id =logical(id); %bugfix
-end
-
-end
-
+function [status, id] = fileCompare(filename,fileList)
+%fileCompare checks if file1 is (binary) identical to a file in filelist
+% it returns a sttus and the id of the identical file
+% the functions uses the windows system function fc or the unix function
+% diff
+
+if isempty(fileList)
+   % no comparison necessary
+    status =false;
+    id = 0;
+    return
+end
+
+[~,~,ext1] = fileparts(filename); 
+id = zeros(height(fileList),1);
+
+for i=1:height(fileList)
+    [~,~,ext2] = fileparts(fileList{i,'name'});
+
+    if ~isequal(ext1,ext2)
+        %warning('File extension are not identical');
+        status = false;
+        continue
+    end
+
+    filepath = fullfile(fileList{i,'folder'},fileList{i,'name'});
+    if ispc
+        [status,~] = system(['fc ' filename ' ' char(filepath)]);
+        % 0 -> identical, 1 -> not identical
+         status = ~status; % false (not identical), true(identical)
+                   
+    elseif isunix %untested!
+        [status,~] = system(['diff ' filename ' ' filepath]);
+    else
+        warning('Platform not supported')
+    end
+    
+    if status == 1        
+        id(i) = 1;
+    else 
+        % Status can also be any other number e.g. 2 
+        id(i) = 0;
+    end
+    
+    id =logical(id); %bugfix
+end
+
+end
+
diff --git a/fcn_help/FriendlyID.m b/+PlotID/friendlyID.m
similarity index 91%
rename from fcn_help/FriendlyID.m
rename to +PlotID/friendlyID.m
index e18834b..cdac106 100644
--- a/fcn_help/FriendlyID.m
+++ b/+PlotID/friendlyID.m
@@ -1,4 +1,4 @@
-function [IDf,PrjID, Str] = FriendlyID(ID)
+function [IDf,PrjID, Str] = friendlyID(ID)
 %FriendlyID Changes the Hex Number to a human friendly datetime and dateStr
 % IDf ID as DateTime Object, PrjID returns the ProjectID, Str returns the
 % timestamp as String
diff --git a/fcn_help/removePltIdFiles.m b/+PlotID/removePltIdFiles.m
similarity index 86%
rename from fcn_help/removePltIdFiles.m
rename to +PlotID/removePltIdFiles.m
index 3080c22..98e83b3 100644
--- a/fcn_help/removePltIdFiles.m
+++ b/+PlotID/removePltIdFiles.m
@@ -1,19 +1,19 @@
-function [fListClean] = removePltIdFiles(fList)
-%removePltIdFiles removes functions that are part of PlotID out of flist
-%   Detailed explanation goes here
-%addpath('..\fcn_core');
-
-[~,names,ext] = fileparts(fList);
-names = strcat(names, ext); % add ext for comparison
-
-% Get a list of all .m files that are part of Plot id
-PltID_flist = struct2table([dir('fcn_help'); dir('fcn_core')]); %get list of files 
-[~,~,PltID_flist.ext(:)] = fileparts(PltID_flist.name(:)); % add ext column
-
-PltID_flist = PltID_flist(strcmp(PltID_flist.ext,'.m'),:);
-
-% Comparison and filter
-fListClean = fList(~ismember(names,PltID_flist.name));
-
-end
-
+function [fListClean] = removePltIdFiles(fList)
+%removePltIdFiles removes functions that are part of PlotID out of flist
+%   Detailed explanation goes here
+%addpath('..\fcn_core');
+
+[~,names,ext] = fileparts(fList);
+names = strcat(names, ext); % add ext for comparison
+
+% Get a list of all .m files that are part of Plot id
+PltID_flist = struct2table(dir('+PlotID')); %get list of files 
+[~,~,PltID_flist.ext(:)] = fileparts(PltID_flist.name(:)); % add ext column
+
+PltID_flist = PltID_flist(strcmp(PltID_flist.ext,'.m'),:);
+
+% Comparison and filter
+fListClean = fList(~ismember(names,PltID_flist.name));
+
+end
+
diff --git a/CI_files/default_test.m b/CI_files/default_test.m
index c25bd97..3d1f20c 100644
--- a/CI_files/default_test.m
+++ b/CI_files/default_test.m
@@ -3,7 +3,6 @@ function [result] = default_test()
 %   Detailed explanation goes here
 
 clear; clc; close all;
-addpath('./fcn_core','./fcn_help');
 
 % clean up, if previous run failed
 try
@@ -41,7 +40,7 @@ plot(x1,y1,'-r');
 
 %% Tag the plot
 try
-    [figs, ID] = TagPlot(fig,'ProjectID', ProjectID);
+    [figs, ID] = PlotID.TagPlot(fig,'ProjectID', ProjectID);
 
     %% call a dummy function
     a=1;
@@ -56,7 +55,7 @@ try
     % file name of the data
     path.rdata =  {dataset1,dataset2} ; % don't forget the extension
 
-    Publish(path, ID, figs, 'Location', 'CI-Test')
+    PlotID.Publish(path, ID, figs, 'Location', 'CI-Test')
     
     % clean up 
     delete CI_files/export/* CI_files/*.mat CI_files/*.h5 
diff --git a/example.m b/example.m
index ebdaf12..8587451 100644
--- a/example.m
+++ b/example.m
@@ -3,7 +3,6 @@
 
 %% Clear Environment
 clear; clc; close all;
-addpath('fcn_core','fcn_help');
 addpath('CI_files'); % Test scripts
 
 try
@@ -66,7 +65,7 @@ set(gca, 'TickDir', 'out', 'YLim', [0,4]);
 % PlotID Implementation starts here.
 % TagPlot adds a visible ID to the figure(s) and to the figures property
 % 'Tag'
-[fig, ID] = TagPlot(fig, 'ProjectID', ProjectID);
+[fig, ID] = PlotID.TagPlot(fig, 'ProjectID', ProjectID);
 
 %% Publishing
 % Second part of plotID 
@@ -78,7 +77,7 @@ path.script = mfilename('fullpath'); % filename of the m.script
 % file names of the datasets
 path.rdata =  {dataset1,dataset2} ; % don't forget the extension
 
-Publish(path, ID, fig(1), 'Location', 'local','Method','centraliced')
+PlotID.Publish(path, ID, fig(1), 'Location', 'local','Method','centraliced')
 
 %% Example 2: multiple plots plot, all based on data-set2 (hdf5)
 % for individual data-sets, use an appropriate array
@@ -90,7 +89,7 @@ plot(x1,y1,'--k');
 set(gca, 'TickDir', 'out', 'YLim', [0,4]);
 
 % tag both plots 
-[fig, IDs] = TagPlot(fig,'ProjectID', ProjectID);
+[fig, IDs] = PlotID.TagPlot(fig,'ProjectID', ProjectID);
 
 % data locations
 path.script = mfilename('fullpath'); % filename of the m.script
@@ -99,8 +98,7 @@ path.rdata =  {dataset2} ; % don't forget the extension
 
 % publsihing via for-loop
 for i=1: numel(fig)
-    disp(string(i));
-    Publish(path, IDs{i}, fig(i), 'Location', 'local','Method','centraliced');
+    PlotID.Publish(path, IDs{i}, fig(i), 'Location', 'local','Method','centraliced');
 end
 
 %% Second Plot with identical data to test centralized method
@@ -111,6 +109,6 @@ plot(x,y,'-k');
 hold on
 plot(x1,y1,'-r');
 
-[fig2, ID] = TagPlot(fig2,'ProjectID', ProjectID);
+[fig2, ID] = PlotID.TagPlot(fig2,'ProjectID', ProjectID);
 
-Publish(path, ID, fig2, 'Location', 'local','Method','centraliced')
\ No newline at end of file
+PlotID.Publish(path, ID, fig2, 'Location', 'local','Method','centraliced')
\ No newline at end of file
-- 
GitLab