瀏覽代碼

Adding helper files

Andrej 2 年之前
父節點
當前提交
3b9bbda390
共有 4 個文件被更改,包括 134 次插入0 次删除
  1. 13 0
      pythonScripts/calculate.ipynb
  2. 94 0
      pythonScripts/manageFiles.ipynb
  3. 0 0
      pythonScripts/updateFields.ipynb
  4. 27 0
      pythonScripts/updateFields1.ipynb

File diff suppressed because it is too large
+ 13 - 0
pythonScripts/calculate.ipynb


+ 94 - 0
pythonScripts/manageFiles.ipynb

@@ -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
+}

File diff suppressed because it is too large
+ 0 - 0
pythonScripts/updateFields.ipynb


File diff suppressed because it is too large
+ 27 - 0
pythonScripts/updateFields1.ipynb


Some files were not shown because too many files changed in this diff