{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.15","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"tpu1vmV38","dataSources":[{"sourceId":84969,"databundleVersionId":10033515,"sourceType":"competition"}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"**install the zarr library**","metadata":{}},{"cell_type":"markdown","source":"Zarr is a modern file format designed to store large, multi-dimensional data (like 3D images) efficiently, especially for cloud storage. It organizes the data into chunks, allowing quick access to specific parts without loading the whole file. This makes it ideal for handling big datasets that need to be accessed or processed in sections.","metadata":{}},{"cell_type":"code","source":"!pip install zarr","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-13T07:27:34.570903Z","iopub.execute_input":"2024-11-13T07:27:34.571313Z","iopub.status.idle":"2024-11-13T07:27:41.381430Z","shell.execute_reply.started":"2024-11-13T07:27:34.571281Z","shell.execute_reply":"2024-11-13T07:27:41.380433Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#Loading required Libraries\n\nimport numpy as np \nimport pandas as pd \nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport zarr","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-13T07:27:41.383100Z","iopub.execute_input":"2024-11-13T07:27:41.383385Z","iopub.status.idle":"2024-11-13T07:27:46.186661Z","shell.execute_reply.started":"2024-11-13T07:27:41.383357Z","shell.execute_reply":"2024-11-13T07:27:46.185908Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**About Dataset**\n* In the train folder, there are two subfolders: Overlay and Static.\n* Overlay: This folder has JSON files (like apo-ferritin.json) that show where objects are located in the 3D images. These files help mark specific structures for easy identification.\n* Static: This folder contains 3D images saved as zarr files (e.g., ctfdeconvolved.zarr, denoised.zarr). Each file is a processed version of the same images, like denoised or corrected, to give clearer views of the objects.","metadata":{}},{"cell_type":"markdown","source":"**Exploring Static folder**\n\n* The Static folder has data from different experiments, each stored in subfolders like TS_5_4, TS_69_2, etc. These subfolders contain 3D images that have been processed for better analysis.\n  \n* The TS_5_4 experiment contains processed 3D image data with different enhancements, including CTF correction (ctfdeconvolved.zarr ), denoising (denoised.zarr), ISOnet correction (isonetcorrected.zarr), and possibly wide-bandpass filtering (wbp.zarr). These techniques improve the clarity and accuracy of the images for better analysis.\n","metadata":{}},{"cell_type":"code","source":"# picking CTF correction (ctfdeconvolved.zarr ) file from TS_5_4 Experiment\n\nts_5_4_ctf = zarr.open('/kaggle/input/czii-cryo-et-object-identification/train/static/ExperimentRuns/TS_5_4/VoxelSpacing10.000/ctfdeconvolved.zarr',mode = 'r')\nprint(ts_5_4_ctf)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-13T07:27:47.287454Z","iopub.execute_input":"2024-11-13T07:27:47.288510Z","iopub.status.idle":"2024-11-13T07:27:47.338613Z","shell.execute_reply.started":"2024-11-13T07:27:47.288475Z","shell.execute_reply":"2024-11-13T07:27:47.337855Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**listing all the items contained within the Zarr group**\n","metadata":{}},{"cell_type":"code","source":"print(list(ts_5_4_ctf.keys()))\nprint(ts_5_4_ctf[0].shape)\nprint(ts_5_4_ctf[1].shape)\nprint(ts_5_4_ctf[2].shape)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-13T07:27:51.152475Z","iopub.execute_input":"2024-11-13T07:27:51.153218Z","iopub.status.idle":"2024-11-13T07:27:51.174023Z","shell.execute_reply.started":"2024-11-13T07:27:51.153185Z","shell.execute_reply":"2024-11-13T07:27:51.173364Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Visualizing first image ts_5_4_ctf[0] having shape (184,630,630)**\n* The shape is (184, 630, 630), meaning it’s a 3D image with 184 layers, each of size 630x630 pixels.\n\n","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(10,100))  \n\nfor i in range(184):  \n    plt.subplot(37, 5, i + 1)  \n    plt.imshow(ts_5_4_ctf[0][i])  \n    plt.axis('off')  \n\n\nplt.tight_layout() \nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-13T07:27:53.336702Z","iopub.execute_input":"2024-11-13T07:27:53.337045Z","iopub.status.idle":"2024-11-13T07:29:13.607212Z","shell.execute_reply.started":"2024-11-13T07:27:53.337018Z","shell.execute_reply":"2024-11-13T07:29:13.606423Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Visualizing other zarr files from the TS_5_4 Experiment**","metadata":{}},{"cell_type":"code","source":"ts_5_4_denoised = zarr.open('/kaggle/input/czii-cryo-et-object-identification/train/static/ExperimentRuns/TS_5_4/VoxelSpacing10.000/denoised.zarr',mode = 'r')\nprint(ts_5_4_denoised[0].shape)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-13T07:29:38.107503Z","iopub.execute_input":"2024-11-13T07:29:38.108230Z","iopub.status.idle":"2024-11-13T07:29:38.144112Z","shell.execute_reply.started":"2024-11-13T07:29:38.108189Z","shell.execute_reply":"2024-11-13T07:29:38.143416Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(10,100))  \n\nfor i in range(184):  \n    plt.subplot(37, 5, i + 1)  \n    plt.imshow(ts_5_4_denoised[0][i])  \n    plt.axis('off')  \n\n\nplt.tight_layout() \nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-13T07:29:39.918027Z","iopub.execute_input":"2024-11-13T07:29:39.918395Z","iopub.status.idle":"2024-11-13T07:30:48.856324Z","shell.execute_reply.started":"2024-11-13T07:29:39.918366Z","shell.execute_reply":"2024-11-13T07:30:48.855432Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ts_5_4_iso = zarr.open('/kaggle/input/czii-cryo-et-object-identification/train/static/ExperimentRuns/TS_5_4/VoxelSpacing10.000/isonetcorrected.zarr',mode = 'r')\nprint(ts_5_4_iso[0].shape)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-13T07:31:42.566244Z","iopub.execute_input":"2024-11-13T07:31:42.566956Z","iopub.status.idle":"2024-11-13T07:31:42.592907Z","shell.execute_reply.started":"2024-11-13T07:31:42.566921Z","shell.execute_reply":"2024-11-13T07:31:42.592154Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(10,100))  \n\nfor i in range(184):  \n    plt.subplot(37, 5, i + 1)  \n    plt.imshow(ts_5_4_iso[0][i])  \n    plt.axis('off')  \n\n\nplt.tight_layout() \nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-13T07:31:56.024311Z","iopub.execute_input":"2024-11-13T07:31:56.025264Z","iopub.status.idle":"2024-11-13T07:33:10.412563Z","shell.execute_reply.started":"2024-11-13T07:31:56.025228Z","shell.execute_reply":"2024-11-13T07:33:10.411745Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ts_5_4_wbp = zarr.open('/kaggle/input/czii-cryo-et-object-identification/train/static/ExperimentRuns/TS_5_4/VoxelSpacing10.000/wbp.zarr',mode = 'r')\nprint(ts_5_4_wbp[0].shape)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-13T07:33:10.413978Z","iopub.execute_input":"2024-11-13T07:33:10.414257Z","iopub.status.idle":"2024-11-13T07:33:10.437897Z","shell.execute_reply.started":"2024-11-13T07:33:10.414229Z","shell.execute_reply":"2024-11-13T07:33:10.436977Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(10,100))  \n\nfor i in range(184):  \n    plt.subplot(37, 5, i + 1)  \n    plt.imshow(ts_5_4_wbp[0][i])  \n    plt.axis('off')  \n\n\nplt.tight_layout() \nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-13T07:33:40.373284Z","iopub.execute_input":"2024-11-13T07:33:40.373624Z","iopub.status.idle":"2024-11-13T07:34:55.285353Z","shell.execute_reply.started":"2024-11-13T07:33:40.373596Z","shell.execute_reply":"2024-11-13T07:34:55.284294Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}