Replies: 2 comments
-
Prefer using use dicom_dictionary_std::tags;
let image_laterality = if let Some(elem) = obj.element_opt(tags::IMAGE_LATERALITY)? {
elem.to_str()?
} else {
"".into()
}; Note also the preference in the use of methods |
Beta Was this translation helpful? Give feedback.
-
Many thanks for that, this is the perfect place. I'm trying to process in parallel, though I don't see any speedup TBH, and I thought this could be the reason for the Some details of my code: fn main() -> Result<(), Box<dyn std::error::Error>> {
...
// Process DICOM files in parallel
let results: Vec<_> = dicom_files
.par_chunks(num_jobs)
.map(|chunk| process_dicom_files(chunk))
.flatten()
.collect();
...
Ok(())
}
fn process_dicom_files(paths: &[PathBuf]) -> Vec<DicomData> {
paths
.iter()
.filter_map(|path| match extract_dicom_data(path) {
Ok(data) => Some(data),
Err(e) => {
eprintln!("Error processing {:?}: {}", path, e);
None
}
})
.collect()
} I've updated fn extract_dicom_data(path: &Path) -> Result<DicomData, Box<dyn std::error::Error>> {
let obj = OpenFileOptions::new()
.read_until(tags::PIXEL_DATA)
.open_file(path)?; To avoid reading I use |
Beta Was this translation helpful? Give feedback.
-
Originally posted by @alanwilter in #446 (comment)
Beta Was this translation helpful? Give feedback.
All reactions