The top level analysis functions in
mhrv can be used as a command-based
user interface to the toolbox. The
allow analysis of both ECG and R-peak annotation files in WFDB format and return
all HRV metrics supported by the toolbox.
Analyzes an ECG signal, detects and filters R-peaks and calculates various heart-rate variability (HRV) metrics on them.
- rec_name – Path and name of a wfdb record’s files e.g. db/mitdb/100 if the record files (both 100.dat and 100.hea) are in a folder named ‘db/mitdb’ relative to MATLABs pwd.
- varargin –
Pass in name-value pairs to configure advanced options.
- ecg_channel: The channel number to use (in case the record has more than one). If not provided, mhrv will attempt to use the first channel that has ECG data.
- ann_ext: Specify an annotation file extention to use instead of loading the record itself (.dat file). If provided, RR intervals will be loaded from the annotation file instead of from the ECG. Default: empty (don’t use annotation).
- window_minutes: Split ECG signal into windows of the specified length (in minutes) and perform the analysis on each window separately.
- window_index_offset: Number of windows to skip from the beginning.
- window_index_limit: Maximal number of windows to process. Combined with the above, this allows control of which window to start from and how many windows to process from there.
- params: Name of mhrv defaults file to use (e.g. ‘canine’). Default ‘’, i.e. no parameters file will be loaded. Alternatively, can also be a cell array containing the exact arguments to pass to mhrv_load_params. This allows overriding parameters from a script.
- transform_fn: A function handle to apply to the NN intervals before calculating metrics. The function handle should accept one argument only, the NN interval lengths.
- plot: true/false whether to generate plots. Defaults to true if no output arguments were specified.
- hrv_metrics: A table where each row is a window and each column is an HRV metrics that was calculated in that window.
- hrv_stats: A table containing various statistics about each metric, calculated over all windows.
- plot_datas: Cell array containing the plot_data structs for each window.
Performs batch processing of multiple records with mhrv.
This function analyzes multiple physionet records with mhrv and outputs tables containting the results. The records to analyze can be subdivided into record types, in which case output tables will be generated for each record type. Optionally, an Excel file can be generated containing the results of the analysis, including a comparison of the results per group.
- rec_dir – Directory to scan for input files.
- varargin –
Optional key-value parameter pairs.
- rec_types: A cell array containing the names of the type of record to analyze.
- rec_filenames: A cell array with identical length as ‘rec_names’, containing patterns to match against the files in ‘rec_dir’ for each ‘rec_type’.
- rec_transforms: A cell array of transform functions to apply to each file in each record (one transform for each rec_type).
- ann_ext: Specify an annotation file extention to use instead of loading the record itself (.dat file). If provided, RR intervals will be loaded from the annotation file instead of from the ECG. Can also be a cell-array of strings the same length as rec types. This allows using a different annotator extension for each rec type. Default: empty string (don’t use annotation).
- min_nn: Set a minumum number of NN intervals so that windows with less will be discarded. Default is 0 (don’t discard anything).
- rr_dist_max: Sanity threshold for RR interval distribution. Windows where mean(RR)+2std(RR) > rr_dist_max will be discarded.
- rr_dist_min: Similar to above, but will discard windows where mean(RR)-2std(RR) < rr_dist_min.
- mhrv_params: Parameters pass into mhrv when processing each record. Can be either a string specifying the parameters file name, or it can be a cell array where the first entry is the parameters file name and the subsequent entires are key-value pairs that override parameters from the file.
- skip_plot_data: Whether to skip saving the plot data for each record. This can reduce memory consumption significantly for large batches. Default: false.
- writexls: true/false whether to write the output to an Excel file.
- output_dir: Directory to write output file to.
- output_filename: Desired name of the output file.
A structure, batch_data, containing the following fields:
- rec_types: A cell of strings of the names of the record types that were analyzed.
- rec_transforms: A cell array of the RR transformation functis used on each record type.
- mhrv_window_minutes: Number of minutes in each analysis windows that each record was split into.
- mhrv_params: A cell array containing the value of the params argument passed to mhrv for the analysis (see mhrv documentation).
- hrv_tables: A map from each value in ‘rec_types’ to the table of HRV values for that type. - stats_tables: A map with keys as above, whose values are summary tables for each type.
- plot_datas: A map with keys as above, whose values are also maps, mapping from an individual record filename to the matching plot data object (which can be used for generating plots).