{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":71549,"databundleVersionId":8561470,"sourceType":"competition"}],"dockerImageVersionId":30698,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"## Table of Contents\n* [Data Preparation](#data_prep)\n  * Main Table\n  * Labels\n  * Descriptions\n  * [Dcm Metadata](#dcm_meta)\n","metadata":{}},{"cell_type":"code","source":"# packages\n\n# standard\nimport numpy as np\nimport pandas as pd\nimport os\nimport time\nimport tqdm\n\n# plots\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as patches\nimport plotly.express as px\nimport seaborn as sns\n\n# dicom\nimport pydicom as dicom","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-06-06T14:21:00.725864Z","iopub.execute_input":"2024-06-06T14:21:00.726720Z","iopub.status.idle":"2024-06-06T14:21:03.663118Z","shell.execute_reply.started":"2024-06-06T14:21:00.726676Z","shell.execute_reply":"2024-06-06T14:21:03.662134Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# warning handling\nimport warnings\nwarnings.filterwarnings('ignore')","metadata":{"execution":{"iopub.status.busy":"2024-06-06T14:21:07.509312Z","iopub.execute_input":"2024-06-06T14:21:07.510336Z","iopub.status.idle":"2024-06-06T14:21:07.514722Z","shell.execute_reply.started":"2024-06-06T14:21:07.510299Z","shell.execute_reply":"2024-06-06T14:21:07.513662Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# show files\n!ls -l '../input/rsna-2024-lumbar-spine-degenerative-classification'","metadata":{"execution":{"iopub.status.busy":"2024-06-06T14:21:10.164423Z","iopub.execute_input":"2024-06-06T14:21:10.164874Z","iopub.status.idle":"2024-06-06T14:21:11.193232Z","shell.execute_reply.started":"2024-06-06T14:21:10.164843Z","shell.execute_reply":"2024-06-06T14:21:11.192076Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# configs\ndefault_color_1 = 'darkblue'","metadata":{"execution":{"iopub.status.busy":"2024-06-06T14:21:16.523289Z","iopub.execute_input":"2024-06-06T14:21:16.524122Z","iopub.status.idle":"2024-06-06T14:21:16.528594Z","shell.execute_reply.started":"2024-06-06T14:21:16.524085Z","shell.execute_reply":"2024-06-06T14:21:16.527585Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# read data\ndf_train_main = pd.read_csv('../input/rsna-2024-lumbar-spine-degenerative-classification/train.csv')\ndf_train_label = pd.read_csv('../input/rsna-2024-lumbar-spine-degenerative-classification/train_label_coordinates.csv')\ndf_train_desc = pd.read_csv('../input/rsna-2024-lumbar-spine-degenerative-classification/train_series_descriptions.csv')\ndf_test_desc = pd.read_csv('../input/rsna-2024-lumbar-spine-degenerative-classification/test_series_descriptions.csv')\ndf_sub = pd.read_csv('../input/rsna-2024-lumbar-spine-degenerative-classification/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2024-06-06T14:21:20.076346Z","iopub.execute_input":"2024-06-06T14:21:20.076757Z","iopub.status.idle":"2024-06-06T14:21:20.261462Z","shell.execute_reply.started":"2024-06-06T14:21:20.076725Z","shell.execute_reply":"2024-06-06T14:21:20.260510Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id='data_prep'></a>\n# Data Preparation","metadata":{}},{"cell_type":"markdown","source":"### Main Table","metadata":{}},{"cell_type":"code","source":"# preview\ndf_train_main.head()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T14:21:47.505937Z","iopub.execute_input":"2024-06-06T14:21:47.506315Z","iopub.status.idle":"2024-06-06T14:21:47.535965Z","shell.execute_reply.started":"2024-06-06T14:21:47.506286Z","shell.execute_reply":"2024-06-06T14:21:47.535008Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Labels","metadata":{}},{"cell_type":"code","source":"# preview\ndf_train_label.head()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T14:22:02.504250Z","iopub.execute_input":"2024-06-06T14:22:02.504646Z","iopub.status.idle":"2024-06-06T14:22:02.521082Z","shell.execute_reply.started":"2024-06-06T14:22:02.504615Z","shell.execute_reply":"2024-06-06T14:22:02.519840Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Descriptions","metadata":{}},{"cell_type":"code","source":"# preview\ndf_train_desc.head()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T14:22:28.393345Z","iopub.execute_input":"2024-06-06T14:22:28.394267Z","iopub.status.idle":"2024-06-06T14:22:28.403439Z","shell.execute_reply.started":"2024-06-06T14:22:28.394233Z","shell.execute_reply":"2024-06-06T14:22:28.402468Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Combine Tables","metadata":{}},{"cell_type":"code","source":"# join first two tables\ndf_train_step_1 = pd.merge(left=df_train_label, right=df_train_main, how='left', on='study_id').reset_index(drop=True)\ndf_train_step_1.head()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T14:22:48.616322Z","iopub.execute_input":"2024-06-06T14:22:48.616726Z","iopub.status.idle":"2024-06-06T14:22:48.746317Z","shell.execute_reply.started":"2024-06-06T14:22:48.616695Z","shell.execute_reply":"2024-06-06T14:22:48.745305Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# join with third table\ndf_train = pd.merge(left=df_train_step_1, right=df_train_desc, how='left', on=['study_id', 'series_id']).reset_index(drop=True)\ndf_train.head()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T14:22:51.572342Z","iopub.execute_input":"2024-06-06T14:22:51.572746Z","iopub.status.idle":"2024-06-06T14:22:51.681362Z","shell.execute_reply.started":"2024-06-06T14:22:51.572714Z","shell.execute_reply":"2024-06-06T14:22:51.680181Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# convert ids to categorical\ndf_train.study_id = df_train.study_id.astype('category')\ndf_train.series_id = df_train.series_id.astype('category')","metadata":{"execution":{"iopub.status.busy":"2024-06-06T14:22:56.133842Z","iopub.execute_input":"2024-06-06T14:22:56.134518Z","iopub.status.idle":"2024-06-06T14:22:56.143494Z","shell.execute_reply.started":"2024-06-06T14:22:56.134481Z","shell.execute_reply":"2024-06-06T14:22:56.142368Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.info()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T14:22:59.488677Z","iopub.execute_input":"2024-06-06T14:22:59.489525Z","iopub.status.idle":"2024-06-06T14:22:59.566319Z","shell.execute_reply.started":"2024-06-06T14:22:59.489485Z","shell.execute_reply":"2024-06-06T14:22:59.565359Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id='dcm_meta'></a>\n### Dcm Metadata","metadata":{}},{"cell_type":"code","source":"tmp_ds = dicom.dcmread('../input/rsna-2024-lumbar-spine-degenerative-classification/train_images/4646740/3666319702/12.dcm')\nprint(tmp_ds)\nprint(tmp_ds.dir())","metadata":{"execution":{"iopub.status.busy":"2024-06-06T14:23:50.509379Z","iopub.execute_input":"2024-06-06T14:23:50.509795Z","iopub.status.idle":"2024-06-06T14:23:50.529497Z","shell.execute_reply.started":"2024-06-06T14:23:50.509765Z","shell.execute_reply":"2024-06-06T14:23:50.528322Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### read 'image position patient' in Dcm metadata of all image files","metadata":{}},{"cell_type":"code","source":"df_train_dcm_meta = pd.DataFrame(columns=['study_id', 'series_id', 'instance_number', 'img_pos_x', 'img_pos_y', 'img_pos_z'])\ndf_train_dcm_meta['study_id'] = df_train_dcm_meta['study_id'].astype(int)\ndf_train_dcm_meta['series_id'] = df_train_dcm_meta['series_id'].astype(int)\ndf_train_dcm_meta['instance_number'] = df_train_dcm_meta['instance_number'].astype(int)\ndf_train_dcm_meta['img_pos_x'] = df_train_dcm_meta['img_pos_x'].astype(float)\ndf_train_dcm_meta['img_pos_y'] = df_train_dcm_meta['img_pos_y'].astype(float)\ndf_train_dcm_meta['img_pos_z'] = df_train_dcm_meta['img_pos_z'].astype(float)\ndf_train_dcm_meta.info()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T15:36:25.368022Z","iopub.execute_input":"2024-06-06T15:36:25.368402Z","iopub.status.idle":"2024-06-06T15:36:25.385090Z","shell.execute_reply.started":"2024-06-06T15:36:25.368373Z","shell.execute_reply":"2024-06-06T15:36:25.383672Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def get_dcm_meta(file_path):\n    ds = dicom.dcmread(file_path)\n    return ds.ImagePositionPatient\n\ndef min_max(x, axis=None):\n    min = x.min(axis=axis, keepdims=True)\n    max = x.max(axis=axis, keepdims=True)\n    result = (x-min)/(max-min)\n    return result\n\ntrain_image_path = '../input/rsna-2024-lumbar-spine-degenerative-classification/train_images/'\n\nfor study_id in tqdm.tqdm(df_train_main['study_id']):\n#for study_id in tqdm.tqdm([4646740]):\n    study_id_path = train_image_path + str(study_id) + '/'\n    \n    for dirname, _, filenames in os.walk(study_id_path):\n        if len(filenames) > 0:\n            series_id = int(dirname.split('/')[-1])\n            \n            positions = []\n            instance_numbers = []\n            for filename in filenames:\n                dcm_meta = get_dcm_meta(os.path.join(dirname, filename))\n                positions.append(dcm_meta)\n                instance_numbers.append(int(filename[:-4]))\n                \n            # normalization \n            positions = np.array(positions)\n            #print(positions)\n            positions = min_max(positions, axis=0)\n            np.nan_to_num(positions, nan=0.5, copy=False)\n            #print(positions)\n\n            for i, instance_number in enumerate(instance_numbers):\n                new_row = {'study_id':study_id, \n                           'series_id':series_id,\n                           'instance_number':instance_number,\n                           'img_pos_x':positions[i][0], \n                           'img_pos_y':positions[i][1], \n                           'img_pos_z':positions[i][2]}\n                df_train_dcm_meta.loc[len(df_train_dcm_meta)] = new_row                \n                ","metadata":{"execution":{"iopub.status.busy":"2024-06-06T15:36:28.378107Z","iopub.execute_input":"2024-06-06T15:36:28.378502Z","iopub.status.idle":"2024-06-06T15:59:54.678298Z","shell.execute_reply.started":"2024-06-06T15:36:28.378470Z","shell.execute_reply":"2024-06-06T15:59:54.676686Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_dcm_meta.info()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:03:05.544630Z","iopub.execute_input":"2024-06-06T16:03:05.545389Z","iopub.status.idle":"2024-06-06T16:03:05.568358Z","shell.execute_reply.started":"2024-06-06T16:03:05.545352Z","shell.execute_reply":"2024-06-06T16:03:05.567047Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_dcm_meta.head()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:03:08.665471Z","iopub.execute_input":"2024-06-06T16:03:08.666510Z","iopub.status.idle":"2024-06-06T16:03:08.680681Z","shell.execute_reply.started":"2024-06-06T16:03:08.666463Z","shell.execute_reply":"2024-06-06T16:03:08.679653Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# make image position patient table available for download\ndf_train_dcm_meta.to_csv('df_train_dcm_meta.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:03:13.055991Z","iopub.execute_input":"2024-06-06T16:03:13.056707Z","iopub.status.idle":"2024-06-06T16:03:13.929377Z","shell.execute_reply.started":"2024-06-06T16:03:13.056665Z","shell.execute_reply":"2024-06-06T16:03:13.928507Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### plot 'image position patient' of all images","metadata":{}},{"cell_type":"code","source":"df_train_dcm = pd.merge(left=df_train_dcm_meta, right=df_train_desc, how='left', on=['study_id', 'series_id']).reset_index(drop=True)","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:03:17.273154Z","iopub.execute_input":"2024-06-06T16:03:17.273820Z","iopub.status.idle":"2024-06-06T16:03:17.311759Z","shell.execute_reply.started":"2024-06-06T16:03:17.273787Z","shell.execute_reply":"2024-06-06T16:03:17.310714Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_dcm.info()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:03:19.529645Z","iopub.execute_input":"2024-06-06T16:03:19.530114Z","iopub.status.idle":"2024-06-06T16:03:19.548880Z","shell.execute_reply.started":"2024-06-06T16:03:19.530085Z","shell.execute_reply":"2024-06-06T16:03:19.547918Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_dcm.head()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:03:22.329460Z","iopub.execute_input":"2024-06-06T16:03:22.330125Z","iopub.status.idle":"2024-06-06T16:03:22.342417Z","shell.execute_reply.started":"2024-06-06T16:03:22.330092Z","shell.execute_reply":"2024-06-06T16:03:22.341332Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(6,2))\ncounts = df_train_dcm['series_description'].value_counts()\nprint(counts)\ncounts.plot(kind='bar')\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:03:24.983904Z","iopub.execute_input":"2024-06-06T16:03:24.984616Z","iopub.status.idle":"2024-06-06T16:03:25.192512Z","shell.execute_reply.started":"2024-06-06T16:03:24.984582Z","shell.execute_reply":"2024-06-06T16:03:25.191525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_dcm_AxialT2 = df_train_dcm[df_train_dcm.series_description=='Axial T2']\ndf_train_dcm_SagittalT1 = df_train_dcm[df_train_dcm.series_description=='Sagittal T1']\ndf_train_dcm_SagittalT2STIR = df_train_dcm[df_train_dcm.series_description=='Sagittal T2/STIR']","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:03:28.217409Z","iopub.execute_input":"2024-06-06T16:03:28.218329Z","iopub.status.idle":"2024-06-06T16:03:28.267667Z","shell.execute_reply.started":"2024-06-06T16:03:28.218295Z","shell.execute_reply":"2024-06-06T16:03:28.266599Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### plot 'image position patient' of labeled images","metadata":{}},{"cell_type":"code","source":"df_train_2 = pd.merge(left=df_train, right=df_train_dcm_meta, how='left', on=['study_id', 'series_id', 'instance_number']).reset_index(drop=True)","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:04:30.791536Z","iopub.execute_input":"2024-06-06T16:04:30.792481Z","iopub.status.idle":"2024-06-06T16:04:31.002317Z","shell.execute_reply.started":"2024-06-06T16:04:30.792422Z","shell.execute_reply":"2024-06-06T16:04:31.001434Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_2.info()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:04:33.521845Z","iopub.execute_input":"2024-06-06T16:04:33.522208Z","iopub.status.idle":"2024-06-06T16:04:33.599284Z","shell.execute_reply.started":"2024-06-06T16:04:33.522181Z","shell.execute_reply":"2024-06-06T16:04:33.598427Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_2.head()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:04:38.313415Z","iopub.execute_input":"2024-06-06T16:04:38.314213Z","iopub.status.idle":"2024-06-06T16:04:38.337612Z","shell.execute_reply.started":"2024-06-06T16:04:38.314175Z","shell.execute_reply":"2024-06-06T16:04:38.336592Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(6,2))\ncounts = df_train_2['series_description'].value_counts()\nprint(counts)\ncounts.plot(kind='bar')\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:04:41.125642Z","iopub.execute_input":"2024-06-06T16:04:41.126590Z","iopub.status.idle":"2024-06-06T16:04:41.271371Z","shell.execute_reply.started":"2024-06-06T16:04:41.126554Z","shell.execute_reply":"2024-06-06T16:04:41.270206Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_2_AxialT2 = df_train_2[df_train_2.series_description=='Axial T2']\ndf_train_2_SagittalT1 = df_train_2[df_train_2.series_description=='Sagittal T1']\ndf_train_2_SagittalT2STIR = df_train_2[df_train_2.series_description=='Sagittal T2/STIR']","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:04:44.257495Z","iopub.execute_input":"2024-06-06T16:04:44.257893Z","iopub.status.idle":"2024-06-06T16:04:44.318081Z","shell.execute_reply.started":"2024-06-06T16:04:44.257862Z","shell.execute_reply":"2024-06-06T16:04:44.317027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure()\nax = fig.add_subplot(projection='3d')\n\nfor index, row in tqdm.tqdm(df_train_2_AxialT2.iterrows()):\n    ax.scatter(row.img_pos_x, row.img_pos_y, row.img_pos_z,color=default_color_1, alpha=0.25)\n    if index > 3000:\n        break\n\nax.set_title('Axial T2 image position')\nax.set_xlabel('x')\nax.set_ylabel('y')\nax.set_zlabel('z')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:04:47.546249Z","iopub.execute_input":"2024-06-06T16:04:47.546660Z","iopub.status.idle":"2024-06-06T16:05:00.933467Z","shell.execute_reply.started":"2024-06-06T16:04:47.546628Z","shell.execute_reply":"2024-06-06T16:05:00.932403Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ax = sns.jointplot(data=df_train_2_AxialT2, x='img_pos_x', y='img_pos_z', \n                   hue='condition', alpha=0.25)\nplt.legend(bbox_to_anchor=(1.2,1), loc=2)\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:05:05.356352Z","iopub.execute_input":"2024-06-06T16:05:05.357094Z","iopub.status.idle":"2024-06-06T16:05:06.884426Z","shell.execute_reply.started":"2024-06-06T16:05:05.357059Z","shell.execute_reply":"2024-06-06T16:05:06.883477Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ax = sns.jointplot(data=df_train_2_AxialT2, x='img_pos_x', y='img_pos_z', \n                   hue='level', alpha=0.25)\nplt.legend(bbox_to_anchor=(1.2,1), loc=2)\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:05:12.803969Z","iopub.execute_input":"2024-06-06T16:05:12.804782Z","iopub.status.idle":"2024-06-06T16:05:14.419581Z","shell.execute_reply.started":"2024-06-06T16:05:12.804749Z","shell.execute_reply":"2024-06-06T16:05:14.418504Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure()\nax = fig.add_subplot(projection='3d')\n\nfor index, row in tqdm.tqdm(df_train_2_SagittalT1.iterrows()):\n    ax.scatter(row.img_pos_x, row.img_pos_y, row.img_pos_z,color=default_color_1, alpha=0.25)\n    if index > 3000:\n        break\n\nax.set_title('Sagittal T1 image position')\nax.set_xlabel('x')\nax.set_ylabel('y')\nax.set_zlabel('z')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:05:27.457397Z","iopub.execute_input":"2024-06-06T16:05:27.458354Z","iopub.status.idle":"2024-06-06T16:05:41.341674Z","shell.execute_reply.started":"2024-06-06T16:05:27.458317Z","shell.execute_reply":"2024-06-06T16:05:41.340669Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ax = sns.jointplot(data=df_train_2_SagittalT1, x='img_pos_x', y='img_pos_y', \n                   hue='condition', alpha=0.25)\nplt.legend(bbox_to_anchor=(1.2,1), loc=2)\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:05:48.620410Z","iopub.execute_input":"2024-06-06T16:05:48.621366Z","iopub.status.idle":"2024-06-06T16:05:50.121719Z","shell.execute_reply.started":"2024-06-06T16:05:48.621328Z","shell.execute_reply":"2024-06-06T16:05:50.120700Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ax = sns.jointplot(data=df_train_2_SagittalT1, x='img_pos_x', y='img_pos_y', \n                   hue='level', alpha=0.25)\nplt.legend(bbox_to_anchor=(1.2,1), loc=2)\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:06:01.019786Z","iopub.execute_input":"2024-06-06T16:06:01.020586Z","iopub.status.idle":"2024-06-06T16:06:02.580500Z","shell.execute_reply.started":"2024-06-06T16:06:01.020550Z","shell.execute_reply":"2024-06-06T16:06:02.579338Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure()\nax = fig.add_subplot(projection='3d')\n\nfor index, row in tqdm.tqdm(df_train_2_SagittalT2STIR.iterrows()):\n    ax.scatter(row.img_pos_x, row.img_pos_y, row.img_pos_z,color=default_color_1, alpha=0.25)\n    if index > 3000:\n        break\n\nax.set_title('Sagittal T2/STIR image position')\nax.set_xlabel('x')\nax.set_ylabel('y')\nax.set_zlabel('z')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:06:07.187509Z","iopub.execute_input":"2024-06-06T16:06:07.188406Z","iopub.status.idle":"2024-06-06T16:06:13.826487Z","shell.execute_reply.started":"2024-06-06T16:06:07.188369Z","shell.execute_reply":"2024-06-06T16:06:13.825321Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ax = sns.jointplot(data=df_train_2_SagittalT2STIR, x='img_pos_x', y='img_pos_y', \n                   hue='condition', alpha=0.25)\nplt.legend(bbox_to_anchor=(1.2,1), loc=2)\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:06:17.642230Z","iopub.execute_input":"2024-06-06T16:06:17.643289Z","iopub.status.idle":"2024-06-06T16:06:18.622735Z","shell.execute_reply.started":"2024-06-06T16:06:17.643249Z","shell.execute_reply":"2024-06-06T16:06:18.621740Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ax = sns.jointplot(data=df_train_2_SagittalT2STIR, x='img_pos_x', y='img_pos_y', \n                   hue='level', alpha=0.25)\nplt.legend(bbox_to_anchor=(1.2,1), loc=2)\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-06T16:06:26.830386Z","iopub.execute_input":"2024-06-06T16:06:26.831024Z","iopub.status.idle":"2024-06-06T16:06:28.049082Z","shell.execute_reply.started":"2024-06-06T16:06:26.830984Z","shell.execute_reply":"2024-06-06T16:06:28.048184Z"},"trusted":true},"execution_count":null,"outputs":[]}]}