{"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":84969,"databundleVersionId":10033515,"sourceType":"competition"},{"sourceId":10148144,"sourceType":"datasetVersion","datasetId":6264520},{"sourceId":10148257,"sourceType":"datasetVersion","datasetId":6264605},{"sourceId":10148475,"sourceType":"datasetVersion","datasetId":6264776}],"dockerImageVersionId":30804,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"If you found this notebook helpful, please consider giving it an upvote!\n\nこのノートブックがいいと思った方はぜひupvoteをお願いします！","metadata":{}},{"cell_type":"code","source":"from IPython.display import HTML\nfrom base64 import b64encode\n\ndef play(filename):\n    html = ''\n    video = open(filename,'rb').read()\n    src = 'data:video/mp4;base64,' + b64encode(video).decode()\n    html += '<video width=1000 controls autoplay loop><source src=\"%s\" type=\"video/mp4\"></video>' % src \n    return HTML(html)\n\nplay('/kaggle/input/napari-video/napari 2024-12-09 21-23-06.mp4')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T13:07:07.649740Z","iopub.execute_input":"2024-12-09T13:07:07.650256Z","iopub.status.idle":"2024-12-09T13:07:08.482695Z","shell.execute_reply.started":"2024-12-09T13:07:07.650206Z","shell.execute_reply":"2024-12-09T13:07:08.480733Z"},"jupyter":{"source_hidden":true}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# !Attention!\n\nKaggle does not support napari, so this code needs to be run <span style=\"color: red;\">**locally**</span>. Please download the numpy data from the input section to your local environment and then execute this code.\n\nkaggleはnapariに対応していないため、このコードは<span style=\"color: red;\">**ローカル**</span>で実行する必要があります。インプットからnumpyデータをローカルにダウンロードしてからこのコードを実行してください\n","metadata":{}},{"cell_type":"markdown","source":"The method for creating segmented numpy data is documented in this notebook.\n\nセグメントされたnumpyデータの作り方はこのノートブックに書いています\n\nhttps://www.kaggle.com/code/yoshio13/how-to-convert-json-to-segmentation-images","metadata":{}},{"cell_type":"code","source":"!pip install napari","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# run in local\n\nimport os\nimport napari\nimport numpy as np\n\n\nROOT_DIR = \"/kaggle/input/czii-cryoetobjectidentification-numpydata\"\nEXP_NAME = \"TS_5_4\"\n\ntomogram = np.load(os.path.join(ROOT_DIR, EXP_NAME, f\"{EXP_NAME}_0_image.npy\"))\nlabel = np.load(os.path.join(ROOT_DIR, EXP_NAME, f\"{EXP_NAME}_0_label.npy\"))\n\nif __name__ == '__main__':\n    viewer = napari.Viewer()\n    viewer.dims.ndisplay = 3\n    viewer.add_image(tomogram)\n    viewer.add_labels(label)\n    napari.run()\n\n","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"It is possible to display slice images instead of 3D visuals.\n\n3Dではなくスライスした画像でも表示できます","metadata":{}},{"cell_type":"code","source":"from IPython.display import HTML\nfrom base64 import b64encode\n\ndef play(filename):\n    html = ''\n    video = open(filename,'rb').read()\n    src = 'data:video/mp4;base64,' + b64encode(video).decode()\n    html += '<video width=1000 controls autoplay loop><source src=\"%s\" type=\"video/mp4\"></video>' % src \n    return HTML(html)\n\nplay('/kaggle/input/napari-viedo2/napari 2024-12-09 21-47-07.mp4')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T13:08:25.497403Z","iopub.execute_input":"2024-12-09T13:08:25.497839Z","iopub.status.idle":"2024-12-09T13:08:26.012701Z","shell.execute_reply.started":"2024-12-09T13:08:25.497807Z","shell.execute_reply":"2024-12-09T13:08:26.010764Z"}},"outputs":[],"execution_count":null}]}