Browse Source

Adding helper script for sorting data

Andrej 1 year ago
parent
commit
c50c321b24
1 changed files with 18 additions and 13 deletions
  1. 18 13
      pythonScripts/assignOrthancStudy.ipynb

+ 18 - 13
pythonScripts/assignOrthancStudy.ipynb

@@ -2,7 +2,7 @@
  "cells": [
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": 2,
    "metadata": {},
    "outputs": [
     {
@@ -153,28 +153,33 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 55,
+   "execution_count": 5,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "User: andrej studen CSRF: 742504d3e58cd8cc93caa10ef513c97d\n",
-      "User: andrej studen CSRF: f667632a0758568b8589814da47b5f63\n",
-      "User: andrej studen CSRF: a7dea55e5497029587c2c9c471abaaad\n",
-      "User: andrej studen CSRF: 9f045a603f2e8358f6bb8a8e6e24eb9a\n",
-      "User: andrej studen CSRF: 4db47ccfa9edf2e0db620650e615e744\n",
-      "User: andrej studen CSRF: 2da87dffa8b1129a0592da44cbf9dd46\n",
-      "User: andrej studen CSRF: a09108818db07a4b2c444c82901f27c9\n"
+      "User: andrej studen CSRF: 7350f9dcc87c17afddc8c65618089763\n",
+      "User: andrej studen CSRF: 7ddb2a798e2815d2cc6344b560e9a8e1\n",
+      "User: andrej studen CSRF: 523db9b5e52a7a6c294b36d8e86b81d4\n"
      ]
     }
    ],
    "source": [
-    "def isCT(mtags):\n",
+    "def isCT(orthanc,sedata):\n",
+    "    #base criteria - is CT and SeriesDescription contains AC\n",
+    "    mtags=sedata['MainDicomTags']\n",
     "    if not mtags['Modality']=='CT':\n",
     "        return False\n",
-    "    if not mtags['SeriesDescription'].find('AC')==0:\n",
+    "    try:\n",
+    "        if not mtags['SeriesDescription'].find('AC')==0:\n",
+    "            return False\n",
+    "    except KeyError:\n",
+    "        pass\n",
+    "    #backup - more than a single instance\n",
+    "    n=len(sedata['Instances'])\n",
+    "    if n==1:\n",
     "        return False\n",
     "    return True\n",
     "\n",
@@ -216,14 +221,14 @@
     "    dataset='Imaging1'\n",
     "    ds=db.selectRows(project,'study',dataset,'')\n",
     "    for r in ds['rows']:\n",
-    "        if r['nmCorrDataOrthancId']:\n",
+    "        if r['nmMasterOrthancId']:\n",
     "            continue\n",
     "        series=orthanc.getStudyData(r['studyOrthancId'])['Series']\n",
     "        for s in series:\n",
     "            sedata=orthanc.getSeriesData(s)\n",
     "            mtags=sedata['MainDicomTags']\n",
     "            #print('{} {}'.format(mtags['Modality'],mtags['SeriesDescription']))\n",
-    "            if isCT(mtags):\n",
+    "            if isCT(orthanc,sedata):\n",
     "                r['ctOrthancId']=s\n",
     "                continue\n",
     "            if isMasterNM(orthanc,sedata):\n",