Skip to content

Commit

Permalink
Merge pull request #2827 from activeloopai/dicom_shape_calculation
Browse files Browse the repository at this point in the history
consider more than one frame in dicom
  • Loading branch information
azat-manukyan committed Apr 22, 2024
2 parents b37edbb + 215c270 commit db94b51
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions deeplake/core/compression.py
Expand Up @@ -780,10 +780,15 @@ def _read_dicom_shape_and_dtype(
f = BytesIO(f) # type: ignore
dcm = dcmread(f)
nchannels = dcm[0x0028, 0x0002].value
shape = (dcm.Rows, dcm.Columns, nchannels)
numOfFrames = dcm.get("NumberOfFrames", -1)

isfloat = "FloatPixelData" in dcm or "DoubleFloatPixelData" in dcm
dtype = pixel_dtype(dcm, isfloat).str
return shape, dtype

if numOfFrames != -1:
return (int(numOfFrames), dcm.Rows, dcm.Columns, nchannels), dtype
else:
return (dcm.Rows, dcm.Columns, nchannels), dtype


def _decompress_dicom(f: Union[str, bytes, BinaryIO]):
Expand Down

0 comments on commit db94b51

Please sign in to comment.