Skip to content

Commit

Permalink
Correct how the number of timepoints in a 4D scan is determined (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
nlessmann authored Jun 24, 2022
1 parent 7efad9c commit fb40477
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions panimg/image_builders/dicom.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,12 @@ def _find_valid_dicom_files(
continue

n_files = len(headers)
n_time = max(
int(getattr(header["data"], "TemporalPositionIndex", 0))
for header in headers
n_time = len(
{
int(header["data"].TemporalPositionIndex)
for header in headers
if "TemporalPositionIndex" in header["data"]
}
)

arbitrary_header = headers[0]["data"]
Expand All @@ -487,8 +490,8 @@ def _find_valid_dicom_files(
)
n_slices = n_files * n_slices_per_file

if n_time < 1:
# Not a 4d dicom file (DICOM standard says TPI is >=1 )
if n_time < 2:
# Not a 4d dicom file
result.append(
DicomDataset(
name=set_name,
Expand Down

0 comments on commit fb40477

Please sign in to comment.