autods_pet.imaging.dicom#
DICOM discovery, tag extraction, and NIfTI conversion for autods_pet.
Provides functions to find DICOM files, extract PET/CT metadata tags, and convert DICOM series to NIfTI format using pydicom and SimpleITK.
- autods_pet.imaging.dicom.resolve_patient_folder(basepath, patient_id)[source]#
Case-insensitive lookup for a patient subfolder.
Returns the resolved
Pathor None if no match is found.
- autods_pet.imaging.dicom.find_dicom_files(patient_dir, size_threshold_kb=100)[source]#
Recursively find
.dcmfiles above a size threshold.
- autods_pet.imaging.dicom.find_series_by_modality(patient_dir, size_threshold_kb=100)[source]#
Find the primary CT and PT DICOM series in a patient directory.
Groups
.dcmfiles by(Modality, SeriesInstanceUID), then picks the series with the most files for each modality.Note
This function reads DICOM headers for every
.dcmfile sequentially (O(n) disk reads, no parallelism). For directories with 1000+ files on network-attached storage this may be slow. Consider parallel header reads for high-throughput deployments.
- autods_pet.imaging.dicom.extract_pet_tags(dicom_path)[source]#
Extract PET metadata tags from a single DICOM file.
Handles nested
RadiopharmaceuticalInformationSequencewith top-level fallback for dose and half-life tags.- Returns:
Keys match the metadata expected by
normalize_pet():PatientID,StudyDate,AcquisitionTime,Units,DecayCorrection,RadiopharmaceuticalStartTime,RadionuclideTotalDose,RadionuclideHalfLife,SeriesInstanceUID,StudyInstanceUID. Missing tags are set to None.- Return type:
- Parameters:
- autods_pet.imaging.dicom.extract_ct_tags(dicom_path)[source]#
Extract CT metadata tags from a single DICOM file.
- autods_pet.imaging.dicom.extract_patient_weight(dicom_path)[source]#
Extract patient weight (kg) from a DICOM file.