{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "remoteSourcesURL https://git0.fmf.uni-lj.si/studen/nixSuite/raw/master/remoteResources/resources.json\n", "{'labkeyInterface': {'url': 'https://git0.fmf.uni-lj.si/studen/labkeyInterface/archive/master.zip', 'branch': 'master', 'modules': []}, 'irAEMM': {'url': 'https://git0.fmf.uni-lj.si/studen/iraemm/archive/master.zip', 'branch': 'master', 'modules': ['iraemmBrowser']}, 'SlicerLabkeyExtension': {'url': 'https://git0.fmf.uni-lj.si/studen/SlicerLabkeyExtension/archive/SlicerExtensionIndex.zip', 'branch': 'SlicerExtensionIndex', 'modules': ['labkeyBrowser']}, 'limfomiPET': {'url': 'https://git0.fmf.uni-lj.si/studen/limfomiPET/archive/master.zip', 'branch': 'master', 'modules': ['imageBrowser']}, 'parseConfig': {'url': 'https://git0.fmf.uni-lj.si/studen/parseConfig/archive/master.zip', 'branch': 'master', 'modules': []}, 'orthancInterface': {'url': 'https://git0.fmf.uni-lj.si/studen/orthancInterface/archive/master.zip', 'branch': 'master', 'modules': []}}\n" ] } ], "source": [ "import sys\n", "import os\n", "import SimpleITK\n", "import numpy\n", "import matplotlib.pyplot\n", "import subprocess\n", "import json\n", "import re\n", "import config\n", "import getData\n", "import analysis\n", "\n", "sys.path.append(os.path.join(os.path.expanduser('~'),'software','src','nixSuite','wrapper'))\n", "import nixWrapper\n", "nixWrapper.loadLibrary('labkeyInterface')\n", "import labkeyInterface\n", "import labkeyFileBrowser\n", "import labkeyDatabaseBrowser\n", "\n", "def connect(server,f):\n", " net=labkeyInterface.labkeyInterface()\n", " fconfig=os.path.join(os.path.expanduser('~'),'.labkey','{}.json'.format(server))\n", " net.init(fconfig)\n", " net.getCSRF()\n", " return f(net)\n", "\n", "def connectDB(server):\n", " return connect(server,labkeyDatabaseBrowser.labkeyDB)\n", "\n", "def connectFB(server):\n", " return connect(server,labkeyFileBrowser.labkeyFileBrowser)\n", "\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "#setup\n", "fsetup='../template/cardiacSPECT.json'\n", "with open(fsetup,'r') as f:\n", " setup=json.load(f)\n", "\n", "db=connectDB('merlin')\n", "fb=connectFB('merlin')\n", " \n", "\n", " \n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#doAnalysis\n", "\n", "#fill the Imaging1 fields, for multiple visits, change sequence number\n", "\n", "\n", "#0.) convert to NRRD \n", "# ~/software/src/SlicerLabkeyExtenstion/slicerScripts/runSlicer.sh convertToNRRD.py ../template/cardiacSPECT.json)\n", "\n", "#this is not performed at vangogh, use Analysis on merlin, convertNRRD.py with cardiacSPECT.json\n", "\n", "#1.) downloadFiles\n", "\n", "#getData.downloadPatientFiles(db,fb,setup)\n", "#this should also be done at vangogh... Figuring out how\n", "\n", "#2.) generate (c-cluster) centers\n", "\n", "#setup the analysis (class sizes, number of realizations)\n", "nclass=[10,20,30]\n", "#nclass=[10]\n", "nr=20\n", "#nr=1\n", "\n", "#takes multiple hours for nr=20, nclass=[10,20,30]\n", "#runs matlab - maybe the first time licensing will be checked and error will be returned\n", "#just run once\n", "#analysis.calculateCenters(db,setup,nclass,nr)\n", "\n", "#3.) now do analysis - global gets the average IVF fit (see point one of the slides for both branches of analysis)\n", "#this again takes multiple hours for four images\n", "#from what I see this could be shortend (since only global parameters are sought)\n", "#analysis.doAnalysis(db,setup,nclass,nr,'global')\n", "\n", "#4.) do cluster analysis (bullets two and three under ML analysis)\n", "#analysis.doAnalysis(db,setup,nclass,nr,'IVF')\n", "\n", "#5.) sort out the segmentation points -> segmentation.ipynb and generate Segmentation.txt files read by pixelAnalysis\n", "\n", "#6.) run doPixelAnalysisIVF to calculate parameters from locations\n", "sigma2=[0.1,1,4]\n", "#analysis.doPixelAnalysis(db,setup,sigma2)\n", "\n", "#7.) store summary to database\n", "na=3\n", "s2=0.1\n", "#summary=analysis.fullSummary(db,setup,nclass,nr,s2,na)\n", "#analysis.storeSummary(db,setup,summary,s2,na)\n", "\n", "summaryIVF=analysis.summaryPixelIVF(db,setup,sigma2)\n", "analysis.storeIVF(db,setup,summaryIVF)\n", "\n", "#8.) Plot regions through chart wizard on labkey, see also Summary R Report for error-plots on multi-class analysis\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": 4 }