torch_ecg.utils.ecg_plot¶
- torch_ecg.utils.ecg_plot(ecg: Dict[str, ndarray], sample_rate: int, columns: int, rec_file_name: str | bytes | PathLike, output_dir: str | bytes | PathLike, resolution: int = 200, pad_inches: int = 0, lead_index: List[str] | None = None, full_mode: str = 'None', store_text_bbox: bool = False, units: str = 'mV', papersize: str | None = None, x_gap: float = 1.0, y_gap: float = 0.5, display_factor: float = 1.0, line_width: float = 0.75, title: str | None = None, style: str | None = None, row_height: float = 8.0, show_lead_name: bool = True, show_grid: bool = False, show_dc_pulse: bool = False, y_grid: float | None = None, x_grid: float | None = None, standard_colours: int = 0, bbox: bool = False, print_txt: bool = False, save_format: str | None = None) Tuple[float, float] [source]¶
Function to plot raw ECG signal.
- Parameters:
ecg (Dict[str, np.ndarray]) – Dictionary of ECG signals with lead names as keys, values as 1D numpy arrays.
sample_rate (int) – Sampling rate of the ECG signal.
columns (int) – Number of columns to be plotted in each row.
rec_file_name (path-like) – Name of the record file.
output_dir (path-like) – Output directory.
resolution (int, default
200
) – Resolution of the output image.pad_inches (int, default
0
) – Padding of white margin along the image in inches.lead_index (List[str], optional) – Order of lead indices to be plotted. By default, the order is the same as the order in
ecg
.full_mode (str, default
"None"
) – Sets the lead to add at the bottom of the paper ECG as a long strip. If"None"
, no lead is added at the bottom. If not"None"
, the lead"full" + full_mode
must be present inecg
.store_text_bbox (bool, default
False
) – IfTrue
, stores the bounding box of the text in a text file.units (str, default
"mV"
) – Units of the ECG signal. NOT used currently.papersize ({
"A0"
,"A1"
,"A2"
,"A3"
,"A4"
,"letter"
}, defaultNone
) – Size of the paper to plot the ECG on.x_gap (float, default
1.0
) – Gap between paper x axis border and signal plot.y_gap (float, default
0.5
) – Gap between paper y axis border and signal plot.display_factor (float, default
1.0
) – Factor to scale the ECG signal by.line_width (float, default
0.75
) – Width of line tracing the ECG.title (str, optional) – Title of the figure.
style ({
"bw"
,"color"
}, optional) – Sets the style of the plot.row_height (float, default
8.0
) – Gap between corresponding ECG rows.show_lead_name (bool, default
True
) – Option to show lead names or skip.show_grid (bool, default
False
) – Turn grid on or off.show_dc_pulse (bool, default
False
) – Option to show DC pulse.y_grid (float, optional) – Sets the y grid size in inches.
x_grid (float, optional) – Sets the x grid size in inches.
standard_colours ({
0
,1
,2
,3
,4
,5
}, default0
) – Sets the colour of the plot grid.bbox (bool, default
False
) – IfTrue
, stores the bounding box of the lead in a text file.print_txt (bool, default
False
) – IfTrue
, prints the metadata of the plot.save_format ({
"png"
,"pdf"
,"svg"
,"jpg"
}, optional) – Format to save the plot in. IfNone
, the plot is not saved.
- Returns:
x_grid_dots (float) – X grid size in dots.
y_grid_dots (float) – Y grid size in dots.