|
@@ -0,0 +1,94 @@
|
|
|
|
+{
|
|
|
|
+ "cells": [
|
|
|
|
+ {
|
|
|
|
+ "cell_type": "code",
|
|
|
|
+ "execution_count": null,
|
|
|
|
+ "id": "8d48ca51-ba3b-412b-b5c1-8de044c96817",
|
|
|
|
+ "metadata": {},
|
|
|
|
+ "outputs": [],
|
|
|
|
+ "source": [
|
|
|
|
+ "#load required libraries\n",
|
|
|
|
+ "import sys\n",
|
|
|
|
+ "import os\n",
|
|
|
|
+ "import SimpleITK\n",
|
|
|
|
+ "import numpy\n",
|
|
|
|
+ "import matplotlib.pyplot\n",
|
|
|
|
+ "import chardet\n",
|
|
|
|
+ "import json\n",
|
|
|
|
+ "\n",
|
|
|
|
+ "#you should get nixSuite via git clone https://git0.fmf.uni-lj.si/studen/nixSuite.git\n",
|
|
|
|
+ "#if you don't put it to $HOME/software/src/, you should update the path\n",
|
|
|
|
+ "nixSuite=os.path.join(os.path.expanduser('~'),'software','src','nixSuite')\n",
|
|
|
|
+ "sys.path.append(os.path.join(nixSuite,'wrapper'))\n",
|
|
|
|
+ "import nixWrapper\n",
|
|
|
|
+ "nixWrapper.loadLibrary('labkeyInterface')\n",
|
|
|
|
+ "import labkeyInterface\n",
|
|
|
|
+ "import labkeyDatabaseBrowser\n",
|
|
|
|
+ "import labkeyFileBrowser\n",
|
|
|
|
+ "\n",
|
|
|
|
+ "def connectDB(server):\n",
|
|
|
|
+ " #check connectivity. This checks the configuration in $HOME/.labkey/network.json, \n",
|
|
|
|
+ " #where paths to certificates are stored\n",
|
|
|
|
+ " net=labkeyInterface.labkeyInterface()\n",
|
|
|
|
+ " fconfig=os.path.join(os.path.expanduser('~'),'.labkey','{}.json'.format(server))\n",
|
|
|
|
+ " net.init(fconfig)\n",
|
|
|
|
+ " #this reports the certificate used\n",
|
|
|
|
+ " try:\n",
|
|
|
|
+ " print('Using: {}'.format(net.connectionConfig['SSL']['user']))\n",
|
|
|
|
+ " except KeyError:\n",
|
|
|
|
+ " pass\n",
|
|
|
|
+ " #This gets a deafult CSRF code; It should report user name plus a long string of random hex numbers\n",
|
|
|
|
+ " net.getCSRF()\n",
|
|
|
|
+ " db=labkeyDatabaseBrowser.labkeyDB(net)\n",
|
|
|
|
+ " fb=labkeyFileBrowser.labkeyFileBrowser(net)\n",
|
|
|
|
+ " return db,fb"
|
|
|
|
+ ]
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "cell_type": "code",
|
|
|
|
+ "execution_count": null,
|
|
|
|
+ "id": "1322d7a2-b34b-43ef-8c7a-74065d41b560",
|
|
|
|
+ "metadata": {},
|
|
|
|
+ "outputs": [],
|
|
|
|
+ "source": [
|
|
|
|
+ "db,fb=connectDB('onko-nix')\n",
|
|
|
|
+ "imageDir='preprocessedImages'\n",
|
|
|
|
+ "idFilter={'variable':'ParticipantId','value':'1057/18','oper':'eq'}\n",
|
|
|
|
+ "project='limfomiPET/Study'\n",
|
|
|
|
+ "ds=db.selectRows(project,'study','Imaging1',[idFilter])\n",
|
|
|
|
+ "localDir=os.path.join(os.path.expanduser('~'),'temp','limfomiPET')\n",
|
|
|
|
+ "if not os.path.isdir(localDir):\n",
|
|
|
|
+ " os.mkdir(localDir)\n",
|
|
|
|
+ "for r in ds['rows']:\n",
|
|
|
|
+ " print(r)\n",
|
|
|
|
+ " remotePath='/'.join([imageDir,r['patientCode'],r['visitCode'],r['ctResampled']])\n",
|
|
|
|
+ " urlPath=fb.formatPathURL(project,remotePath)\n",
|
|
|
|
+ " #print('{}'.format(fb.entryExists(urlPath)))\n",
|
|
|
|
+ " localPath=os.path.join(localDir,r['ctResampled'])\n",
|
|
|
|
+ " fb.readFileToFile(urlPath,localPath)\n",
|
|
|
|
+ " "
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
|
|
+ "metadata": {
|
|
|
|
+ "kernelspec": {
|
|
|
|
+ "display_name": "Python 3 (ipykernel)",
|
|
|
|
+ "language": "python",
|
|
|
|
+ "name": "python3"
|
|
|
|
+ },
|
|
|
|
+ "language_info": {
|
|
|
|
+ "codemirror_mode": {
|
|
|
|
+ "name": "ipython",
|
|
|
|
+ "version": 3
|
|
|
|
+ },
|
|
|
|
+ "file_extension": ".py",
|
|
|
|
+ "mimetype": "text/x-python",
|
|
|
|
+ "name": "python",
|
|
|
|
+ "nbconvert_exporter": "python",
|
|
|
|
+ "pygments_lexer": "ipython3",
|
|
|
|
+ "version": "3.10.6"
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ "nbformat": 4,
|
|
|
|
+ "nbformat_minor": 5
|
|
|
|
+}
|