### Install dicom2jpg Source: https://github.com/ykuo2/dicom2jpg/blob/main/README.md Use pip to install the package. ```bash pip install dicom2jpg ``` -------------------------------- ### Convert DICOM files and extract image data Source: https://github.com/ykuo2/dicom2jpg/blob/main/README.md Examples of converting DICOM files to various image formats and extracting data into numpy arrays. ```python import dicom2jpg dicom_img_01 = "/Users/user/Desktop/img01.dcm" dicom_dir = "/Users/user/Desktop/Patient_01" export_location = "/Users/user/Desktop/BMP_files" # convert single DICOM file to jpg format dicom2jpg.dicom2jpg(dicom_img_01) # convert all DICOM files in dicom_dir folder to png format dicom2jpg.dicom2png(dicom_dir) # convert all DICOM files in dicom_dir folder to bmp, to a specified location dicom2jpg.dicom2bmp(dicom_dir, target_root=export_location) # convert single DICOM file to numpy.ndarray for further use img_data = dicom2jpg.dicom2img(dicom_img_01) # convert DICOM ByteIO to numpy.ndarray img_data = dicom2jpg.io2img(dicomIO) ``` -------------------------------- ### dicom2jpg.dicom2bmp(origin, target_root=None, anonymous=False, multiprocessing=True) Source: https://github.com/ykuo2/dicom2jpg/blob/main/README.md Converts DICOM files or folders to BMP format. ```APIDOC ## dicom2jpg.dicom2bmp(origin, target_root=None, anonymous=False, multiprocessing=True) ### Description Converts a single DICOM file, a folder, or a list/tuple of files/folders to BMP format. ### Parameters - **origin** (str/list/tuple) - Required - A single DICOM file, a folder, or a list/tuple of file/folder paths. - **target_root** (str) - Optional - The root folder for exported files. Defaults to the root folder of the first file/folder. - **anonymous** (bool) - Optional - If True, uses anonymous file path structure. Defaults to False. - **multiprocessing** (bool) - Optional - If True, enables multiprocessing for conversion. Defaults to True. ``` -------------------------------- ### dicom2jpg.dicom2jpg(origin, target_root=None, anonymous=False, multiprocessing=True) Source: https://github.com/ykuo2/dicom2jpg/blob/main/README.md Converts DICOM files or folders to JPG format. ```APIDOC ## dicom2jpg.dicom2jpg(origin, target_root=None, anonymous=False, multiprocessing=True) ### Description Converts a single DICOM file, a folder, or a list/tuple of files/folders to JPG format. ### Parameters - **origin** (str/list/tuple) - Required - A single DICOM file, a folder, or a list/tuple of file/folder paths. - **target_root** (str) - Optional - The root folder for exported files. Defaults to the root folder of the first file/folder. - **anonymous** (bool) - Optional - If True, uses anonymous file path structure. Defaults to False. - **multiprocessing** (bool) - Optional - If True, enables multiprocessing for conversion. Defaults to True. ``` -------------------------------- ### dicom2jpg.dicom2png(origin, target_root=None, anonymous=False, multiprocessing=True) Source: https://github.com/ykuo2/dicom2jpg/blob/main/README.md Converts DICOM files or folders to PNG format. ```APIDOC ## dicom2jpg.dicom2png(origin, target_root=None, anonymous=False, multiprocessing=True) ### Description Converts a single DICOM file, a folder, or a list/tuple of files/folders to PNG format. ### Parameters - **origin** (str/list/tuple) - Required - A single DICOM file, a folder, or a list/tuple of file/folder paths. - **target_root** (str) - Optional - The root folder for exported files. Defaults to the root folder of the first file/folder. - **anonymous** (bool) - Optional - If True, uses anonymous file path structure. Defaults to False. - **multiprocessing** (bool) - Optional - If True, enables multiprocessing for conversion. Defaults to True. ``` -------------------------------- ### dicom2jpg.dicom2tiff(origin, target_root=None, anonymous=False, multiprocessing=True) Source: https://github.com/ykuo2/dicom2jpg/blob/main/README.md Converts DICOM files or folders to TIFF format. ```APIDOC ## dicom2jpg.dicom2tiff(origin, target_root=None, anonymous=False, multiprocessing=True) ### Description Converts a single DICOM file, a folder, or a list/tuple of files/folders to TIFF format. ### Parameters - **origin** (str/list/tuple) - Required - A single DICOM file, a folder, or a list/tuple of file/folder paths. - **target_root** (str) - Optional - The root folder for exported files. Defaults to the root folder of the first file/folder. - **anonymous** (bool) - Optional - If True, uses anonymous file path structure. Defaults to False. - **multiprocessing** (bool) - Optional - If True, enables multiprocessing for conversion. Defaults to True. ``` -------------------------------- ### DICOM conversion function signatures Source: https://github.com/ykuo2/dicom2jpg/blob/main/README.md Function signatures for converting DICOM files to image formats. ```python dicom2jpg.dicom2jpg(origin, target_root=None, anonymous=False, multiprocessing=True) dicom2jpg.dicom2png(origin, target_root=None, anonymous=False, multiprocessing=True) dicom2jpg.dicom2bmp(origin, target_root=None, anonymous=False, multiprocessing=True) dicom2jpg.dicom2tiff(origin, target_root=None, anonymous=False, multiprocessing=True) ``` -------------------------------- ### DICOM to numpy array function signatures Source: https://github.com/ykuo2/dicom2jpg/blob/main/README.md Function signatures for converting DICOM data to numpy arrays. ```python dicom2jpg.dicom2img(origin) dicom2jpg.io2img(dicomIO) ``` -------------------------------- ### dicom2jpg.dicom2img(origin) Source: https://github.com/ykuo2/dicom2jpg/blob/main/README.md Converts a DICOM file to a numpy.ndarray. ```APIDOC ## dicom2jpg.dicom2img(origin) ### Description Converts a single DICOM file to a numpy.ndarray (8-bit, RGB if color). ### Parameters - **origin** (str) - Required - Path to the DICOM file. ``` -------------------------------- ### dicom2jpg.io2img(dicomIO) Source: https://github.com/ykuo2/dicom2jpg/blob/main/README.md Converts a DICOM ByteIO stream to a numpy.ndarray. ```APIDOC ## dicom2jpg.io2img(dicomIO) ### Description Converts a DICOM ByteIO stream to a numpy.ndarray (8-bit, RGB if color). ### Parameters - **dicomIO** (ByteIO) - Required - The DICOM ByteIO stream. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.