Dicom find
dicom_find
#
Functions:
| Name | Description |
|---|---|
convert_to_case_insensitive |
Deprecated helper kept for compatibility. |
filter_valid_dicoms |
Yield valid DICOM file paths from a directory. |
find_dicoms |
Locate DICOM files in a specified directory. |
convert_to_case_insensitive
#
Deprecated helper kept for compatibility.
Source code in src/imgtools/dicom/dicom_find.py
filter_valid_dicoms
#
filter_valid_dicoms(
directory: pathlib.Path,
check_header: bool,
case_sensitive: bool,
search_input: typing.List[str] | None,
extension: str,
recursive: bool,
) -> typing.Generator[pathlib.Path, None, None]
Yield valid DICOM file paths from a directory.
Unlike the original glob/rglob implementation, this traversal follows nested symlinked directories.
Source code in src/imgtools/dicom/dicom_find.py
find_dicoms
#
find_dicoms(
directory: pathlib.Path,
recursive: bool = True,
check_header: bool = False,
extension: str = "dcm",
case_sensitive: bool = False,
limit: int | None = None,
search_input: typing.List[str] | None = None,
) -> typing.List[pathlib.Path]
Locate DICOM files in a specified directory.
This function scans a directory for files matching the specified extension and validates them as DICOM files based on the provided options. It supports recursive search, nested symbolic links to directories, and optional header validation to confirm file validity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
pathlib.Path
|
The directory in which to search for DICOM files. |
required |
|
bool
|
Whether to include subdirectories in the search. |
True
|
|
bool
|
Whether to validate files by checking for a valid DICOM header.
- If |
False
|
|
str
|
File extension to search for (e.g., "dcm"). If empty, consider all files regardless of extension. |
"dcm"
|
|
bool
|
Whether to perform a case-sensitive search for the file extension. |
False
|
|
int
|
Maximum number of DICOM files to return. If |
None
|
|
typing.List[str]
|
List of terms to filter files by. Only files containing all terms
in their paths will be included. If |
None
|
Returns:
| Type | Description |
|---|---|
typing.List[pathlib.Path]
|
A list of valid DICOM file paths found in the directory. |