diff --git a/xnat_ingest/session.py b/xnat_ingest/session.py index 0bb3952..04f4ec5 100644 --- a/xnat_ingest/session.py +++ b/xnat_ingest/session.py @@ -215,7 +215,13 @@ def from_dicoms( DICOM files within the session """ if isinstance(dicoms_path, Path) or "*" not in dicoms_path: - dicom_fspaths = list(Path(dicoms_path).iterdir()) + dicoms_path = Path(dicoms_path) + if not dicoms_path.exists(): + raise ValueError(f"Provided DICOMs path '{dicoms_path}' does not exist") + if dicoms_path.is_dir(): + dicom_fspaths = list(Path(dicoms_path).iterdir()) + else: + dicom_fspaths = [dicoms_path] else: dicom_fspaths = [Path(p) for p in glob(dicoms_path)]