File size: 2,088 Bytes
a3290d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import voxel as vx\n",
    "import tunnelvision as tv\n",
    "import numpy as np\n",
    "\n",
    "mv = vx.load(\"./segmentations/converted_dcm.nii.gz\")\n",
    "mv = mv.reformat((\"LR\", \"PA\", \"IS\"))\n",
    "np_mv = mv.A\n",
    "np_mv = np_mv.astype(np.int32)\n",
    "np_mv = np.expand_dims(np_mv, axis=0)\n",
    "np_mv = np.expand_dims(np_mv, axis=4)\n",
    "\n",
    "seg = vx.load(\"./rois/roi.nii.gz\")\n",
    "np_seg = seg.A\n",
    "np_seg_dim = seg.A\n",
    "np_seg = np_seg.astype(np.int32)\n",
    "np_seg = np.expand_dims(np_seg, axis=0)\n",
    "np_seg = np.expand_dims(np_seg, axis=4)\n",
    "\n",
    "hip_seg = vx.load(\"./segmentations/hip.nii.gz\")\n",
    "hip_seg = hip_seg.reformat((\"LR\", \"PA\", \"IS\"))\n",
    "np_hip_seg = hip_seg.A.astype(int)\n",
    "# set values not equal to 88 or 89 to 0\n",
    "np_hip_seg[(np_hip_seg != 88) & (np_hip_seg != 89)] = 0\n",
    "np_hip_seg[np_hip_seg != 0] = np_hip_seg[np_hip_seg != 0] + 4\n",
    "np_hip_seg[np_seg_dim != 0] = 0\n",
    "np_hip_seg = np_hip_seg.astype(np.int32)\n",
    "np_hip_seg = np.expand_dims(np_hip_seg, axis=0)\n",
    "np_hip_seg = np.expand_dims(np_hip_seg, axis=4)\n",
    "\n",
    "ax = tv.Axes(figsize=(512, 512))\n",
    "ax.imshow(np_mv)\n",
    "ax.imshow(np_seg, cmap=\"seg\")\n",
    "ax.imshow(np_hip_seg, cmap=\"seg\")\n",
    "ax.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.8.16 ('c2c_env')",
   "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.8.16"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "62fd47c2f495fb43260e4f88a1d5487d18d4c091bac4d4df4eca96cade9f1e23"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}