{"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":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nimport subprocess\n#for dirname, _, filenames in os.walk('/kaggle/input'):\n#    for filename in filenames:\n#        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-08-28T00:56:30.331017Z","iopub.execute_input":"2021-08-28T00:56:30.331680Z","iopub.status.idle":"2021-08-28T00:56:30.338431Z","shell.execute_reply.started":"2021-08-28T00:56:30.331623Z","shell.execute_reply":"2021-08-28T00:56:30.336758Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.system('apt install bc')\n! cp /kaggle/input/captk-181-installerbin/CaPTk_1.8.1_Installer.bin /kaggle/working/\n! chmod +x /kaggle/working/CaPTk_1.8.1_Installer.bin\n! echo -e Y | /kaggle/working/CaPTk_1.8.1_Installer.bin","metadata":{"execution":{"iopub.status.busy":"2021-08-28T01:41:37.365317Z","iopub.execute_input":"2021-08-28T01:41:37.365813Z","iopub.status.idle":"2021-08-28T01:42:18.041616Z","shell.execute_reply.started":"2021-08-28T01:41:37.365771Z","shell.execute_reply":"2021-08-28T01:42:18.040256Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subprocess.call([\"/kaggle/working/CaPTk/1.8.1/captk\", \"--appimage-extract\"])","metadata":{"execution":{"iopub.status.busy":"2021-08-28T00:57:21.144899Z","iopub.execute_input":"2021-08-28T00:57:21.145313Z","iopub.status.idle":"2021-08-28T00:57:47.052286Z","shell.execute_reply.started":"2021-08-28T00:57:21.145273Z","shell.execute_reply":"2021-08-28T00:57:47.051110Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.environ['PATH'] = \"/kaggle/working/squashfs-root/usr/lib:\" + os.environ['PATH'] \nos.environ['LD_LIBRARY_PATH'] = \"/kaggle/working/squashfs-root/usr/lib:\" + os.environ['LD_LIBRARY_PATH'] \nprint(os.environ['PATH'])\nprint(os.environ['LD_LIBRARY_PATH'])\n\n!/kaggle/working/squashfs-root/usr/bin/BraTSPipeline -h","metadata":{"execution":{"iopub.status.busy":"2021-08-28T00:57:47.053952Z","iopub.execute_input":"2021-08-28T00:57:47.054488Z","iopub.status.idle":"2021-08-28T00:57:48.016488Z","shell.execute_reply.started":"2021-08-28T00:57:47.054449Z","shell.execute_reply":"2021-08-28T00:57:48.015365Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cmd = '/kaggle/working/squashfs-root/usr/bin/BraTSPipeline'\n\nsubj = '/kaggle/input/rsna-miccai-brain-tumor-radiogenomic-classification/test/00001'\n\nt1c = os.path.join(subj,'T1wCE','Image-1.dcm')\nt1w = os.path.join(subj,'T1w','Image-1.dcm')\nt2w = os.path.join(subj,'T2w','Image-257.dcm')\nfl  = os.path.join(subj,'FLAIR','Image-1.dcm')\nop  = os.path.join('/kaggle/working/','00001')\n\nif os.path.exists(op)==False:\n    os.mkdir(op)\n\nprint(os.path.exists(t1c))\nprint(os.path.exists(t1w))\nprint(os.path.exists(t2w))\nprint(os.path.exists(fl))","metadata":{"execution":{"iopub.status.busy":"2021-08-28T01:39:49.532227Z","iopub.execute_input":"2021-08-28T01:39:49.532817Z","iopub.status.idle":"2021-08-28T01:39:49.559139Z","shell.execute_reply.started":"2021-08-28T01:39:49.532773Z","shell.execute_reply":"2021-08-28T01:39:49.558111Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\nsubprocess.call([cmd,'-t1c',t1c,'-t1',t1w,'-t2',t2w,'-fl',fl,'-s','0','-b','0','-o',op])","metadata":{"execution":{"iopub.status.busy":"2021-08-28T01:40:16.337058Z","iopub.execute_input":"2021-08-28T01:40:16.337660Z","iopub.status.idle":"2021-08-28T01:40:49.915233Z","shell.execute_reply.started":"2021-08-28T01:40:16.337623Z","shell.execute_reply":"2021-08-28T01:40:49.913981Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}