{"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":"markdown","source":"# <h><b><center>⭐️⭐️RSNA Screening Mammograpy Breast Cancer Detection⭐️⭐️</center></b></h>\n\n<center>\n    <img src=\"https://www.rsna.org/-/media/Images/RSNA/News-articles/2021/june/Breast-AI-feature.ashx?h=500&w=800&la=en&hash=1B1412A43BE14CCC9DB81B9A4EA072E6F59436CC\" alt=\"centered image\" />\n</center>\n\n\n# <center><b>💡Goal of the Competition💡</b></center>\n\n## **The goal of this competition is to identify breast cancer. You'll train your model with screening mammograms obtained from regular screening.**\n\n### ***Your work improving the automation of detection in screening mammography may enable radiologists to be more accurate and efficient, improving the quality and safety of patient care. It could also help reduce costs and unnecessary medical procedures.***","metadata":{}},{"cell_type":"markdown","source":"\n# <center><i>🤔 Initially Concern about Only 💡 CSV Data 🤔 - EDA & Machinelearning approach</i></center>\n\n## **Steps:**\n\n### **1. Import Necessary Library**\n\n### **2. Load and analysis the data**\n\n### **3. Preprocessing**\n\n### **4. KFOLD**\n\n### **5. Build the Model**\n\n### **6. Predict Output**\n\n### **7. Generate Submission file**\n\n# <center><b>💡Just try! My ordinary baseline work and taking only CSV File, then we will focus image data💡</b></center>","metadata":{}},{"cell_type":"markdown","source":"# **Import Library** ","metadata":{}},{"cell_type":"code","source":"import numpy as np \nimport pandas as pd\nimport matplotlib.pyplot as plt\n%matplotlib inline\nimport seaborn as sns\nimport cv2\n#Preprocessing\nfrom sklearn import model_selection\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import OrdinalEncoder,StandardScaler\nfrom sklearn import preprocessing\nfrom sklearn.impute import KNNImputer\nfrom sklearn.impute import SimpleImputer\n#Model\nfrom sklearn.ensemble import RandomForestRegressor\nfrom sklearn.metrics import mean_squared_error\nfrom xgboost import XGBRegressor\nfrom lightgbm import LGBMRegressor\nimport lightgbm as lgb","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:18:33.608412Z","iopub.execute_input":"2022-12-10T05:18:33.609569Z","iopub.status.idle":"2022-12-10T05:18:40.411141Z","shell.execute_reply.started":"2022-12-10T05:18:33.609462Z","shell.execute_reply":"2022-12-10T05:18:40.409855Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Load data**","metadata":{}},{"cell_type":"code","source":"train = pd.read_csv('/kaggle/input/rsna-breast-cancer-detection/train.csv')\ntest = pd.read_csv('/kaggle/input/rsna-breast-cancer-detection/test.csv')\nsample = pd.read_csv('/kaggle/input/rsna-breast-cancer-detection/sample_submission.csv')\ntrain_image_path = '/kaggle/input/rsna-breast-cancer-detection/train_images'\ntest_image_path = '/kaggle/input/rsna-breast-cancer-detection/test_images'","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:18:40.417484Z","iopub.execute_input":"2022-12-10T05:18:40.420191Z","iopub.status.idle":"2022-12-10T05:18:40.590748Z","shell.execute_reply.started":"2022-12-10T05:18:40.420147Z","shell.execute_reply":"2022-12-10T05:18:40.589631Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **EDA**","metadata":{}},{"cell_type":"code","source":"print(f'Train_Shape: {train.shape},Test_Shape: {test.shape},Sample_Shape: {sample.shape}')\ndisplay(train.sample(2))\ndisplay(test.sample(2))\ndisplay(sample.sample(2))\n","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:18:40.592447Z","iopub.execute_input":"2022-12-10T05:18:40.592959Z","iopub.status.idle":"2022-12-10T05:18:40.646539Z","shell.execute_reply.started":"2022-12-10T05:18:40.592913Z","shell.execute_reply":"2022-12-10T05:18:40.644751Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.info()","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:18:40.656811Z","iopub.execute_input":"2022-12-10T05:18:40.657276Z","iopub.status.idle":"2022-12-10T05:18:40.705611Z","shell.execute_reply.started":"2022-12-10T05:18:40.657236Z","shell.execute_reply":"2022-12-10T05:18:40.704371Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.describe(include='object')","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:18:40.707229Z","iopub.execute_input":"2022-12-10T05:18:40.707885Z","iopub.status.idle":"2022-12-10T05:18:40.748198Z","shell.execute_reply.started":"2022-12-10T05:18:40.707843Z","shell.execute_reply":"2022-12-10T05:18:40.747147Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.rc('figure',figsize= (10,12))\nsns.set_context('paper',font_scale=1)\n\nplt.title('Missing value status',fontweight = 'bold')\nax = sns.heatmap(train.isnull().sum().to_frame(),annot=True,fmt = 'd',cmap = 'RdGy')\nax.set_xlabel('Amount Missing')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:18:40.750144Z","iopub.execute_input":"2022-12-10T05:18:40.750533Z","iopub.status.idle":"2022-12-10T05:18:41.230633Z","shell.execute_reply.started":"2022-12-10T05:18:40.750493Z","shell.execute_reply":"2022-12-10T05:18:41.229401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.rc('figure',figsize= (10,12))\nsns.set_context('paper',font_scale=1)\n\nplt.title('Missing value status',fontweight = 'bold')\nax = sns.heatmap(test.isnull().sum().to_frame(),annot=True,fmt = 'd')\nax.set_xlabel('Amount Missing')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:18:41.233413Z","iopub.execute_input":"2022-12-10T05:18:41.234108Z","iopub.status.idle":"2022-12-10T05:18:41.594769Z","shell.execute_reply.started":"2022-12-10T05:18:41.234033Z","shell.execute_reply":"2022-12-10T05:18:41.593725Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(8,8))\nsns.countplot(train['cancer'])","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:18:41.596506Z","iopub.execute_input":"2022-12-10T05:18:41.597133Z","iopub.status.idle":"2022-12-10T05:18:41.80765Z","shell.execute_reply.started":"2022-12-10T05:18:41.597083Z","shell.execute_reply":"2022-12-10T05:18:41.806417Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:18:41.809834Z","iopub.execute_input":"2022-12-10T05:18:41.810187Z","iopub.status.idle":"2022-12-10T05:18:41.837276Z","shell.execute_reply.started":"2022-12-10T05:18:41.810156Z","shell.execute_reply":"2022-12-10T05:18:41.836123Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(8,8))\nsns.countplot(train['view'])","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:18:41.842212Z","iopub.execute_input":"2022-12-10T05:18:41.842701Z","iopub.status.idle":"2022-12-10T05:18:42.110188Z","shell.execute_reply.started":"2022-12-10T05:18:41.842662Z","shell.execute_reply":"2022-12-10T05:18:42.109255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(15,20))\nsns.countplot(train['age'])","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:18:42.111377Z","iopub.execute_input":"2022-12-10T05:18:42.111745Z","iopub.status.idle":"2022-12-10T05:18:43.093002Z","shell.execute_reply.started":"2022-12-10T05:18:42.111709Z","shell.execute_reply":"2022-12-10T05:18:43.091771Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(8,8))\nsns.countplot(train['difficult_negative_case'])","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:18:43.094664Z","iopub.execute_input":"2022-12-10T05:18:43.095304Z","iopub.status.idle":"2022-12-10T05:18:43.302963Z","shell.execute_reply.started":"2022-12-10T05:18:43.095262Z","shell.execute_reply":"2022-12-10T05:18:43.301553Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **KFOLD**","metadata":{}},{"cell_type":"code","source":"#add extra one columns\ntrain['kfold']=-1\n#Distributing the data 5 shares\nkfold = model_selection.KFold(n_splits=5, shuffle= True, random_state = 12)\nfor fold, (train_indicies, valid_indicies) in enumerate(kfold.split(X=train)):\n    #print(fold,train_indicies,valid_indicies)\n    train.loc[valid_indicies,'kfold'] = fold    \nprint(train.kfold.value_counts()) #total data 300000 = kfold split :5 * 60000\n#output of train folds data\ntrain.to_csv(\"trainfold_5.csv\",index=False)","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:18:43.306418Z","iopub.execute_input":"2022-12-10T05:18:43.306981Z","iopub.status.idle":"2022-12-10T05:18:43.526366Z","shell.execute_reply.started":"2022-12-10T05:18:43.306947Z","shell.execute_reply":"2022-12-10T05:18:43.524979Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Preprocessing - Categorical to Numerical data**","metadata":{}},{"cell_type":"code","source":"##Converting all categorical data to numerical\ntrain['view'] =train['view'].astype('category').cat.codes\ntrain['density'] =train['density'].astype('category').cat.codes\ntrain['laterality'] =train['laterality'].astype('category').cat.codes\ntrain['difficult_negative_case'] =train['difficult_negative_case'].astype('category').cat.codes\n\n\ntest['prediction_id'] =test['prediction_id'].astype('category').cat.codes\ntest['view'] =test['view'].astype('category').cat.codes\ntest['laterality'] = test['laterality'].astype('category').cat.codes","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:18:43.52849Z","iopub.execute_input":"2022-12-10T05:18:43.528924Z","iopub.status.idle":"2022-12-10T05:18:43.556195Z","shell.execute_reply.started":"2022-12-10T05:18:43.528882Z","shell.execute_reply":"2022-12-10T05:18:43.555107Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.info()","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:18:43.557834Z","iopub.execute_input":"2022-12-10T05:18:43.558237Z","iopub.status.idle":"2022-12-10T05:18:43.577178Z","shell.execute_reply.started":"2022-12-10T05:18:43.558201Z","shell.execute_reply":"2022-12-10T05:18:43.57612Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **KNNImputer**","metadata":{}},{"cell_type":"code","source":"imputer = KNNImputer(n_neighbors=5)\ntrain_im = pd.DataFrame(imputer.fit_transform(train))\ntest_im = pd.DataFrame(imputer.fit_transform(test))\n#remove column\ntrain_im.columns = train.columns\ntest_im.columns = test.columns\n\ntrain = train_im\ntest = test_im","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:18:43.579182Z","iopub.execute_input":"2022-12-10T05:18:43.579933Z","iopub.status.idle":"2022-12-10T05:20:13.840681Z","shell.execute_reply.started":"2022-12-10T05:18:43.579888Z","shell.execute_reply":"2022-12-10T05:20:13.839587Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Build the model**","metadata":{}},{"cell_type":"code","source":"from catboost import CatBoostRegressor,CatBoostClassifier\nfrom xgboost import XGBRegressor,XGBClassifier\n\n#features(categorical and numerical datas separate)\nuseful_features = [c for c in train.columns if c not in (\"kfold\",\"cancer\",\"BIRADS\",\"density\",\"difficult_negative_case\",\"biopsy\")]\nobject_cols = [col for col in useful_features]\n#numerical_cols = [col for col in useful_features]\ntest = test.copy()\n\nfor fold in range(5):\n    xtrain = train[train.kfold != fold].reset_index(drop=True)\n    xvalid = train[train.kfold == fold].reset_index(drop=True)\n\n    ytrain = xtrain.cancer\n    yvalid = xvalid.cancer\n    \n    xtrain = xtrain[useful_features]\n    xvalid = xvalid[useful_features]\n        \n    #Model hyperparameter of XGboostRegressor\n    \n    xgb_params = {\n            'learning_rate': 0.001168,\n            'subsample': 0.7875490025178,\n            'colsample_bytree': 0.11807135201147,\n            'max_depth': 6,\n            'booster': 'gbtree', \n            'reg_lambda': 0.0008746338866473539,\n            'reg_alpha': 23.13181079976304,\n            'random_state':42,\n            'n_estimators':10000\n            }\n\n    model= XGBClassifier(**xgb_params)\n\n    model.fit(xtrain,ytrain,verbose=False)\n    #way of output is display\n    print(f\"fold:{fold}\")","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:20:13.842592Z","iopub.execute_input":"2022-12-10T05:20:13.843052Z","iopub.status.idle":"2022-12-10T05:25:25.987902Z","shell.execute_reply.started":"2022-12-10T05:20:13.843012Z","shell.execute_reply":"2022-12-10T05:25:25.986652Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Predict the test data**","metadata":{}},{"cell_type":"code","source":"test_predict = model.predict(test)\ntest_predict","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:25:25.990333Z","iopub.execute_input":"2022-12-10T05:25:25.991037Z","iopub.status.idle":"2022-12-10T05:25:26.003004Z","shell.execute_reply.started":"2022-12-10T05:25:25.990995Z","shell.execute_reply":"2022-12-10T05:25:26.00193Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#prediction of data\npreds = np.mean(np.column_stack(test_predict),axis=1)\nprint(preds)","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:25:26.004641Z","iopub.execute_input":"2022-12-10T05:25:26.005387Z","iopub.status.idle":"2022-12-10T05:25:26.015439Z","shell.execute_reply.started":"2022-12-10T05:25:26.00534Z","shell.execute_reply":"2022-12-10T05:25:26.014489Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Generate submission data**","metadata":{}},{"cell_type":"code","source":"sample.cancer = preds[0]\nsample.to_csv(\"submission.csv\",index=False)\nprint(\"success\")","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:25:26.016887Z","iopub.execute_input":"2022-12-10T05:25:26.017575Z","iopub.status.idle":"2022-12-10T05:25:26.03014Z","shell.execute_reply.started":"2022-12-10T05:25:26.017537Z","shell.execute_reply":"2022-12-10T05:25:26.028926Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample.head()","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:25:26.031645Z","iopub.execute_input":"2022-12-10T05:25:26.032765Z","iopub.status.idle":"2022-12-10T05:25:26.047363Z","shell.execute_reply.started":"2022-12-10T05:25:26.032719Z","shell.execute_reply":"2022-12-10T05:25:26.04638Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# <center><b>💡Focus on Image Data💡</b></center>\n\n### **credit: https://www.kaggle.com/code/jirkaborovec/mammography-convert-windowing-dicom-png**","metadata":{}},{"cell_type":"markdown","source":"# **Windowing and Converting DICOM to PNG Images**","metadata":{}},{"cell_type":"markdown","source":"## **Install and import necessary library**","metadata":{}},{"cell_type":"code","source":"!pip install -qU \"python-gdcm\" pydicom pylibjpeg \"opencv-python-headless\"","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:25:26.048618Z","iopub.execute_input":"2022-12-10T05:25:26.049835Z","iopub.status.idle":"2022-12-10T05:25:47.509247Z","shell.execute_reply.started":"2022-12-10T05:25:26.049796Z","shell.execute_reply":"2022-12-10T05:25:47.507982Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nimport glob\nimport pydicom\nfrom tqdm.auto import tqdm\nimport cv2\nfrom PIL import Image\nfrom pydicom.pixel_data_handlers import apply_windowing","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:25:47.511265Z","iopub.execute_input":"2022-12-10T05:25:47.511706Z","iopub.status.idle":"2022-12-10T05:25:47.665341Z","shell.execute_reply.started":"2022-12-10T05:25:47.51166Z","shell.execute_reply":"2022-12-10T05:25:47.664229Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## **Load and convert images folder paths**","metadata":{}},{"cell_type":"code","source":"train_image = \"/kaggle/input/rsna-breast-cancer-detection/train_images\"\npath_convert_image = \"/kaggle/working/train_images\"","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:25:47.667235Z","iopub.execute_input":"2022-12-10T05:25:47.667658Z","iopub.status.idle":"2022-12-10T05:25:47.673885Z","shell.execute_reply.started":"2022-12-10T05:25:47.667617Z","shell.execute_reply":"2022-12-10T05:25:47.672881Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"is_images_found = glob.glob(os.path.join(train_image, \"*\", \"*.dcm\"))\nprint(f\"is_images_found: {len(is_images_found)}\")","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:25:47.675772Z","iopub.execute_input":"2022-12-10T05:25:47.67781Z","iopub.status.idle":"2022-12-10T05:26:57.985738Z","shell.execute_reply.started":"2022-12-10T05:25:47.677776Z","shell.execute_reply":"2022-12-10T05:26:57.984538Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## **Read the file**","metadata":{}},{"cell_type":"code","source":"#Load sample images\ndicom_images = pydicom.dcmread(is_images_found[0])\nprint(dicom_images)","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:26:57.987981Z","iopub.execute_input":"2022-12-10T05:26:57.98911Z","iopub.status.idle":"2022-12-10T05:26:58.088747Z","shell.execute_reply.started":"2022-12-10T05:26:57.989046Z","shell.execute_reply":"2022-12-10T05:26:58.087508Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## **Windowing**","metadata":{}},{"cell_type":"code","source":"nb_cols,nb_spls = 5,10\nnp.random.shuffle(is_images_found)","metadata":{"execution":{"iopub.status.busy":"2022-12-10T05:26:58.090365Z","iopub.execute_input":"2022-12-10T05:26:58.090741Z","iopub.status.idle":"2022-12-10T05:26:58.100727Z","shell.execute_reply.started":"2022-12-10T05:26:58.090704Z","shell.execute_reply":"2022-12-10T05:26:58.099665Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig,axarr = plt.subplots(ncols=nb_cols, nrows= nb_spls//nb_cols,\n                        figsize = (4 * nb_cols, 5*nb_spls/nb_cols))\n\nfor i, dicom_path in enumerate(is_images_found[:nb_spls]):\n    dicom = pydicom.dcmread(dicom_path)\n    if dicom.PhotometricInterpretation == \"MONOCHROME1\":\n        data = np.amax(dicom.pixel_array) - dicom.pixel_array\n    else:\n        data = dicom.pixel_array\n    img = apply_windowing(data, dicom)\n    print(img.shape, img.min(), img.max())\n    img = (img.astype(float) - img.min()) / (img.max() - img.min())\n    axarr[i // nb_cols, i % nb_cols].imshow(img, cmap=\"gray\")\n    axarr[i // nb_cols, i % nb_cols].set_axis_off()\nfig.tight_layout()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-12-10T05:26:58.107209Z","iopub.execute_input":"2022-12-10T05:26:58.107524Z","iopub.status.idle":"2022-12-10T05:27:30.525924Z","shell.execute_reply.started":"2022-12-10T05:26:58.107496Z","shell.execute_reply":"2022-12-10T05:27:30.524782Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## **Converting the images**","metadata":{}},{"cell_type":"code","source":"#Converting images\ndef convert_dicom(dicom_path, output_dir, img_size: int = 1024):\n    dicom = pydicom.dcmread(dicom_path)\n    if dicom.PhotometricInterpretation == \"MONOCHROME1\":\n        data = np.amax(dicom.pixel_array) - dicom.pixel_array\n    else:\n        data = dicom.pixel_array\n    img = apply_windowing(data, dicom)\n    img = (img.astype(float) - img.min()) / (img.max() - img.min())\n    img = Image.fromarray((img * 255).astype(np.uint8))\n\n    img_name, _ = os.path.splitext(os.path.basename(dicom_path))\n    img_dir = os.path.basename(os.path.dirname(dicom_path))\n    png_path = os.path.join(output_dir, img_dir, f\"{img_name}.png\")\n    os.makedirs(os.path.dirname(png_path), exist_ok=True)\n    # plt.imsave(png_path, (img * 255).astype(np.uint8))\n\n    img.thumbnail((img_size, img_size))\n    img.save(png_path)\n","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-12-10T05:27:30.526977Z","iopub.execute_input":"2022-12-10T05:27:30.527318Z","iopub.status.idle":"2022-12-10T05:27:30.538539Z","shell.execute_reply.started":"2022-12-10T05:27:30.527286Z","shell.execute_reply":"2022-12-10T05:27:30.53715Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#process of all image\nfrom joblib import Parallel, delayed\n\n# ! rm -rf train_images\n# ! mkdir train_images\n\n_= Parallel(n_jobs=5)(\n    delayed(convert_dicom)(p_img, output_dir=path_convert_image, img_size=720)\n    for p_img in tqdm(is_images_found)\n)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-12-10T05:27:30.540027Z","iopub.execute_input":"2022-12-10T05:27:30.541098Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#show some converted\nls_image = glob.glob(os.path.join(PATH_CONVERT, \"*\", \"*.png\"))\nnp.random.shuffle(ls_image)\n\nnb_spls = 6\n_, axarr = plt.subplots(ncols=2, nrows=nb_spls // 2, figsize=(10, 6 * nb_spls / 2))\nfor i, img_path in enumerate(ls_image[:nb_spls]):\n    img = plt.imread(img_path)\n    print(img.shape, img.min(), img.max())\n    axarr[i // 2, i % 2].imshow(img, cmap=\"gray\")\n    axarr[i // 2, i % 2].set_axis_off()","metadata":{"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## <b>📢Next process I was focus on Deeplearning approach! Coming soon...............</b>","metadata":{}},{"cell_type":"markdown","source":"## **Reference**\n\n1. https://www.kaggle.com/code/venkatkumar001/stripai-baseline-understanding-only-csv\n2. https://www.kaggle.com/code/jirkaborovec/mammography-convert-windowing-dicom-png\n\n## ***🤔If you see any error and doubts feel free to ask me!***","metadata":{}},{"cell_type":"markdown","source":"# <center><b>⭐️⭐️Thanks for visiting guys⭐️⭐️</b><center>","metadata":{}}]}