% This script is provided "as is", and the authors are not responsible
% whatsoever for the outcomes of this script or any modification.		
% The usage of the script in any publication should be acknowledged by citing:
% Barbieri L, Luchinat E, "Monitoring Protein-Ligand Interactions in Human 
% Cells by Real-Time Quantitative In-Cell NMR using a High Cell Density 
% Bioreactor", Journal of Visualized Experiments.
% ---------------------------------------------------

%choose NMR dataset
 folder = uigetdir();
 
%load ascii file for each spectrum (output of convbin2asc)
 acquslist = dir(fullfile(fullfile({filelist.folder}), '\acqus')); 

% Get full path names for each text file
acqus_paths = fullfile({filelist.folder}, '..\..\acqus');

% Regular rexpression to extract datestamp
expr = '[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9 .]{6}';

% Get datetimes as a vector
for i = 1 : numel(acqus_paths)
 acqus_file = fileread(acqus_paths{i});
 datestring = regexp(acqus_file,expr,'match');
 datetimes(i,:) = datetime(datestring,'InputFormat','yyyy-MM-dd HH:mm:ss.SSS');
end

% Create vector of time increments for each spectrum 
% (initial spectrum time = 0)
times_hours = hours(datetimes - datetimes(1,1));