{"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":"Quick notebook showing how to create masks for any patient in the training dataset using TotalSegmentator.\n\nIt works offline, the weights are already downloaded.","metadata":{}},{"cell_type":"markdown","source":"### **Installation**","metadata":{}},{"cell_type":"code","source":"!cp ../input/totalsegmentatorkaggle/totalSegmentatorKaggle/install.sh . && chmod +x install.sh && ./install.sh","metadata":{"execution":{"iopub.status.busy":"2023-08-24T21:04:12.153285Z","iopub.execute_input":"2023-08-24T21:04:12.154128Z","iopub.status.idle":"2023-08-24T21:07:09.691777Z","shell.execute_reply.started":"2023-08-24T21:04:12.154083Z","shell.execute_reply":"2023-08-24T21:07:09.69058Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Patient_id 10104 and serie_id 27573 for the example, change it to any other patient if you want.\n\n!mkdir -p /kaggle/temp/masks","metadata":{"execution":{"iopub.status.busy":"2023-08-24T21:07:09.695777Z","iopub.execute_input":"2023-08-24T21:07:09.69608Z","iopub.status.idle":"2023-08-24T21:07:10.81489Z","shell.execute_reply.started":"2023-08-24T21:07:09.696053Z","shell.execute_reply":"2023-08-24T21:07:10.813443Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### **Generate masks**","metadata":{}},{"cell_type":"code","source":"# -f if you want to use 3d_lowres, faster and less memory intensive\n!TotalSegmentator \\\n-i /kaggle/input/rsna-2023-abdominal-trauma-detection/train_images/10104/27573 \\\n-o /kaggle/temp/masks \\\n-ot 'nifti' \\\n-rs spleen kidney_left kidney_right liver esophagus colon duodenum small_bowel stomach","metadata":{"execution":{"iopub.status.busy":"2023-08-24T21:07:10.817631Z","iopub.execute_input":"2023-08-24T21:07:10.818877Z","iopub.status.idle":"2023-08-24T21:09:17.067081Z","shell.execute_reply.started":"2023-08-24T21:07:10.818838Z","shell.execute_reply":"2023-08-24T21:09:17.065765Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Show the generated masks\n!ls /kaggle/temp/masks","metadata":{"execution":{"iopub.status.busy":"2023-08-24T21:09:17.069795Z","iopub.execute_input":"2023-08-24T21:09:17.070282Z","iopub.status.idle":"2023-08-24T21:09:18.060041Z","shell.execute_reply.started":"2023-08-24T21:09:17.070229Z","shell.execute_reply":"2023-08-24T21:09:18.058839Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}