image_output_1.png
from skimage.transform import resize

import SimpleITK as sitk

import SimpleITK as sitk

import os

import os

import os

import os

import pandas as pd

import pandas as pd

import torch

import torch

import torch

labels = pd.read_csv('../input/rsna-miccai-brain-tumor-radiogenomic-classification/train_labels.csv')

data_len = 1000
labels['imfolder'] = ['{0:05d}'.format(s) for s in labels['BraTS21ID']]
path = '../input/rsna-miccai-brain-tumor-radiogenomic-classification/test/'
labels['path'] = [os.path.join(path, f) for f in labels['imfolder']]
train = labels[:data_len]
val_len = int(data_len * 0.2)

train = labels[:0]
path = '../input/rsna-miccai-brain-tumor-radiogenomic-classification/test/'
p = []
d = []
for i in range(1010):
    id_ = '{0:05d}'.format(i)
    if os.path.exists(path + id_):
        p.append(path + id_)
        d.append(id_)

def load(path, kind, image_size=128, depth=64):
    directory = path + '/' + kind
    reader = sitk.ImageSeriesReader()
    dicom_names = reader.GetGDCMSeriesFileNames(directory)
    reader.SetFileNames(dicom_names)
    image = reader.Execute()
    image = sitk.GetArrayFromImage(image)
    mid = int(image.shape[0] / 2)
    if image.shape[0] >= 64:
        image = image[mid - 32:mid + 32, :, :]
    image = resize(image, (64, 128, 128), preserve_range=True)
    image = torch.tensor(image)
    return image

image = load(path='../input/rsna-miccai-brain-tumor-radiogenomic-classification/test/01006/', kind='FLAIR')

image.shape