{"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":"This notebook aims to separate 50 samples (out of 2019 samples in the original dataset) to make a smaller version for training lighter models.\n\nTo download these files, all you need is to go to the <b><i>'Data'</i></b> section and download the <b><i>'light_dataset.zip'</i></b> file in the <b><i>'output'</i></b> sector. Note that these files are the first 50 samples of the <b><i>'train.csv'</i></b> in the original dataset and for labeling these data, one has to use the first 50 rows of the <b><i>'train.csv'</i></b> file.","metadata":{}},{"cell_type":"code","source":"# import needed modules\n\nimport shutil\nimport pandas as pd\nfrom tqdm import tqdm","metadata":{"execution":{"iopub.status.busy":"2023-02-18T21:16:39.976674Z","iopub.execute_input":"2023-02-18T21:16:39.977526Z","iopub.status.idle":"2023-02-18T21:16:39.98431Z","shell.execute_reply.started":"2023-02-18T21:16:39.977453Z","shell.execute_reply":"2023-02-18T21:16:39.982485Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# import train.csv to the environment\n\ntrain_path = '/kaggle/input/rsna-2022-cervical-spine-fracture-detection/train.csv'\ntrain_df = pd.read_csv(train_path)\n\ntrain_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-02-18T21:16:43.753731Z","iopub.execute_input":"2023-02-18T21:16:43.754099Z","iopub.status.idle":"2023-02-18T21:16:43.800196Z","shell.execute_reply.started":"2023-02-18T21:16:43.75407Z","shell.execute_reply":"2023-02-18T21:16:43.798881Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = pd.read_csv('/kaggle/input/rsna-2022-cervical-spine-fracture-detection/train.csv')\ntrain_df.head()\n\nt_lst = []\nfor i in tqdm(train_df['StudyInstanceUID'][:50]):\n    t_lst.append(i)","metadata":{"execution":{"iopub.status.busy":"2023-02-18T21:16:47.022645Z","iopub.execute_input":"2023-02-18T21:16:47.023051Z","iopub.status.idle":"2023-02-18T21:16:47.042852Z","shell.execute_reply.started":"2023-02-18T21:16:47.02302Z","shell.execute_reply":"2023-02-18T21:16:47.041631Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!mkdir /kaggle/working/light_dataset","metadata":{"execution":{"iopub.status.busy":"2023-02-18T21:16:50.5317Z","iopub.execute_input":"2023-02-18T21:16:50.532078Z","iopub.status.idle":"2023-02-18T21:16:50.799044Z","shell.execute_reply.started":"2023-02-18T21:16:50.532049Z","shell.execute_reply":"2023-02-18T21:16:50.797875Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"base_path = '/kaggle/input/rsna-2022-cervical-spine-fracture-detection/train_images'\n\nfor j in tqdm(t_lst):\n    shutil.make_archive(f'/kaggle/working/light_dataset/{j}', 'zip', f'/kaggle/input/rsna-2022-cervical-spine-fracture-detection/train_images/{i}')","metadata":{"execution":{"iopub.status.busy":"2023-02-18T21:17:09.347909Z","iopub.execute_input":"2023-02-18T21:17:09.348298Z","iopub.status.idle":"2023-02-18T21:17:28.351995Z","shell.execute_reply.started":"2023-02-18T21:17:09.34827Z","shell.execute_reply":"2023-02-18T21:17:28.350686Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"shutil.make_archive(f'/kaggle/working/light_dataset', 'zip', f'/kaggle/working/light_dataset')","metadata":{"execution":{"iopub.status.busy":"2023-02-18T21:17:32.611311Z","iopub.execute_input":"2023-02-18T21:17:32.611697Z","iopub.status.idle":"2023-02-18T21:17:43.720118Z","shell.execute_reply.started":"2023-02-18T21:17:32.611666Z","shell.execute_reply":"2023-02-18T21:17:43.718604Z"},"trusted":true},"execution_count":null,"outputs":[]}]}