{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np \nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport matplotlib.lines as lines\nimport pydicom\n\nfrom glob import glob\n\nplt.style.use('ggplot')","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-08-08T16:38:43.408818Z","iopub.execute_input":"2021-08-08T16:38:43.409264Z","iopub.status.idle":"2021-08-08T16:38:43.758418Z","shell.execute_reply.started":"2021-08-08T16:38:43.409178Z","shell.execute_reply":"2021-08-08T16:38:43.757509Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def level(mean, std):\n    return mean + 1.7 * std\n\ndef read_dicom_files(cohort, case, mpMRI):\n    PATH = '../input/rsna-miccai-brain-tumor-radiogenomic-classification'\n    files_glob = f'{PATH}/{cohort}/{case}/{mpMRI}/*.dcm'\n    sorted_files = sorted(glob(files_glob),key=lambda f: int(f.split('Image-')[1].split('.')[0]))\n    return [pydicom.read_file(f) for f in sorted_files]\n\ndef image_orientation(dicom):\n    rt = 'unkown'\n    # https://www.kaggle.com/davidbroberts/determining-mr-image-planes\n    (x1,y1,_,x2,y2,_) = [round(v) for v in dicom.ImageOrientationPatient]\n    if (x1,y1,x2,y2) == (1,0,0,0):\n        rt = 'coronal'\n    if (x1,y1,x2,y2) == (1,0,0,1):\n        rt = 'axial'\n    if (x1,y1,x2,y2) == (0,1,0,0):\n        rt = 'sagittal'\n    \n    if rt == 'unkown':\n        raise ValueError(f'unkown ImageOrientationPatient: {dicom.ImageOrientationPatient}')\n        \n    return rt\n\ndef stats_image(image):\n    noncero_pixels = image[np.nonzero(image)]\n    if noncero_pixels.shape == (0,):\n        mean = 0\n        std = 0\n    else:\n        mean = np.mean(noncero_pixels)\n        std = np.std(noncero_pixels)\n    return (mean,std)\n\ndef calc_idx(image):\n    (mean,std) = stats_image(image)\n    non_cero_pixels = np.count_nonzero(image > level(mean,std))\n    return non_cero_pixels\n    \ndef top_brilliant_image(images):\n    idx = [calc_idx(image) for image in images]\n    top_image = np.argsort(idx)[::-1][0]\n    return top_image\n\ndef top_brilliant_line(image, axis):\n    (mean,std) = stats_image(image)\n    non_cero_pixels = np.count_nonzero(image > level(mean,std),  axis=axis)\n    top_line = np.argsort(non_cero_pixels)[::-1][0]\n    return top_line\n\ndef normalize_image(image):\n    (mean,std) = stats_image(image)\n    image = (image - mean) / std\n    return image\n\ndef cropped_image(image):\n    noncero_pixels = image[np.nonzero(image)]\n    if noncero_pixels.shape == (0,):\n        return image\n    min=np.array(np.nonzero(image)).min(axis=1)\n    max=np.array(np.nonzero(image)).max(axis=1)\n    return image[min[0]:max[0],min[1]:max[1]]\n\ndef cropped_images(images):\n    min=np.array(np.nonzero(images)).min(axis=1)\n    max=np.array(np.nonzero(images)).max(axis=1)\n    return images[min[0]:max[0],min[1]:max[1],min[2]:max[2]]\n\ndef calc_center(dicom_file, r, c):\n    orientation = image_orientation(dicom_file)\n    if orientation == 'coronal':\n        center = [dicom_file.ImagePositionPatient[0] + dicom_file.PixelSpacing[0] * c,\n                  dicom_file.ImagePositionPatient[1],\n                  dicom_file.ImagePositionPatient[2] - dicom_file.PixelSpacing[1] * r]\n\n    if orientation == 'sagittal':\n        center = [dicom_file.ImagePositionPatient[0],\n                  dicom_file.ImagePositionPatient[1] + dicom_file.PixelSpacing[0] * c,\n                  dicom_file.ImagePositionPatient[2] - dicom_file.PixelSpacing[1] * r]\n        \n    if orientation == 'axial':\n        center = [dicom_file.ImagePositionPatient[0] + dicom_file.PixelSpacing[0] * c,\n                  dicom_file.ImagePositionPatient[1] + dicom_file.PixelSpacing[0] * r,\n                  dicom_file.ImagePositionPatient[2]]\n\n    return center\n\ndef find_nearest_scan(dicom_files, center):\n    axis_move = {'sagittal': 0, 'coronal': 1, 'axial': 2}\n    orientation = image_orientation(dicom_files[0])\n    a = np.array([f.ImagePositionPatient for f in dicom_files])\n    scan = np.argsort(np.abs(a - center),axis=0)[0][axis_move[orientation]]\n    return scan\n\ndef plot_image_hist(image):\n    pixels = image.ravel()\n    noncero_pixels = pixels[np.nonzero(pixels)]\n    (mean,std) = stats_image(noncero_pixels)\n    noncero_pixels = (noncero_pixels - mean) / std\n    (mean,std) = stats_image(noncero_pixels)\n    over_threshold = np.count_nonzero(noncero_pixels > level(mean, std))\n\n    fig, (axi, axh) = plt.subplots(1, 2, figsize = (20,3), gridspec_kw={'width_ratios': [1, 4]})\n    fig.suptitle(f'scan # ({over_threshold})')\n\n    axh.hist(noncero_pixels, 200)\n    axh.set_xlim(-5,5)\n\n    ax_limits = axh.get_ylim()\n    axh.vlines(mean, ymin=ax_limits[0], ymax=ax_limits[1], colors='b')\n    axh.vlines(mean+std, ymin=ax_limits[0], ymax=ax_limits[1], colors='b', linestyles='dotted')\n    axh.vlines(level(mean, std), ymin=ax_limits[0], ymax=ax_limits[1], colors='b', linestyles='dashed')\n    axi.imshow(image, cmap = plt.cm.gray)\n    axi.grid(False)\n    axi.axis('off')\n    plt.show()\n\n","metadata":{"execution":{"iopub.status.busy":"2021-08-08T17:25:37.925382Z","iopub.execute_input":"2021-08-08T17:25:37.925742Z","iopub.status.idle":"2021-08-08T17:25:37.956810Z","shell.execute_reply.started":"2021-08-08T17:25:37.925710Z","shell.execute_reply":"2021-08-08T17:25:37.955946Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Example DICOM File","metadata":{}},{"cell_type":"code","source":"cohort = 'train'\ncase = '00386'\n\nflair_dicom_files = read_dicom_files(cohort, case, 'FLAIR')\nt1w_dicom_files = read_dicom_files(cohort, case, 'T1w')\nt1wce_dicom_files = read_dicom_files(cohort, case, 'T1wCE')\nt2w_dicom_files = read_dicom_files(cohort, case, 'T2w')","metadata":{"execution":{"iopub.status.busy":"2021-08-08T16:38:43.793592Z","iopub.execute_input":"2021-08-08T16:38:43.793953Z","iopub.status.idle":"2021-08-08T16:38:47.585831Z","shell.execute_reply.started":"2021-08-08T16:38:43.793920Z","shell.execute_reply":"2021-08-08T16:38:47.585094Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Basic Information","metadata":{}},{"cell_type":"code","source":"flair_orientation = image_orientation(flair_dicom_files[0])\nflair_nscans = len(flair_dicom_files)\nt1w_orientation = image_orientation(t1w_dicom_files[0])\nt1w_nscans = len(t1w_dicom_files)\nt1wce_orientation = image_orientation(t1wce_dicom_files[0])\nt1wce_nscans = len(t1wce_dicom_files)\nt2w_orientation = image_orientation(t2w_dicom_files[0])\nt2w_nscans = len(t2w_dicom_files)\n\nprint(f\"FLAIR: {flair_orientation}, {flair_nscans} scans\")\nprint(f\"T1w: {t1w_orientation}, {t1w_nscans} scans\")\nprint(f\"T1wce: {t1wce_orientation}, {t1wce_nscans} scans\")\nprint(f\"T2w: {t2w_orientation}, {t2w_nscans} scans\")","metadata":{"execution":{"iopub.status.busy":"2021-08-08T16:46:40.821425Z","iopub.execute_input":"2021-08-08T16:46:40.822869Z","iopub.status.idle":"2021-08-08T16:46:40.837687Z","shell.execute_reply.started":"2021-08-08T16:46:40.822798Z","shell.execute_reply":"2021-08-08T16:46:40.836463Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# test: all dicom files must be of the same patient\nassert flair_dicom_files[0].PatientID == t1w_dicom_files[0].PatientID\nassert flair_dicom_files[0].PatientID == t1wce_dicom_files[0].PatientID\nassert flair_dicom_files[0].PatientID == t2w_dicom_files[0].PatientID","metadata":{"execution":{"iopub.status.busy":"2021-08-08T16:38:47.596474Z","iopub.execute_input":"2021-08-08T16:38:47.596758Z","iopub.status.idle":"2021-08-08T16:38:47.605672Z","shell.execute_reply.started":"2021-08-08T16:38:47.596730Z","shell.execute_reply":"2021-08-08T16:38:47.604809Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Images","metadata":{}},{"cell_type":"code","source":"flair_images = cropped_images(np.array([s.pixel_array for s in flair_dicom_files]))\nt1wce_images = cropped_images(np.array([s.pixel_array for s in t1wce_dicom_files]))\nt1w_images = cropped_images(np.array([s.pixel_array for s in t1w_dicom_files]))\nt2w_images = cropped_images(np.array([s.pixel_array for s in t2w_dicom_files]))","metadata":{"execution":{"iopub.status.busy":"2021-08-08T16:47:19.404328Z","iopub.execute_input":"2021-08-08T16:47:19.404723Z","iopub.status.idle":"2021-08-08T16:47:21.310013Z","shell.execute_reply.started":"2021-08-08T16:47:19.404685Z","shell.execute_reply":"2021-08-08T16:47:21.308643Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.express as px\n\nfig = px.imshow(flair_images, animation_frame=0, binary_string=True, labels=dict(x=\"FLAIR Images\",animation_frame=\"scan\"), height=800)\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-08-08T16:38:50.108478Z","iopub.execute_input":"2021-08-08T16:38:50.109055Z","iopub.status.idle":"2021-08-08T16:38:53.139154Z","shell.execute_reply.started":"2021-08-08T16:38:50.108998Z","shell.execute_reply":"2021-08-08T16:38:53.138204Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.imshow(t1w_images, animation_frame=0, binary_string=True, labels=dict(x=\"T1w Images\",animation_frame=\"scan\"), height=800)\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-08-08T16:38:53.142242Z","iopub.execute_input":"2021-08-08T16:38:53.142768Z","iopub.status.idle":"2021-08-08T16:38:54.568462Z","shell.execute_reply.started":"2021-08-08T16:38:53.142726Z","shell.execute_reply":"2021-08-08T16:38:54.567492Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.imshow(t1wce_images, animation_frame=0, binary_string=True, labels=dict(x=\"T1wCE Images\",animation_frame=\"scan\"), height=800)\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-08-08T16:38:54.570199Z","iopub.execute_input":"2021-08-08T16:38:54.570660Z","iopub.status.idle":"2021-08-08T16:38:55.760001Z","shell.execute_reply.started":"2021-08-08T16:38:54.570626Z","shell.execute_reply":"2021-08-08T16:38:55.759202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.imshow(t2w_images, animation_frame=0, binary_string=True, labels=dict(x=\"T2w Images\",animation_frame=\"scan\"), height=800)\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-08-08T16:38:55.761308Z","iopub.execute_input":"2021-08-08T16:38:55.761685Z","iopub.status.idle":"2021-08-08T16:38:55.933493Z","shell.execute_reply.started":"2021-08-08T16:38:55.761639Z","shell.execute_reply":"2021-08-08T16:38:55.932279Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### FLAIR Images (Histogram)","metadata":{"execution":{"iopub.status.busy":"2021-08-06T20:09:16.368509Z","iopub.execute_input":"2021-08-06T20:09:16.368863Z","iopub.status.idle":"2021-08-06T20:09:16.373611Z","shell.execute_reply.started":"2021-08-06T20:09:16.368832Z","shell.execute_reply":"2021-08-06T20:09:16.372098Z"}}},{"cell_type":"code","source":"for img in flair_images:\n    plot_image_hist(img)","metadata":{"execution":{"iopub.status.busy":"2021-08-08T16:55:56.870433Z","iopub.execute_input":"2021-08-08T16:55:56.870775Z","iopub.status.idle":"2021-08-08T16:56:27.221293Z","shell.execute_reply.started":"2021-08-08T16:55:56.870745Z","shell.execute_reply":"2021-08-08T16:56:27.220569Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Hypothesis","metadata":{}},{"cell_type":"markdown","source":"Tumor is seeing like a brilliant zone in FLAIR images","metadata":{}},{"cell_type":"markdown","source":"### Top brilliant Image in FLAIR serie","metadata":{}},{"cell_type":"code","source":"flair_images = np.array([s.pixel_array for s in flair_dicom_files])\n\ntop = top_brilliant_image(flair_images)\ntop","metadata":{"execution":{"iopub.status.busy":"2021-08-08T17:02:00.807755Z","iopub.execute_input":"2021-08-08T17:02:00.808151Z","iopub.status.idle":"2021-08-08T17:02:00.947834Z","shell.execute_reply.started":"2021-08-08T17:02:00.808119Z","shell.execute_reply":"2021-08-08T17:02:00.946790Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from pydicom.pixel_data_handlers.util import apply_voi_lut\n\nfig, (ax1, ax2) = plt.subplots(1, 2, figsize = (20,10))\nfig.suptitle('normalized image vs VOI LUT image')\n\nimage = flair_images[top]\nax1.imshow(image, cmap = plt.cm.gray)\n\nim = apply_voi_lut(flair_dicom_files[top].pixel_array, flair_dicom_files[top])\nax2.imshow(im, cmap = plt.cm.gray)\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-08-08T17:02:04.414901Z","iopub.execute_input":"2021-08-08T17:02:04.415285Z","iopub.status.idle":"2021-08-08T17:02:04.880241Z","shell.execute_reply.started":"2021-08-08T17:02:04.415253Z","shell.execute_reply":"2021-08-08T17:02:04.879210Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Center of brilliant image ","metadata":{}},{"cell_type":"code","source":"(top,flair_dicom_files[top].ImagePositionPatient)","metadata":{"execution":{"iopub.status.busy":"2021-08-08T17:02:17.770347Z","iopub.execute_input":"2021-08-08T17:02:17.770739Z","iopub.status.idle":"2021-08-08T17:02:17.778864Z","shell.execute_reply.started":"2021-08-08T17:02:17.770705Z","shell.execute_reply":"2021-08-08T17:02:17.778069Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rtop = top_brilliant_line(flair_images[top], axis=1)\nctop = top_brilliant_line(flair_images[top], axis=0)\n\n(rtop,ctop)","metadata":{"execution":{"iopub.status.busy":"2021-08-08T17:02:20.673531Z","iopub.execute_input":"2021-08-08T17:02:20.674113Z","iopub.status.idle":"2021-08-08T17:02:20.688201Z","shell.execute_reply.started":"2021-08-08T17:02:20.674076Z","shell.execute_reply":"2021-08-08T17:02:20.687190Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"center = calc_center(flair_dicom_files[top], rtop, ctop)\ncenter","metadata":{"execution":{"iopub.status.busy":"2021-08-08T17:02:25.570707Z","iopub.execute_input":"2021-08-08T17:02:25.571320Z","iopub.status.idle":"2021-08-08T17:02:25.577540Z","shell.execute_reply.started":"2021-08-08T17:02:25.571280Z","shell.execute_reply":"2021-08-08T17:02:25.576500Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Equivalent scan in other series","metadata":{}},{"cell_type":"code","source":"scan_t1wce = find_nearest_scan(t1wce_dicom_files, center)\n(t1wce_orientation, scan_t1wce, t1wce_dicom_files[scan_t1wce].ImagePositionPatient)","metadata":{"execution":{"iopub.status.busy":"2021-08-08T17:02:28.500617Z","iopub.execute_input":"2021-08-08T17:02:28.501130Z","iopub.status.idle":"2021-08-08T17:02:28.511265Z","shell.execute_reply.started":"2021-08-08T17:02:28.501095Z","shell.execute_reply":"2021-08-08T17:02:28.510219Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"scan_t1w = find_nearest_scan(t1w_dicom_files, center)\n(t1w_orientation, scan_t1w, t1w_dicom_files[scan_t1w].ImagePositionPatient)","metadata":{"execution":{"iopub.status.busy":"2021-08-08T17:02:31.533952Z","iopub.execute_input":"2021-08-08T17:02:31.534326Z","iopub.status.idle":"2021-08-08T17:02:31.544939Z","shell.execute_reply.started":"2021-08-08T17:02:31.534276Z","shell.execute_reply":"2021-08-08T17:02:31.543906Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"scan_t2w = find_nearest_scan(t2w_dicom_files, center)\n(t2w_orientation, scan_t2w, t2w_dicom_files[scan_t2w].ImagePositionPatient)","metadata":{"execution":{"iopub.status.busy":"2021-08-08T17:02:33.830644Z","iopub.execute_input":"2021-08-08T17:02:33.831059Z","iopub.status.idle":"2021-08-08T17:02:33.839226Z","shell.execute_reply.started":"2021-08-08T17:02:33.831016Z","shell.execute_reply":"2021-08-08T17:02:33.838216Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ((ax1,ax2),(ax3,ax4)) = plt.subplots(2, 2, figsize = (20,20))\nfig.suptitle('images')\n\nim = normalize_image(cropped_image(flair_dicom_files[top].pixel_array))\nax1.imshow(im, cmap = plt.cm.gray)\nax1.set_title(f'FLAIR #scan {top}')\n\nim = normalize_image(cropped_image(t1w_dicom_files[scan_t1w].pixel_array))\nax2.imshow(im, cmap = plt.cm.gray)\nax2.set_title(f'T1w #scan {scan_t1w}')\n\nim = normalize_image(cropped_image(t1wce_dicom_files[scan_t1wce].pixel_array))\nax3.imshow(im, cmap = plt.cm.gray)\nax3.set_title(f'T1wCE #scan {scan_t1wce}')\n\nim = normalize_image(cropped_image(t2w_dicom_files[scan_t2w].pixel_array))\nax4.imshow(im, cmap = plt.cm.gray)\nax4.set_title(f'T2w #scan {scan_t2w}')\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-08-08T17:02:43.972728Z","iopub.execute_input":"2021-08-08T17:02:43.973461Z","iopub.status.idle":"2021-08-08T17:02:45.060701Z","shell.execute_reply.started":"2021-08-08T17:02:43.973412Z","shell.execute_reply":"2021-08-08T17:02:45.059745Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Test: train cohort","metadata":{}},{"cell_type":"code","source":"def process_case_and_plot(cohort, case):\n    flair_dicom_files = read_dicom_files(cohort, case, 'FLAIR')\n    t1w_dicom_files = read_dicom_files(cohort, case, 'T1w')\n    t1wce_dicom_files = read_dicom_files(cohort, case, 'T1wCE')\n    t2w_dicom_files = read_dicom_files(cohort, case, 'T2w')\n    \n    flair_images = np.array([s.pixel_array for s in flair_dicom_files])\n    \n    top = top_brilliant_image(flair_images)\n    rtop = top_brilliant_line(flair_images[top], axis=1)\n    ctop = top_brilliant_line(flair_images[top], axis=0)\n\n    center = calc_center(flair_dicom_files[top], rtop, ctop)\n        \n    scan_t1w = find_nearest_scan(t1w_dicom_files, center)\n    scan_t1wce = find_nearest_scan(t1wce_dicom_files, center)\n    scan_t2w = find_nearest_scan(t2w_dicom_files, center)\n\n    flair_image = normalize_image(cropped_image(flair_dicom_files[top].pixel_array))\n    t1w_image = normalize_image(cropped_image(t1w_dicom_files[scan_t1w].pixel_array))\n    t1wce_image = normalize_image(cropped_image(t1wce_dicom_files[scan_t1wce].pixel_array))\n    t2w_image = normalize_image(cropped_image(t2w_dicom_files[scan_t2w].pixel_array))\n\n    fig, (ax1,ax2,ax3,ax4) = plt.subplots(1, 4, figsize = (20,5))\n    fig.suptitle(f'Case {case}')\n    \n    ax1.imshow(flair_image, cmap = plt.cm.gray)\n    ax1.set_title(f'FLAIR #scan {top}')\n    ax1.grid(False)\n\n    ax2.imshow(t1w_image, cmap = plt.cm.gray)\n    ax2.set_title(f'T1w #scan {scan_t1w}')\n    ax2.grid(False)\n    \n    ax3.imshow(t1wce_image, cmap = plt.cm.gray)\n    ax3.set_title(f'T1wCE #scan {scan_t1wce}')\n    ax3.grid(False)\n\n    ax4.imshow(t2w_image, cmap = plt.cm.gray)\n    ax4.set_title(f'T2w #scan {scan_t2w}')\n    ax4.grid(False)\n\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2021-08-08T17:03:23.757772Z","iopub.execute_input":"2021-08-08T17:03:23.758112Z","iopub.status.idle":"2021-08-08T17:03:23.771090Z","shell.execute_reply.started":"2021-08-08T17:03:23.758082Z","shell.execute_reply":"2021-08-08T17:03:23.770204Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv('../input/rsna-miccai-brain-tumor-radiogenomic-classification/train_labels.csv', converters = {'BraTS21ID': str,})","metadata":{"execution":{"iopub.status.busy":"2021-08-08T17:03:27.927332Z","iopub.execute_input":"2021-08-08T17:03:27.927691Z","iopub.status.idle":"2021-08-08T17:03:27.942770Z","shell.execute_reply.started":"2021-08-08T17:03:27.927659Z","shell.execute_reply":"2021-08-08T17:03:27.941765Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cohort = 'train'\nfor case in train.sample(10).BraTS21ID:\n    process_case_and_plot(cohort, case)","metadata":{"execution":{"iopub.status.busy":"2021-08-08T17:26:00.453274Z","iopub.execute_input":"2021-08-08T17:26:00.453778Z","iopub.status.idle":"2021-08-08T17:26:56.500595Z","shell.execute_reply.started":"2021-08-08T17:26:00.453744Z","shell.execute_reply":"2021-08-08T17:26:56.499552Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Test: test cohort","metadata":{}},{"cell_type":"code","source":"test = pd.read_csv('../input/rsna-miccai-brain-tumor-radiogenomic-classification/sample_submission.csv', converters = {'BraTS21ID': str,})","metadata":{"execution":{"iopub.status.busy":"2021-08-08T17:04:26.511030Z","iopub.execute_input":"2021-08-08T17:04:26.511434Z","iopub.status.idle":"2021-08-08T17:04:26.522854Z","shell.execute_reply.started":"2021-08-08T17:04:26.511394Z","shell.execute_reply":"2021-08-08T17:04:26.521728Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cohort = 'test'\nfor case in test.sample(10).BraTS21ID:\n    process_case_and_plot(cohort, case)","metadata":{"execution":{"iopub.status.busy":"2021-08-08T17:39:26.633810Z","iopub.execute_input":"2021-08-08T17:39:26.634232Z","iopub.status.idle":"2021-08-08T17:39:57.239651Z","shell.execute_reply.started":"2021-08-08T17:39:26.634196Z","shell.execute_reply":"2021-08-08T17:39:57.238597Z"},"trusted":true},"execution_count":null,"outputs":[]}]}