{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","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":30775,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\n\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nimport os\n\nimport pydicom\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-10-14T08:47:46.848510Z","iopub.execute_input":"2024-10-14T08:47:46.849466Z","iopub.status.idle":"2024-10-14T08:47:46.855743Z","shell.execute_reply.started":"2024-10-14T08:47:46.849416Z","shell.execute_reply":"2024-10-14T08:47:46.854431Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv('/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/train.csv')\nlabel = pd.read_csv('/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/train_label_coordinates.csv')\ntest_desc = pd.read_csv('/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/test_series_descriptions.csv')\ntrain_desc = pd.read_csv('/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/train_series_descriptions.csv')\n\nsub = pd.read_csv('/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:47:47.603605Z","iopub.execute_input":"2024-10-14T08:47:47.604670Z","iopub.status.idle":"2024-10-14T08:47:47.790605Z","shell.execute_reply.started":"2024-10-14T08:47:47.604621Z","shell.execute_reply":"2024-10-14T08:47:47.789461Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:47:49.100494Z","iopub.execute_input":"2024-10-14T08:47:49.100916Z","iopub.status.idle":"2024-10-14T08:47:49.144050Z","shell.execute_reply.started":"2024-10-14T08:47:49.100875Z","shell.execute_reply":"2024-10-14T08:47:49.142919Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"label.head()","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:47:49.691986Z","iopub.execute_input":"2024-10-14T08:47:49.692409Z","iopub.status.idle":"2024-10-14T08:47:49.709469Z","shell.execute_reply.started":"2024-10-14T08:47:49.692369Z","shell.execute_reply":"2024-10-14T08:47:49.708344Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_desc.head()","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:47:49.981924Z","iopub.execute_input":"2024-10-14T08:47:49.982393Z","iopub.status.idle":"2024-10-14T08:47:49.994391Z","shell.execute_reply.started":"2024-10-14T08:47:49.982351Z","shell.execute_reply":"2024-10-14T08:47:49.993211Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_desc.head()","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:47:50.213527Z","iopub.execute_input":"2024-10-14T08:47:50.213989Z","iopub.status.idle":"2024-10-14T08:47:50.226039Z","shell.execute_reply.started":"2024-10-14T08:47:50.213920Z","shell.execute_reply":"2024-10-14T08:47:50.224827Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def generate_image_paths(df, data_dir):\n    image_paths = []\n    for study_id, series_id in zip(df['study_id'], df['series_id']):\n        study_dir = os.path.join(data_dir, str(study_id))\n        series_dir = os.path.join(study_dir, str(series_id))\n        images = os.listdir(series_dir)\n        image_paths.extend([os.path.join(series_dir, img) for img in images])\n    return image_paths\n\n# Generate image paths for train and test data\ntrain_image_paths = generate_image_paths(train_desc, '/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/train_images')\ntest_image_paths = generate_image_paths(test_desc, '/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/test_images')","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:47:50.424316Z","iopub.execute_input":"2024-10-14T08:47:50.424792Z","iopub.status.idle":"2024-10-14T08:48:50.694209Z","shell.execute_reply.started":"2024-10-14T08:47:50.424747Z","shell.execute_reply":"2024-10-14T08:48:50.692998Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(train_desc)","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:48:50.696495Z","iopub.execute_input":"2024-10-14T08:48:50.696908Z","iopub.status.idle":"2024-10-14T08:48:50.704695Z","shell.execute_reply.started":"2024-10-14T08:48:50.696864Z","shell.execute_reply":"2024-10-14T08:48:50.703575Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(train_image_paths)","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:48:50.706187Z","iopub.execute_input":"2024-10-14T08:48:50.707264Z","iopub.status.idle":"2024-10-14T08:48:50.721905Z","shell.execute_reply.started":"2024-10-14T08:48:50.707220Z","shell.execute_reply":"2024-10-14T08:48:50.720795Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Function to open and display DICOM images in a 3x3 matrix\ndef display_dicom_images(image_paths):\n    plt.figure(figsize=(15, 15))  # Adjust the figure size for a 3x3 grid\n    for i, path in enumerate(image_paths[:9]):  # Ensure you're displaying 9 images\n        ds = pydicom.dcmread(path)\n        plt.subplot(3, 3, i + 1)  # Create a 3x3 matrix (3 rows, 3 columns)\n        plt.imshow(ds.pixel_array, cmap=plt.cm.bone)\n        plt.title(f\"Image {i + 1}\")\n        plt.axis('off')\n    plt.tight_layout()  # Automatically adjust subplot parameters for a clean layout\n    plt.show()\n\n# Display the first nine DICOM images in a 3x3 matrix\ndisplay_dicom_images(train_image_paths)","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:48:50.724470Z","iopub.execute_input":"2024-10-14T08:48:50.724906Z","iopub.status.idle":"2024-10-14T08:48:53.524580Z","shell.execute_reply.started":"2024-10-14T08:48:50.724865Z","shell.execute_reply":"2024-10-14T08:48:53.523401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Function to display DICOM images in a more visually appealing way with coordinates\ndef display_dicom_with_coordinates(image_paths, label_df):\n    # Define a grid size based on the number of images (e.g., up to 9 in a 3x3 grid)\n    num_images = len(image_paths)\n    grid_size = int(np.ceil(np.sqrt(num_images)))\n    fig, axs = plt.subplots(grid_size, grid_size, figsize=(15, 15))  # Dynamically adjust the grid\n    axs = axs.ravel()  # Flatten the axis array for easy indexing\n    \n    # Loop through the image paths and display them with coordinates\n    for idx, path in enumerate(image_paths):\n        study_id = int(path.split('/')[-3])\n        series_id = int(path.split('/')[-2])\n        \n        # Filter the label coordinates for the current study and series\n        filtered_labels = label_df[(label_df['study_id'] == study_id) & (label_df['series_id'] == series_id)]\n        \n        # Read DICOM image\n        ds = pydicom.dcmread(path)\n        \n        # Plot DICOM image with enhanced contrast and a colormap\n        axs[idx].imshow(ds.pixel_array, cmap='bone', vmin=np.percentile(ds.pixel_array, 5), vmax=np.percentile(ds.pixel_array, 95))\n        axs[idx].set_title(f\"Study ID: {study_id}\\nSeries ID: {series_id}\", fontsize=10, fontweight='bold')\n        axs[idx].axis('off')  # Remove axes for a clean look\n        \n        # Plot coordinates on the image (e.g., with red circles and labels for clarity)\n        for _, row in filtered_labels.iterrows():\n            axs[idx].plot(row['x'], row['y'], 'ro', markersize=6)\n            axs[idx].text(row['x'] + 5, row['y'] + 5, f\"({row['x']}, {row['y']})\", color='red', fontsize=8)\n    \n    # Hide any unused subplots in the grid\n    for ax in axs[len(image_paths):]:\n        ax.axis('off')\n    \n    # Adjust layout to make it more visually pleasing\n    plt.tight_layout(pad=3.0)\n    plt.show()\n\n# Function to load DICOM files from a given folder\ndef load_dicom_files(path_to_folder):\n    files = [os.path.join(path_to_folder, f) for f in os.listdir(path_to_folder) if f.endswith('.dcm')]\n    files.sort(key=lambda x: int(os.path.splitext(os.path.basename(x))[0].split('-')[-1]))  # Sort by file name numbers\n    return files\n\n# Display DICOM images with coordinates\nstudy_id = \"1002894806\"\nstudy_folder = f'/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/train_images/{study_id}'\n\n# Gather DICOM file paths from the study folder\nimage_paths = []\nfor series_folder in os.listdir(study_folder):\n    series_folder_path = os.path.join(study_folder, series_folder)\n    dicom_files = load_dicom_files(series_folder_path)\n    if dicom_files:\n        image_paths.append(dicom_files[0])  # Add the first image from each series\n\n# Assuming 'label' is a DataFrame with coordinates (x, y), and study/series information\ndisplay_dicom_with_coordinates(image_paths, label)","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:50:03.044860Z","iopub.execute_input":"2024-10-14T08:50:03.045769Z","iopub.status.idle":"2024-10-14T08:50:04.746190Z","shell.execute_reply.started":"2024-10-14T08:50:03.045718Z","shell.execute_reply":"2024-10-14T08:50:04.744486Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Define function to reshape a single row of the DataFrame\ndef reshape_row(row):\n    data = {'study_id': [], 'condition': [], 'level': [], 'severity': []}\n    \n    for column, value in row.items():\n        if column not in ['study_id', 'series_id', 'instance_number', 'x', 'y', 'series_description']:\n            parts = column.split('_')\n            condition = ' '.join([word.capitalize() for word in parts[:-2]])\n            level = parts[-2].capitalize() + '/' + parts[-1].capitalize()\n            data['study_id'].append(row['study_id'])\n            data['condition'].append(condition)\n            data['level'].append(level)\n            data['severity'].append(value)\n    \n    return pd.DataFrame(data)\n\n# Reshape the DataFrame for all rows\nnew_train_df = pd.concat([reshape_row(row) for _, row in train.iterrows()], ignore_index=True)","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:50:04.749017Z","iopub.execute_input":"2024-10-14T08:50:04.749444Z","iopub.status.idle":"2024-10-14T08:50:06.405552Z","shell.execute_reply.started":"2024-10-14T08:50:04.749402Z","shell.execute_reply":"2024-10-14T08:50:06.404474Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_train_df.head()","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:50:55.021762Z","iopub.execute_input":"2024-10-14T08:50:55.022244Z","iopub.status.idle":"2024-10-14T08:50:55.036603Z","shell.execute_reply.started":"2024-10-14T08:50:55.022194Z","shell.execute_reply":"2024-10-14T08:50:55.035484Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Merge the dataframes on the common columns\nmerged_df = pd.merge(new_train_df, label, on=['study_id', 'condition', 'level'], how='inner')\n# Merge the dataframes on the common column 'series_id'\nfinal_merged_df = pd.merge(merged_df, train_desc, on='series_id', how='inner')","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:50:55.534805Z","iopub.execute_input":"2024-10-14T08:50:55.535688Z","iopub.status.idle":"2024-10-14T08:50:55.633051Z","shell.execute_reply.started":"2024-10-14T08:50:55.535640Z","shell.execute_reply":"2024-10-14T08:50:55.631770Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Merge the dataframes on the common column 'series_id'\nfinal_merged_df = pd.merge(merged_df, train_desc, on=['series_id','study_id'], how='inner')","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:50:56.095901Z","iopub.execute_input":"2024-10-14T08:50:56.096379Z","iopub.status.idle":"2024-10-14T08:50:56.119028Z","shell.execute_reply.started":"2024-10-14T08:50:56.096326Z","shell.execute_reply":"2024-10-14T08:50:56.117812Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_merged_df.head()","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:50:57.533835Z","iopub.execute_input":"2024-10-14T08:50:57.534377Z","iopub.status.idle":"2024-10-14T08:50:57.550560Z","shell.execute_reply.started":"2024-10-14T08:50:57.534331Z","shell.execute_reply":"2024-10-14T08:50:57.549232Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_merged_df[final_merged_df['study_id'] == 100206310].sort_values(['x','y'],ascending = True)","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:50:57.951778Z","iopub.execute_input":"2024-10-14T08:50:57.952691Z","iopub.status.idle":"2024-10-14T08:50:57.979029Z","shell.execute_reply.started":"2024-10-14T08:50:57.952646Z","shell.execute_reply":"2024-10-14T08:50:57.977496Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_merged_df[final_merged_df['series_id'] == 1012284084].sort_values(\"instance_number\")","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:50:58.401866Z","iopub.execute_input":"2024-10-14T08:50:58.403149Z","iopub.status.idle":"2024-10-14T08:50:58.422540Z","shell.execute_reply.started":"2024-10-14T08:50:58.403099Z","shell.execute_reply":"2024-10-14T08:50:58.421403Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Filter the dataframe for the given study_id and sort by instance_number\nfiltered_df = final_merged_df[final_merged_df['study_id'] == 1013589491].sort_values(\"instance_number\")\n\n# Display the resulting dataframe\nfiltered_df","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:50:58.948790Z","iopub.execute_input":"2024-10-14T08:50:58.949282Z","iopub.status.idle":"2024-10-14T08:50:58.975052Z","shell.execute_reply.started":"2024-10-14T08:50:58.949235Z","shell.execute_reply":"2024-10-14T08:50:58.973754Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Sort final_merged_df by study_id, series_id, and series_description\nsorted_final_merged_df = final_merged_df[final_merged_df['study_id'] == 1013589491].sort_values(by=['series_id', 'series_description', 'instance_number'])\nsorted_final_merged_df","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:50:59.575713Z","iopub.execute_input":"2024-10-14T08:50:59.576140Z","iopub.status.idle":"2024-10-14T08:50:59.603650Z","shell.execute_reply.started":"2024-10-14T08:50:59.576100Z","shell.execute_reply":"2024-10-14T08:50:59.602433Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Create the row_id column\nfinal_merged_df['row_id'] = (\n    final_merged_df['study_id'].astype(str) + '_' +\n    final_merged_df['condition'].str.lower().str.replace(' ', '_') + '_' +\n    final_merged_df['level'].str.lower().str.replace('/', '_')\n)","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:51:00.135112Z","iopub.execute_input":"2024-10-14T08:51:00.135869Z","iopub.status.idle":"2024-10-14T08:51:00.287071Z","shell.execute_reply.started":"2024-10-14T08:51:00.135818Z","shell.execute_reply":"2024-10-14T08:51:00.286027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Create the image_path column\nfinal_merged_df['/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification'] = (\n    '/train_images/' + \n    final_merged_df['study_id'].astype(str) + '/' +\n    final_merged_df['series_id'].astype(str) + '/' +\n    final_merged_df['instance_number'].astype(str) + '.dcm'\n)","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:51:42.246700Z","iopub.execute_input":"2024-10-14T08:51:42.247165Z","iopub.status.idle":"2024-10-14T08:51:42.375187Z","shell.execute_reply.started":"2024-10-14T08:51:42.247122Z","shell.execute_reply":"2024-10-14T08:51:42.374247Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_merged_df.head()","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:51:43.715627Z","iopub.execute_input":"2024-10-14T08:51:43.716082Z","iopub.status.idle":"2024-10-14T08:51:43.733581Z","shell.execute_reply.started":"2024-10-14T08:51:43.716038Z","shell.execute_reply":"2024-10-14T08:51:43.732314Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_merged_df[final_merged_df[\"severity\"] == \"Normal/Mild\"].value_counts().sum()","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:51:44.547026Z","iopub.execute_input":"2024-10-14T08:51:44.547485Z","iopub.status.idle":"2024-10-14T08:51:44.726635Z","shell.execute_reply.started":"2024-10-14T08:51:44.547440Z","shell.execute_reply":"2024-10-14T08:51:44.725352Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_merged_df[final_merged_df[\"severity\"] == \"Moderate\"].value_counts().sum()","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:51:45.402725Z","iopub.execute_input":"2024-10-14T08:51:45.404155Z","iopub.status.idle":"2024-10-14T08:51:45.463328Z","shell.execute_reply.started":"2024-10-14T08:51:45.404085Z","shell.execute_reply":"2024-10-14T08:51:45.462058Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Define the base path for test images\nbase_path = '/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/test_images/'\n\n# Function to get image paths for a series\ndef get_image_paths(row):\n    series_path = os.path.join(base_path, str(row['study_id']), str(row['series_id']))\n    if os.path.exists(series_path):\n        return [os.path.join(series_path, f) for f in os.listdir(series_path) if os.path.isfile(os.path.join(series_path, f))]\n    return []\n\n# Mapping of series_description to conditions\ncondition_mapping = {\n    'Sagittal T1': {'left': 'left_neural_foraminal_narrowing', 'right': 'right_neural_foraminal_narrowing'},\n    'Axial T2': {'left': 'left_subarticular_stenosis', 'right': 'right_subarticular_stenosis'},\n    'Sagittal T2/STIR': 'spinal_canal_stenosis'\n}\n\n# Create a list to store the expanded rows\nexpanded_rows = []\n\n# Expand the dataframe by adding new rows for each file path\nfor index, row in test_desc.iterrows():\n    image_paths = get_image_paths(row)\n    conditions = condition_mapping.get(row['series_description'], {})\n    if isinstance(conditions, str):  # Single condition\n        conditions = {'left': conditions, 'right': conditions}\n    for side, condition in conditions.items():\n        for image_path in image_paths:\n            expanded_rows.append({\n                'study_id': row['study_id'],\n                'series_id': row['series_id'],\n                'series_description': row['series_description'],\n                'image_path': image_path,\n                'condition': condition,\n                'row_id': f\"{row['study_id']}_{condition}\"\n            })","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:51:46.631888Z","iopub.execute_input":"2024-10-14T08:51:46.632523Z","iopub.status.idle":"2024-10-14T08:51:46.699501Z","shell.execute_reply.started":"2024-10-14T08:51:46.632474Z","shell.execute_reply":"2024-10-14T08:51:46.698150Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Create a new dataframe from the expanded rows\nexpanded_test_desc = pd.DataFrame(expanded_rows)\n\n# Display the resulting dataframe\nexpanded_test_desc.head()","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:51:48.689774Z","iopub.execute_input":"2024-10-14T08:51:48.690242Z","iopub.status.idle":"2024-10-14T08:51:48.705828Z","shell.execute_reply.started":"2024-10-14T08:51:48.690196Z","shell.execute_reply":"2024-10-14T08:51:48.704526Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# change severity column labels\n#Normal/Mild': 'normal_mild', 'Moderate': 'moderate', 'Severe': 'severe'}\nfinal_merged_df['severity'] = final_merged_df['severity'].map({'Normal/Mild': 'normal_mild', 'Moderate': 'moderate', 'Severe': 'severe'})","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:51:48.708271Z","iopub.execute_input":"2024-10-14T08:51:48.708800Z","iopub.status.idle":"2024-10-14T08:51:48.726079Z","shell.execute_reply.started":"2024-10-14T08:51:48.708742Z","shell.execute_reply":"2024-10-14T08:51:48.724843Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_data = expanded_test_desc\ntrain_data = final_merged_df","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:51:48.954584Z","iopub.execute_input":"2024-10-14T08:51:48.955062Z","iopub.status.idle":"2024-10-14T08:51:48.960485Z","shell.execute_reply.started":"2024-10-14T08:51:48.955013Z","shell.execute_reply":"2024-10-14T08:51:48.959186Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def load_dicom(path):\n    dicom = pydicom.read_file(path)\n    data = dicom.pixel_array\n    data = data - np.min(data)\n    if np.max(data) != 0:\n        data = data / np.max(data)\n    data = (data * 255).astype(np.uint8)\n    return data","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:52:34.474858Z","iopub.execute_input":"2024-10-14T08:52:34.475361Z","iopub.status.idle":"2024-10-14T08:52:34.482760Z","shell.execute_reply.started":"2024-10-14T08:52:34.475315Z","shell.execute_reply":"2024-10-14T08:52:34.481363Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data = train_data.dropna()","metadata":{"execution":{"iopub.status.busy":"2024-10-14T08:52:36.728916Z","iopub.execute_input":"2024-10-14T08:52:36.729416Z","iopub.status.idle":"2024-10-14T08:52:36.777751Z","shell.execute_reply.started":"2024-10-14T08:52:36.729370Z","shell.execute_reply":"2024-10-14T08:52:36.776503Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}