{"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":9867543,"sourceType":"datasetVersion","datasetId":6040935},{"sourceId":10104520,"sourceType":"datasetVersion","datasetId":6232734}],"dockerImageVersionId":30804,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"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\nfor 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","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"try:\n    import zarr\nexcept: \n    !cp -r '/kaggle/input/hengck-czii-cryo-et-01/wheel_file' '/kaggle/working/'\n    !pip install /kaggle/working/wheel_file/asciitree-0.3.3/asciitree-0.3.3\n    !pip install --no-index --find-links=/kaggle/working/wheel_file zarr\n    !pip install --no-index --find-links=/kaggle/working/wheel_file connected-components-3d\nfrom datetime import datetime\nimport pytz\nimport sys\nsys.path.append('/kaggle/input/hengck-czii-cryo-et-01')\nfrom czii_helper import *\nfrom dataset import *\nfrom model2 import *\nimport numpy as np\nfrom scipy.optimize import linear_sum_assignment\nimport glob\nimport cc3d\nimport cv2\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import Axes3D","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-05T02:53:08.507896Z","iopub.execute_input":"2024-12-05T02:53:08.508484Z","iopub.status.idle":"2024-12-05T02:53:51.917519Z","shell.execute_reply.started":"2024-12-05T02:53:08.508423Z","shell.execute_reply":"2024-12-05T02:53:51.916338Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"valid_id = glob.glob('/kaggle/input/czii-cryo-et-object-identification/train/static/ExperimentRuns/*')\nvalid_id = [f.split('/')[-1] for f in valid_id]\ndef read_one_truth(id, overlay_dir):\n    location={}\n    json_dir = f'{overlay_dir}/{id}/Picks'\n    for p in PARTICLE_NAME[1:]:\n        json_file = f'{json_dir}/{p}.json'\n\n        with open(json_file, 'r') as f:\n            json_data = json.load(f)\n\n        num_point = len(json_data['points'])\n        loc = np.array([list(json_data['points'][i]['location'].values()) for i in range(num_point)])\n        location[p] = loc\n\n    return location","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-04T13:05:40.306184Z","iopub.execute_input":"2024-12-04T13:05:40.306603Z","iopub.status.idle":"2024-12-04T13:05:40.315850Z","shell.execute_reply.started":"2024-12-04T13:05:40.306567Z","shell.execute_reply":"2024-12-04T13:05:40.314768Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for i,id in enumerate(valid_id):\n    data=read_one_truth(id,'/kaggle/input/czii-cryo-et-object-identification/train/overlay/ExperimentRuns')\n    np.save(f'{id}.npy', data)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-04T13:06:10.588750Z","iopub.execute_input":"2024-12-04T13:06:10.589811Z","iopub.status.idle":"2024-12-04T13:06:10.818068Z","shell.execute_reply.started":"2024-12-04T13:06:10.589746Z","shell.execute_reply":"2024-12-04T13:06:10.817153Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"valid_id = glob.glob('/kaggle/input/extra-data/czii/ExperimentRuns/*')\nvalid_id = [f.split('/')[-1] for f in valid_id]\nfor i,id in enumerate(valid_id):\n    data=read_one_truth(id,'/kaggle/input/extra-data/czii_static/ExperimentRuns')\n    np.save(f'{id}.npy', data)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-04T13:07:32.940472Z","iopub.execute_input":"2024-12-04T13:07:32.940884Z","iopub.status.idle":"2024-12-04T13:07:33.823233Z","shell.execute_reply.started":"2024-12-04T13:07:32.940849Z","shell.execute_reply":"2024-12-04T13:07:33.822240Z"}},"outputs":[],"execution_count":null}]}