deepecgkit.utils¶
Utility functions for CSV reading, pretrained weight management, and download locations.
read_csv
¶
read_csv(
csv_file: str,
delimiter: str = ",",
transpose: bool = False,
skip_header: bool = True,
dtype: type | None = None,
) -> tuple[np.ndarray, dict[str, int]]
Read CSV file and return data array and header mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
csv_file
|
str
|
Path to the CSV file |
required |
delimiter
|
str
|
Column delimiter (default: ',') |
','
|
transpose
|
bool
|
Whether to transpose the data array |
False
|
skip_header
|
bool
|
Whether to skip the first row as header |
True
|
dtype
|
type | None
|
Data type for the numpy array |
None
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, dict[str, int]]
|
Tuple of (data_array, header_mapping) |
Source code in deepecgkit/utils/__init__.py
get_data_home
¶
Return the root directory for downloaded datasets.
Returns:
| Type | Description |
|---|---|
Path
|
|
Path
|
|
Source code in deepecgkit/utils/paths.py
list_pretrained_weights
¶
List the pretrained weights that can be downloaded, with descriptions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_unpublished
|
bool
|
Also list registry entries that are reserved for a future release and have nothing to download yet |
False
|
Source code in deepecgkit/utils/weights.py
is_published
¶
Report whether registered weights can actually be downloaded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weight_name
|
str
|
Key into the pretrained weight registry |
required |
Returns:
| Type | Description |
|---|---|
bool
|
False for unknown names and for entries whose URL is still a |
bool
|
placeholder awaiting a published release. |
Source code in deepecgkit/utils/weights.py
load_pretrained_weights
¶
load_pretrained_weights(
weight_name: str,
map_location: str | device | None = None,
force_download: bool = False,
) -> dict
Load pretrained weights by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weight_name
|
str
|
Name of the pretrained weights |
required |
map_location
|
str | device | None
|
Device to map weights to (e.g., "cpu", "cuda") |
None
|
force_download
|
bool
|
If True, re-download weights even if cached |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
State dict containing model weights |
Source code in deepecgkit/utils/weights.py
register_weights
¶
register_weights(
name: str,
url: str,
model_class: str,
model_kwargs: dict,
description: str = "",
) -> None
Register custom pretrained weights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Unique name for the weights |
required |
url
|
str
|
URL to download weights from |
required |
model_class
|
str
|
Name of the model class these weights are for |
required |
model_kwargs
|
dict
|
Keyword arguments to instantiate the model |
required |
description
|
str
|
Human-readable description of the weights |
''
|