|
42 | 42 | "source": [ |
43 | 43 | "import os\n", |
44 | 44 | "import shutil\n", |
45 | | - "import subprocess\n", |
46 | 45 | "\n", |
47 | 46 | "import requests\n", |
48 | 47 | "import tqdm" |
|
165 | 164 | "for asset_key in sorted_files.keys():\n", |
166 | 165 | " print(asset_key)\n", |
167 | 166 | " im = read_dcm_image(sorted_files[asset_key][20])\n", |
168 | | - " im.save(f\"./recipes/img/frame_dicom_data_{asset_key}.png\")" |
| 167 | + " im_directory = os.path.dirname(os.path.abspath(\"\"))\n", |
| 168 | + " img_name = f\"frame_dicom_data_{asset_key}.png\"\n", |
| 169 | + " save_location = os.path.join(im_directory, \"img\", img_name)\n", |
| 170 | + " im.save(img_name)" |
169 | 171 | ] |
170 | 172 | }, |
171 | 173 | { |
|
316 | 318 | "cell_type": "markdown", |
317 | 319 | "metadata": {}, |
318 | 320 | "source": [ |
319 | | - "Finally, let's import the volumes using `appendManyToDataset` (see [link](https://staging.cloud.kili-technology.com/docs/python-graphql-api/python-api/#append_many_to_dataset)). The key argument is `json_content_array`, which is a list of list of strings. Each element is the list of urls or paths pointing to images of the volume considered.\n", |
320 | | - " - Let's host these images locally to demonstrate how we would do it with cloud URLs for example :" |
321 | | - ] |
322 | | - }, |
323 | | - { |
324 | | - "cell_type": "code", |
325 | | - "execution_count": null, |
326 | | - "metadata": {}, |
327 | | - "outputs": [], |
328 | | - "source": [ |
329 | | - "subprocess.Popen(\n", |
330 | | - " f\"python -m http.server 8001 --directory {ASSET_ROOT}\",\n", |
331 | | - " shell=True,\n", |
332 | | - " stdin=None,\n", |
333 | | - " stdout=None,\n", |
334 | | - " stderr=None,\n", |
335 | | - " close_fds=True,\n", |
336 | | - ")\n", |
337 | | - "ROOT_URL = \"http://localhost:8001/\"" |
338 | | - ] |
339 | | - }, |
340 | | - { |
341 | | - "cell_type": "code", |
342 | | - "execution_count": null, |
343 | | - "metadata": {}, |
344 | | - "outputs": [], |
345 | | - "source": [ |
346 | | - "def files_to_urls(files):\n", |
347 | | - " return list(map(lambda file: ROOT_URL + file.split(\"TCGA-LUAD\")[1], files))" |
348 | | - ] |
349 | | - }, |
350 | | - { |
351 | | - "cell_type": "code", |
352 | | - "execution_count": null, |
353 | | - "metadata": {}, |
354 | | - "outputs": [], |
355 | | - "source": [ |
356 | | - "kili.append_many_to_dataset(\n", |
357 | | - " project_id=project_id,\n", |
358 | | - " external_id_array=list(sorted_images.keys()),\n", |
359 | | - " json_content_array=list(map(files_to_urls, sorted_images.values())),\n", |
360 | | - ")" |
| 321 | + "Finally, let's import the volumes using `appendManyToDataset` (see [link](https://staging.cloud.kili-technology.com/docs/python-graphql-api/python-api/#append_many_to_dataset)). The key argument is `json_content_array`, which is a list of list of strings. Each element is the list of urls or paths pointing to images of the volume considered." |
361 | 322 | ] |
362 | 323 | }, |
363 | 324 | { |
364 | 325 | "attachments": {}, |
365 | 326 | "cell_type": "markdown", |
366 | 327 | "metadata": {}, |
367 | 328 | "source": [ |
368 | | - "Or, as mentionned, you can simply provide the paths to your images, and call the function like below : " |
| 329 | + "You can simply provide the paths to your images, and call the function like below : " |
369 | 330 | ] |
370 | 331 | }, |
371 | 332 | { |
|
405 | 366 | "source": [ |
406 | 367 | "ds_size = kili.count_assets(project_id=project_id)\n", |
407 | 368 | "print(ds_size)\n", |
408 | | - "assert ds_size == 6" |
| 369 | + "assert ds_size == 3" |
409 | 370 | ] |
410 | 371 | }, |
411 | 372 | { |
|
0 commit comments