zae_engine.utils package¶
Subpackages¶
Submodules¶
zae_engine.utils.io module¶
- zae_engine.utils.io.example_ecg(beat_idx: int = None) Tuple[ndarray, ...] [소스]¶
Load a 10-second ECG recording and annotation from LUDB dataset [1], which has a sampling frequency of 250Hz.
The ‘*.zae’ file in package contains QRS complex information from raw data[1] and beat locations via algorithm. If the argument ‘beat_idx’ is None (default), the function returns the 10-second recording and label sequence. If ‘beat_idx’ is specified, the function returns the segment of the recording, the location, and the symbol of beat.
- 매개변수:
beat_idx (int, optional) – The index of the beat in the data. The value cannot be greater than the maximum index of beats in the data (12). If this parameter is not specified, the function returns the 10-second data.
- 반환:
signal (np.ndarray) – The 10-second ECG recording. If ‘beat_idx’ is specified, this is the segment of the recording around the specified beat.
label (np.ndarray or int) – If ‘beat_idx’ is None, this is the label sequence for the 10-second data. If ‘beat_idx’ is specified, this is the type of the specified beat.
loc (None or int) – The location of the specified beat if ‘beat_idx’ is specified. Otherwise, this is None.
참조
- zae_engine.utils.io.example_mri() ArrayProxy [소스]¶
Load a 4D MRI scan .
This function loads an MRI scan stored in a NIfTI file (‘.nii.gz’) and returns the image data as an ArrayProxy object. The MRI scan is expected to be a 4-dimensional array.
- 매개변수:
None
- 반환:
The 4-dimensional MRI scan data as an ArrayProxy object. The dimensions represent: - Frequency encoding - Phase encoding - Slice - Complex component (real and imaginary)
- 반환 형식:
nibabel.arrayproxy.ArrayProxy
참고
This function assumes that the file ‘example4d.nii.gz’ exists in the ‘data_path’ directory provided by nibabel’s testing module. The NIfTI file format is commonly used for storing MRI data, and this function uses the nibabel library to read it. If the ‘get_fdata’ method is available in the loaded object, the function returns the image data directly from the data object.
예제
>>> mri_data = example_mri() >>> print(mri_data.shape) (128, 96, 24, 2) # Example output, actual dimensions may vary
참조
The NIfTI file format: https://nifti.nimh.nih.gov/nifti-1 The nibabel library documentation: https://nipy.org/nibabel/
- zae_engine.utils.io.image_from_url(url: str, save_dst: str = None) None | Image [소스]¶
Download an image from a URL and optionally save it to a specified path.
This function downloads an image from the provided URL. If a save destination is provided, the image is saved to the specified path. If no save destination is provided, the image is temporarily saved, opened, and returned as a PIL Image object.
- 매개변수:
url (str) – The URL of the image to be downloaded.
save_dst (str, optional) – The file path where the image should be saved. If not provided, the image is temporarily saved and returned as a PIL Image object.
- 반환:
If save_dst is provided, the function returns None after saving the image. If save_dst is not provided, the function returns the image as a PIL Image object.
- 반환 형식:
None or Image.Image
- 예외 발생:
AssertionError – If the file extension of save_dst is not one of the supported formats: ‘png’, ‘jpg’, ‘jpeg’, ‘tif’.
참고
The supported image formats are defined in the IMAGE_FORMAT list.
예제
Download and save an image: >>> image_from_url(’https://example.com/image.png’, ‘downloaded_image.png’)
Download an image and return it as a PIL Image object: >>> img = image_from_url(’https://example.com/image.png’) >>> img.show()