function [origin, fs, poc, duration, f0] = loading(measuredsignal)
% loading charges an eeg signals in a different formats
%
%% Syntax:
%
% [origin, fs, poc, duration, f0] = loading(measuredsignal)
%
%% Description:
%
% This function serves to signal loading. Firtsly the setting of the
% initial conditions must be do manually, the signal file, the sampling
% frequency, the beginning positions of sinusoid trials, the sinusoid trial
% duration and the sinusoid trials frequencies. Then the loading eeg signal
% is plotted.
%
%% Inputs:
%
% measuredsignal: a file with experimental eeg signal
% 
%% Outputs:
%
% origin: a matrix with eeg signal, a number of rows corresponds to a
%         number of channels
%
% fs: a sampling frequency
%
% poc: a n-by-1 vector containing a beginning indices of sinusoid trials
%
% duration: a n-by-1 vector containing a time duration of each sinusoid
%           trial
%
% frequency: a n-by-1 vector containing an individual frequencies of
%            sinusoid trials.
%
%% Author: Veronika Svozilová
%% Date: 08/04/2015
%
%% The setting of the initial conditions
%
prompt = 'What is the original signal? ';
measuredsignal = input(prompt);
prompt2 = 'What is the sampling frequency? ';
fs = input(prompt2);
prompt3 = 'What are the positions of trial beginnings? ';
poc = input(prompt3);
prompt4 = 'What is the duration of trials? ';
duration = input(prompt4);
prompt5 = 'What is the frequency of trials? ';
f0 = input(prompt5);
%
%% The signal loading, for .hdf5 format 
infoorigsignal = h5info(measuredsignal);               
origin = h5read(measuredsignal, '/RawData/Samples');
%
%% The signal loading, for .exp format
% fid = fopen(measuredsignal);
% data0 = fread(fid, 'float32');
% data = reshape(data0, 16, []);
% origin = [data(5,:); data(1,:); data(2,:); data(3,:); data(4,:)];
%
%% Plot the loading eeg signal 
figure
plot(origin(1,:),'r')
hold on
plot(origin(2,:),'g')
% hold on
% plot(origin(3,:),'b')
% hold on
% plot(origin(4,:),'y')
end