|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 24, |
| 6 | + "id": "c27a2580-0100-406d-8d3e-3fa4b6d28f57", |
| 7 | + "metadata": {}, |
| 8 | + "outputs": [], |
| 9 | + "source": [ |
| 10 | + "import obi_auth\n", |
| 11 | + "from entitysdk import Client\n", |
| 12 | + "from obi_auth import get_token\n", |
| 13 | + "from obi_notebook import get_projects" |
| 14 | + ] |
| 15 | + }, |
| 16 | + { |
| 17 | + "cell_type": "markdown", |
| 18 | + "id": "b914d46e-6ec8-42f6-bab4-a19960474ff3", |
| 19 | + "metadata": {}, |
| 20 | + "source": [ |
| 21 | + "# initialize token and project environment" |
| 22 | + ] |
| 23 | + }, |
| 24 | + { |
| 25 | + "cell_type": "code", |
| 26 | + "execution_count": 25, |
| 27 | + "id": "41951493-dd21-4483-99e2-3b53ea9cb6a4", |
| 28 | + "metadata": {}, |
| 29 | + "outputs": [ |
| 30 | + { |
| 31 | + "data": { |
| 32 | + "application/vnd.jupyter.widget-view+json": { |
| 33 | + "model_id": "bf30a255200f48ce9d942ef4c7962ef3", |
| 34 | + "version_major": 2, |
| 35 | + "version_minor": 0 |
| 36 | + }, |
| 37 | + "text/plain": [ |
| 38 | + "Dropdown(description='Select:', options=(('Understanding SSCx', {'id': 'f373e771-3a2f-4f45-ab59-0955efd7b1f4',…" |
| 39 | + ] |
| 40 | + }, |
| 41 | + "metadata": {}, |
| 42 | + "output_type": "display_data" |
| 43 | + } |
| 44 | + ], |
| 45 | + "source": [ |
| 46 | + "token = get_token(environment=\"staging\", auth_mode=\"daf\")\n", |
| 47 | + "project_context = get_projects.get_projects(token, env=\"staging\")" |
| 48 | + ] |
| 49 | + }, |
| 50 | + { |
| 51 | + "cell_type": "markdown", |
| 52 | + "id": "59abe72f-7f83-4fc1-9086-55706ffb4ece", |
| 53 | + "metadata": {}, |
| 54 | + "source": [ |
| 55 | + "# get Client object." |
| 56 | + ] |
| 57 | + }, |
| 58 | + { |
| 59 | + "cell_type": "code", |
| 60 | + "execution_count": 26, |
| 61 | + "id": "f007168f-d6bf-4d70-a816-e9ce0938a965", |
| 62 | + "metadata": {}, |
| 63 | + "outputs": [], |
| 64 | + "source": [ |
| 65 | + "client = Client(environment=\"staging\", project_context=project_context, token_manager=token)" |
| 66 | + ] |
| 67 | + }, |
| 68 | + { |
| 69 | + "cell_type": "markdown", |
| 70 | + "id": "74e14fbd-2bd1-4353-8733-d252bdb0d6db", |
| 71 | + "metadata": {}, |
| 72 | + "source": [ |
| 73 | + "# create an EMDenseReconstructionDataset" |
| 74 | + ] |
| 75 | + }, |
| 76 | + { |
| 77 | + "cell_type": "code", |
| 78 | + "execution_count": 29, |
| 79 | + "id": "85a0c2f2-153e-48c9-9108-a70dd5ff3228", |
| 80 | + "metadata": {}, |
| 81 | + "outputs": [], |
| 82 | + "source": [ |
| 83 | + "from entitysdk.models import EMDenseReconstructionDataset,BrainRegion,Subject\n", |
| 84 | + "\n", |
| 85 | + "brain_region = client.search_entity(entity_type=BrainRegion, query={\"annotation_value\": 68}).one()\n", |
| 86 | + "subject = client.search_entity(entity_type=Subject).first()\n", |
| 87 | + "\n", |
| 88 | + "em_dense_dataset = EMDenseReconstructionDataset(\n", |
| 89 | + " brain_region= brain_region,\n", |
| 90 | + " subject=subject,\n", |
| 91 | + " **{\n", |
| 92 | + " 'name': 'this is an example',\n", |
| 93 | + " 'description': 'this is a test dataset',\n", |
| 94 | + " 'fixation': None,\n", |
| 95 | + " 'staining_type': None,\n", |
| 96 | + " 'slicing_thickness': 40.0,\n", |
| 97 | + " 'tissue_shrinkage': None,\n", |
| 98 | + " 'microscope_type': None,\n", |
| 99 | + " 'detector': None,\n", |
| 100 | + " 'slicing_direction': None,\n", |
| 101 | + " 'landmarks': None,\n", |
| 102 | + " 'voltage': None,\n", |
| 103 | + " 'current': None,\n", |
| 104 | + " 'dose': None,\n", |
| 105 | + " 'temperature': None,\n", |
| 106 | + " 'volume_resolution_x_nm': 4.0,\n", |
| 107 | + " 'volume_resolution_y_nm': 4.0,\n", |
| 108 | + " 'volume_resolution_z_nm': 40.0,\n", |
| 109 | + " 'release_url': 'http://microns-explorer.org',\n", |
| 110 | + " 'cave_client_url': 'https://global.daf-apis.com',\n", |
| 111 | + " 'cave_datastack': 'minnie65_public',\n", |
| 112 | + " 'precomputed_mesh_url': 'precomputed://gs://iarpa_microns/minnie/minnie65/seg_m1300/',\n", |
| 113 | + " 'cell_identifying_property': 'pt_root_id'})\n", |
| 114 | + "em_dense_reconstruction = client.register_entity(entity=em_dense_dataset, project_context=project_context)" |
| 115 | + ] |
| 116 | + }, |
| 117 | + { |
| 118 | + "cell_type": "code", |
| 119 | + "execution_count": 30, |
| 120 | + "id": "4d84409c-7007-42fa-b165-d15103830fe6", |
| 121 | + "metadata": {}, |
| 122 | + "outputs": [], |
| 123 | + "source": [ |
| 124 | + "em_dense_reconstruction = client.search_entity(entity_type=EMDenseReconstructionDataset, query={'name':'this is an example'} ).one()" |
| 125 | + ] |
| 126 | + }, |
| 127 | + { |
| 128 | + "cell_type": "markdown", |
| 129 | + "id": "f59d7ad2-5392-412a-a653-e6c8bbcc4360", |
| 130 | + "metadata": {}, |
| 131 | + "source": [ |
| 132 | + "# create an EMCellMesh" |
| 133 | + ] |
| 134 | + }, |
| 135 | + { |
| 136 | + "cell_type": "code", |
| 137 | + "execution_count": 31, |
| 138 | + "id": "74993e03-3996-442a-8249-c5799a402283", |
| 139 | + "metadata": {}, |
| 140 | + "outputs": [], |
| 141 | + "source": [ |
| 142 | + "from entitysdk.models import EMCellMesh, EMCellMeshGenerationMethod, EMCellMeshType\n", |
| 143 | + "em_mesh = EMCellMesh(\n", |
| 144 | + " generation_method=EMCellMeshGenerationMethod.marching_cubes,\n", |
| 145 | + " mesh_type=EMCellMeshType.dynamic,\n", |
| 146 | + " brain_region=brain_region,\n", |
| 147 | + " subject=subject,\n", |
| 148 | + " em_dense_reconstruction_dataset=em_dense_reconstruction,\n", |
| 149 | + " **{\"release_version\": 1512,\n", |
| 150 | + " \"dense_reconstruction_cell_id\": 12,\n", |
| 151 | + " \"level_of_detail\": 1,\n", |
| 152 | + " })\n", |
| 153 | + "em_mesh_registered = client.register_entity(entity=em_mesh, project_context=project_context)" |
| 154 | + ] |
| 155 | + }, |
| 156 | + { |
| 157 | + "cell_type": "code", |
| 158 | + "execution_count": 32, |
| 159 | + "id": "cbd40f00-7a9b-4329-a193-4e0dfa43188e", |
| 160 | + "metadata": {}, |
| 161 | + "outputs": [], |
| 162 | + "source": [ |
| 163 | + "em_mesh_registered = client.search_entity(entity_type=EMCellMesh, query={'release_version':1512} ).one()" |
| 164 | + ] |
| 165 | + }, |
| 166 | + { |
| 167 | + "cell_type": "markdown", |
| 168 | + "id": "e9b43270-2e02-45f5-809a-88dbfc1fafef", |
| 169 | + "metadata": {}, |
| 170 | + "source": [ |
| 171 | + "# uploading an .obj file" |
| 172 | + ] |
| 173 | + }, |
| 174 | + { |
| 175 | + "cell_type": "code", |
| 176 | + "execution_count": 33, |
| 177 | + "id": "55da1866-dfea-445b-9afd-cea189276af6", |
| 178 | + "metadata": {}, |
| 179 | + "outputs": [], |
| 180 | + "source": [ |
| 181 | + "asset_obj = client.upload_file(\n", |
| 182 | + " entity_id=em_mesh_registered.id,\n", |
| 183 | + " entity_type=EMCellMesh,\n", |
| 184 | + " file_path=\"90.obj\",\n", |
| 185 | + " file_content_type=\"application/obj\",\n", |
| 186 | + " asset_label=\"cell_surface_mesh\",\n", |
| 187 | + " project_context=project_context,\n", |
| 188 | + " )" |
| 189 | + ] |
| 190 | + } |
| 191 | + ], |
| 192 | + "metadata": { |
| 193 | + "kernelspec": { |
| 194 | + "display_name": "Python 3 (ipykernel)", |
| 195 | + "language": "python", |
| 196 | + "name": "python3" |
| 197 | + }, |
| 198 | + "language_info": { |
| 199 | + "codemirror_mode": { |
| 200 | + "name": "ipython", |
| 201 | + "version": 3 |
| 202 | + }, |
| 203 | + "file_extension": ".py", |
| 204 | + "mimetype": "text/x-python", |
| 205 | + "name": "python", |
| 206 | + "nbconvert_exporter": "python", |
| 207 | + "pygments_lexer": "ipython3", |
| 208 | + "version": "3.12.8" |
| 209 | + } |
| 210 | + }, |
| 211 | + "nbformat": 4, |
| 212 | + "nbformat_minor": 5 |
| 213 | +} |
0 commit comments