def _get_slice_pixeldata(dicom_slice):
    """
    the slice and intercept calculation can cause the slices to have different dtypes
    we should get the correct dtype that can cover all of them

    :type dicom_slice: pydicom object
    :param dicom_slice: slice to get the pixeldata for
    """
    data = dicom_slice.pixel_array
    # fix overflow issues for signed data where BitsStored is lower than BitsAllocated and PixelReprentation = 1 (signed)
    # for example a hitachi mri scan can have BitsAllocated 16 but BitsStored is 12 and HighBit 11
    if dicom_slice.BitsAllocated != dicom_slice.BitsStored and \
            dicom_slice.HighBit == dicom_slice.BitsStored - 1 and \
            dicom_slice.PixelRepresentation == 1:
        if dicom_slice.BitsAllocated == 16:
            data = data.astype(numpy.int16)  # assert that it is a signed type
        max_value = pow(2, dicom_slice.HighBit) - 1
        invert_value = -1 ^ max_value
        data[data > max_value] = numpy.bitwise_or(data[data > max_value], invert_value)
        pass
    return apply_scaling(data, dicom_slice)
def _get_slice_pixeldata ( dicom_slice ) : data = dicom_slice . pixel_array if dicom_slice . BitsAllocated != dicom_slice . BitsStored and dicom_slice . HighBit == dicom_slice . BitsStored - 1 and dicom_slice . PixelRepresentation == 1 : if dicom_slice . BitsAllocated == 16 : data = data . astype ( numpy . int16 ) max_value = pow ( 2 , dicom_slice . HighBit ) - 1 invert_value = - 1 ^ max_value data [ data > max_value ] = numpy . bitwise_or ( data [ data > max_value ] , invert_value ) pass return apply_scaling ( data , dicom_slice )
the slice and intercept calculation can cause the slices to have different dtypes
    we should get the correct dtype that can cover all of them

    :type dicom_slice: pydicom object
    :param dicom_slice: slice to get the pixeldata for