function DataChromatix(varargin) % % DataChromatix(data, timeunit, yunit, displaywin, shift, memorywin, ... % colorwin, nbins, ncolors, lambda, fs, videoname, minsec, cmap) % % Given any time series, creates a video of its chromatized version % based on the probability distribution of the previous values % on a certain window (memory). The memory can start from the beginning % of the recording or be specified by the user. % % inputs: % data --> 1-column matrix containing time series to colorize, in any units % timeunit --> string containing the label for the time axis % if you choose 1 for minsec, it overrides this one % yunit --> string containing the label for the y axis (physical units of % data) % displaywin --> window to display, in same units as data % shift --> shift from one window to the next, in same units as data % memorywin --> memory used to colorize time series, in same units as data. % If left empty,infinite memory is employed % default=memory starting from beginning of recording % colorwin --> length of window that is colorized at each iteration, % in same units as data. Must be >shift % if left empty, coincides with shift % nbins --> number of bins of the histogram % if left empty, it is estimated via the Freedman-Diaconis rule % ncolors --> number of colors used in the colorization (default=64) % lambda --> smoothing parameter for histogram (default=10) % fs --> sampling frequency of the data (default=1) % videoname --> string containing name of the video to be saved % (default='Myvideo') % input 0 if you don't want the video, only the final figure % minsec --> flag, if =1 shows time in mm:ss (default=0), assuming that % the original time series is in seconds % cmap --> colormap you want to use (default='jet') % % Examples: please note that the wfdb library must be installed % and in your Matlab path for the examples to work % % % Example 1: Fixed-length memory window % wfdb2mat('ctu-uhb-ctgdb/1170') % load 1170m % data=val(1,:)'; % data=data/100; % data(data<30 | data>240)=[]; % lambda=10; % fs=4; % T=600.0; % sec time interval to display (10min) % nbins=100; % ncolors=64; % colorwin=100; % Tshift=60.0; % sec time shift % DataChromatix(data, 'Time (mm:ss)', 'FHR (bpm)',T, Tshift, 1000, colorwin, nbins, ncolors, 10, fs, 'video1', 1) % % % Example 2: Memory window starting from the beginning of recording % wfdb2mat('ctu-uhb-ctgdb/1170') % load 1170m % data=val(1,:)'; % data=data/100; % data(data<30 | data>240)=[]; % lambda=10; % fs=4; % T=600.0; % sec time interval to display (10min) % Tshift=60.0; % sec time shift % DataChromatix(data, 'Time (s)', 'FHR (bpm)',T, Tshift, [], [], [], [], 10, fs, 0, 0) % % Authors: Anton Burykin and Sara Mariani, 2015 % Last Modified: January 7th, 2015 % % please report bugs/questions at sara.mariani7@gmail.com % % when using this script, please reference: % A. Burykin*, S. Mariani*, T. Henriques, T. Silva, % W. Schnettler, M. D. Costa** and A. L. Goldberger**, % "Remembrance of time series past: simple chromatic % method for visualizing trends in biomedical signals," % Physiol. Meas., vol. 36, pp. N95, 2015. inputs={'data','timeunit','yunit','displaywin','shift','memorywin', ... 'colorwin','nbins','ncolors','lambda', 'fs', 'videoname','minsec','cmap'}; if nargin>14 error('Too many input arguments') end if nargin<5 error('Not enough input arguments') end for n=1:nargin eval([inputs{n} '=varargin{n};']) end for n=nargin+1:14 eval([inputs{n} '=[];']) end if isempty(lambda), lambda=10; end if isempty(videoname), videoname='MyVideo'; end if isempty(minsec), minsec=0; end if isempty(cmap), cmap='jet'; end if isempty(fs), fs=1; end if isempty(ncolors), ncolors=64; end if isempty(colorwin), colorwin=shift; end if colorwin=z(n)) && (hr_mem(k)