4d9d2a1fc4e0d9289000a235340235802d51a97a,app/grandchallenge/cases/image_builders/dicom.py,,_create_itk_from_dcm,#,262

Before Change



        del dcm_array

        img = SimpleITK.Image(shape, sitk_dtype, 1)
        SimpleITK._SimpleITK._SetImageFromArray(temp.read(), img)

    return img

After Change


    if samples_per_pixel > 1:
        pixel_dims += (samples_per_pixel,)
    dcm_array = None
    use_pixel_array = False

    for index, partial in enumerate(dicom_ds.headers):
        ds = pydicom.dcmread(str(partial["file"]))

        if apply_scaling:
            pixel_array = float(
                getattr(ds, "RescaleSlope", 1)
            ) * ds.pixel_array + float(getattr(ds, "RescaleIntercept", 0))
        else:
            pixel_array = ds.pixel_array

        if (
            len(pixel_array.shape) == dimensions
            or pixel_array.shape == pixel_dims
        ):
            use_pixel_array = True
            del ds
            break
        if dcm_array is None:
            dcm_array = np.zeros(pixel_dims, dtype=np_dtype)

        z_index = index if z_i >= 0 else len(dicom_ds.headers) - index - 1

        if dimensions == 4:
            dcm_array[
                index // dicom_ds.n_slices, z_index % dicom_ds.n_slices, :, :
            ] = pixel_array
            if index % dicom_ds.n_slices == 0:
                content_times.append(str(ds.ContentTime))
                exposures.append(str(ds.Exposure))
        else:
            dcm_array[z_index % dicom_ds.n_slices, :, :] = pixel_array

        del ds
    if use_pixel_array:
        img = SimpleITK.GetImageFromArray(pixel_array, isVector=is_rgb)
    else:
        img = SimpleITK.GetImageFromArray(dcm_array, isVector=is_rgb)
    return img


def image_builder_dicom(
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: comic/grand-challenge.org
Commit Name: 4d9d2a1fc4e0d9289000a235340235802d51a97a
Time: 2021-02-12
Author: 57257130+MikeOverkamp-diag@users.noreply.github.com
File Name: app/grandchallenge/cases/image_builders/dicom.py
Class Name:
Method Name: _create_itk_from_dcm


Project Name: sassoftware/python-dlpy
Commit Name: 3e07cdecb8d7eea947304fae062ed0e64b519052
Time: 2017-07-07
Author: leo.liu@sas.com
File Name: dl_api/images.py
Class Name: Image
Method Name: resize


Project Name: sassoftware/python-dlpy
Commit Name: 3e07cdecb8d7eea947304fae062ed0e64b519052
Time: 2017-07-07
Author: leo.liu@sas.com
File Name: dl_api/images.py
Class Name: Image
Method Name: crop


Project Name: comic/grand-challenge.org
Commit Name: 4d9d2a1fc4e0d9289000a235340235802d51a97a
Time: 2021-02-12
Author: 57257130+MikeOverkamp-diag@users.noreply.github.com
File Name: app/grandchallenge/cases/image_builders/dicom.py
Class Name:
Method Name: _create_itk_from_dcm