{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "###############################################\n", "## Press the \"Run\" button above ##\n", "## Fernando Pérez-García, 2020 ##\n", "## fernando.perezgarcia.17@ucl.ac.uk ##\n", "###############################################\n", "\n", "from pathlib import Path\n", "from IPython.display import Javascript\n", "from IPython.core.display import display, HTML\n", "\n", "def say(string, header=True):\n", " if header: string = f'

{string}

'\n", " display(HTML(string))\n", "\n", "# Download repository\n", "say('Downloading repository...')\n", "repoName = 'Semiology-Visualisation-Tool'\n", "repoDir = Path(f'{repoName}-master')\n", "url = f'https://github.com/thenineteen/{repoName}/archive/master.zip'\n", "archiveFilePath = f'{repoName}.zip'\n", "downloadAndExtractArchive(url, archiveFilePath, '.')\n", "\n", "# Install Python module\n", "say('Installing libraries...')\n", "pip_install(f'--quiet --editable {repoDir}')\n", "\n", "# Load Python and Slicer modules\n", "say('Loading module...')\n", "moduleFactory = slicer.app.moduleManager().factoryManager()\n", "modulePath = repoDir / 'slicer/SemiologyVisualisation.py'\n", "moduleFactory.registerModule(qt.QFileInfo(str(modulePath)))\n", "moduleFactory.loadModules([modulePath.stem])\n", "selectModule('SemiologyVisualisation')\n", "slicer.semiologyVisualisation.setLiteMode()\n", "\n", "# Preload data\n", "say('Loading data...')\n", "slicer.semiologyVisualisation.loadDataButton.clicked()\n", "\n", "say('Done. Trying to open in a new tab...')\n", "html = \"\"\"\n", "

Click here to manually open 3D Slicer in a new tab

\"\"\"\n", "say(html, header=False)\n", "\n", "display(Javascript('window.open(\"../desktop\");'))" ] } ], "metadata": { "kernelspec": { "display_name": "Slicer 4.11", "language": "python", "name": "slicer-4.11" }, "language_info": { "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "version": "3.6.7" } }, "nbformat": 4, "nbformat_minor": 4 }