Skip to content

Commit

Permalink
changed signature of dicom read metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Dec 7, 2023
1 parent 75aab0f commit 9158916
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion extras/fileformats/extras/medimage/dicom.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def dicom_dir_generate_sample_data(dcmdir: DicomDir, dest_dir: Path, seed: ty.Un


@FileSet.generate_sample_data.register
def dicom_set_generate_sample_data(dcm_series: DicomSeries, dest_dir: Path, seed: ty.Union[int, Random] = 0, stem: ty.Optional[str] = None) -> ty.Iterable[Path]:
def dicom_series_generate_sample_data(dcm_series: DicomSeries, dest_dir: Path, seed: ty.Union[int, Random] = 0, stem: ty.Optional[str] = None) -> ty.Iterable[Path]:
rng = Random(seed)
dicom_dir = dicom_dir_generate_sample_data(dcm_series, dest_dir=mkdtemp(), seed=rng, stem=None)[0]
stem = gen_filename(rng, stem=stem)
Expand Down
8 changes: 6 additions & 2 deletions fileformats/medimage/dicom.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,16 @@ def from_paths(
dicoms, remaining = Dicom.from_paths(fspaths, common_ok=common_ok)
series_dict = defaultdict(list)
for dicom in dicoms:
series_dict[(str(dicom["StudyInstanceUID"]), str(dicom["SeriesNumber"]))].append(dicom)
series_dict[
(str(dicom["StudyInstanceUID"]), str(dicom["SeriesNumber"]))
].append(dicom)
return set([cls(s) for s in series_dict.values()]), remaining


@FileSet.read_metadata.register
def dicom_collection_read_metadata(collection: DicomCollection) -> ty.Mapping[str, ty.Any]:
def dicom_collection_read_metadata(
collection: DicomCollection, selected_keys: ty.Optional[ty.Sequence[str]] = None
) -> ty.Mapping[str, ty.Any]:
# Collated DICOM headers across series
collated = copy(collection.contents[0].metadata)
for i, dicom in enumerate(collection.contents[1:], start=1):
Expand Down

0 comments on commit 9158916

Please sign in to comment.