Diff of /interpolate-scans.ipynb [000000] .. [dc3c86]

Switch to unified view

a b/interpolate-scans.ipynb
1
{
2
 "cells": [
3
  {
4
   "cell_type": "markdown",
5
   "metadata": {},
6
   "source": [
7
    "## Interpolate scans so that all have same number of slices"
8
   ]
9
  },
10
  {
11
   "cell_type": "code",
12
   "execution_count": 10,
13
   "metadata": {},
14
   "outputs": [],
15
   "source": [
16
    "import numpy as np\n",
17
    "from scipy import ndimage as nd\n",
18
    "import os"
19
   ]
20
  },
21
  {
22
   "cell_type": "code",
23
   "execution_count": 5,
24
   "metadata": {},
25
   "outputs": [
26
    {
27
     "name": "stdout",
28
     "output_type": "stream",
29
     "text": [
30
      "\u001b[01;34m..\u001b[00m\r\n",
31
      "├── \u001b[01;34mdata\u001b[00m\r\n",
32
      "│   ├── \u001b[01;34mtrain\u001b[00m\r\n",
33
      "│   │   ├── \u001b[01;34maxial\u001b[00m\r\n",
34
      "│   │   ├── \u001b[01;34mcoronal\u001b[00m\r\n",
35
      "│   │   └── \u001b[01;34msagittal\u001b[00m\r\n",
36
      "│   └── \u001b[01;34mvalid\u001b[00m\r\n",
37
      "│       ├── \u001b[01;34maxial\u001b[00m\r\n",
38
      "│       ├── \u001b[01;34mcoronal\u001b[00m\r\n",
39
      "│       └── \u001b[01;34msagittal\u001b[00m\r\n",
40
      "├── \u001b[01;34mdata24\u001b[00m\r\n",
41
      "│   ├── \u001b[01;34mtrain\u001b[00m\r\n",
42
      "│   │   ├── \u001b[01;34maxial\u001b[00m\r\n",
43
      "│   │   ├── \u001b[01;34mcoronal\u001b[00m\r\n",
44
      "│   │   └── \u001b[01;34msagittal\u001b[00m\r\n",
45
      "│   └── \u001b[01;34mvalid\u001b[00m\r\n",
46
      "│       ├── \u001b[01;34maxial\u001b[00m\r\n",
47
      "│       ├── \u001b[01;34mcoronal\u001b[00m\r\n",
48
      "│       └── \u001b[01;34msagittal\u001b[00m\r\n",
49
      "└── \u001b[01;34mmrnet-fastai\u001b[00m\r\n",
50
      "    ├── \u001b[01;34m__pycache__\u001b[00m\r\n",
51
      "    ├── \u001b[01;34mexp\u001b[00m\r\n",
52
      "    ├── \u001b[01;34mmodels\u001b[00m\r\n",
53
      "    └── \u001b[01;34mpaper-code\u001b[00m\r\n",
54
      "        └── \u001b[01;34mMRNet-master\u001b[00m\r\n",
55
      "\r\n",
56
      "24 directories\r\n"
57
     ]
58
    }
59
   ],
60
   "source": [
61
    "! tree -d .."
62
   ]
63
  },
64
  {
65
   "cell_type": "code",
66
   "execution_count": 17,
67
   "metadata": {},
68
   "outputs": [
69
    {
70
     "data": {
71
      "text/plain": [
72
       "True"
73
      ]
74
     },
75
     "execution_count": 17,
76
     "metadata": {},
77
     "output_type": "execute_result"
78
    }
79
   ],
80
   "source": [
81
    "os.listdir('../data/train/axial')[0][-4:]=='.npy'"
82
   ]
83
  },
84
  {
85
   "cell_type": "markdown",
86
   "metadata": {},
87
   "source": [
88
    "Copy data to another directory, for example `/data24`, for 24 slices per scan. "
89
   ]
90
  },
91
  {
92
   "cell_type": "code",
93
   "execution_count": 4,
94
   "metadata": {},
95
   "outputs": [],
96
   "source": [
97
    "#! cp -R ../data ../data24"
98
   ]
99
  },
100
  {
101
   "cell_type": "markdown",
102
   "metadata": {},
103
   "source": [
104
    "Recurse through /train and /valid directories, load the scan file (.npy), interpolate to 24 slices and overwrite."
105
   ]
106
  },
107
  {
108
   "cell_type": "code",
109
   "execution_count": 26,
110
   "metadata": {},
111
   "outputs": [
112
    {
113
     "name": "stdout",
114
     "output_type": "stream",
115
     "text": [
116
      "Found 50 .npy files in ../data24/train/axial\n",
117
      "Converting ../data24/train/axial/0032.npy\n",
118
      "Number of slices for this scan: 24\n",
119
      "Interpolation factors for this scan: [1.0, 1.0, 1.0]\n",
120
      "Converting ../data24/train/axial/0026.npy\n",
121
      "Number of slices for this scan: 39\n",
122
      "Interpolation factors for this scan: [0.6153846153846154, 1.0, 1.0]\n",
123
      "Converting ../data24/train/axial/0027.npy\n",
124
      "Number of slices for this scan: 22\n",
125
      "Interpolation factors for this scan: [1.0909090909090908, 1.0, 1.0]\n",
126
      "Converting ../data24/train/axial/0033.npy\n",
127
      "Number of slices for this scan: 45\n",
128
      "Interpolation factors for this scan: [0.5333333333333333, 1.0, 1.0]\n",
129
      "Converting ../data24/train/axial/0019.npy\n",
130
      "Number of slices for this scan: 38\n",
131
      "Interpolation factors for this scan: [0.631578947368421, 1.0, 1.0]\n",
132
      "Converting ../data24/train/axial/0025.npy\n",
133
      "Number of slices for this scan: 24\n",
134
      "Interpolation factors for this scan: [1.0, 1.0, 1.0]\n",
135
      "Converting ../data24/train/axial/0031.npy\n",
136
      "Number of slices for this scan: 51\n",
137
      "Interpolation factors for this scan: [0.47058823529411764, 1.0, 1.0]\n",
138
      "Converting ../data24/train/axial/0030.npy\n",
139
      "Number of slices for this scan: 40\n",
140
      "Interpolation factors for this scan: [0.6, 1.0, 1.0]\n",
141
      "Converting ../data24/train/axial/0024.npy\n",
142
      "Number of slices for this scan: 38\n",
143
      "Interpolation factors for this scan: [0.631578947368421, 1.0, 1.0]\n",
144
      "Converting ../data24/train/axial/0018.npy\n",
145
      "Number of slices for this scan: 30\n",
146
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
147
      "Converting ../data24/train/axial/0020.npy\n",
148
      "Number of slices for this scan: 36\n",
149
      "Interpolation factors for this scan: [0.6666666666666666, 1.0, 1.0]\n",
150
      "Converting ../data24/train/axial/0034.npy\n",
151
      "Number of slices for this scan: 39\n",
152
      "Interpolation factors for this scan: [0.6153846153846154, 1.0, 1.0]\n",
153
      "Converting ../data24/train/axial/0008.npy\n",
154
      "Number of slices for this scan: 38\n",
155
      "Interpolation factors for this scan: [0.631578947368421, 1.0, 1.0]\n",
156
      "Converting ../data24/train/axial/0009.npy\n",
157
      "Number of slices for this scan: 34\n",
158
      "Interpolation factors for this scan: [0.7058823529411765, 1.0, 1.0]\n",
159
      "Converting ../data24/train/axial/0035.npy\n",
160
      "Number of slices for this scan: 40\n",
161
      "Interpolation factors for this scan: [0.6, 1.0, 1.0]\n",
162
      "Converting ../data24/train/axial/0021.npy\n",
163
      "Number of slices for this scan: 32\n",
164
      "Interpolation factors for this scan: [0.75, 1.0, 1.0]\n",
165
      "Converting ../data24/train/axial/0037.npy\n",
166
      "Number of slices for this scan: 26\n",
167
      "Interpolation factors for this scan: [0.9230769230769231, 1.0, 1.0]\n",
168
      "Converting ../data24/train/axial/0023.npy\n",
169
      "Number of slices for this scan: 36\n",
170
      "Interpolation factors for this scan: [0.6666666666666666, 1.0, 1.0]\n",
171
      "Converting ../data24/train/axial/0022.npy\n",
172
      "Number of slices for this scan: 36\n",
173
      "Interpolation factors for this scan: [0.6666666666666666, 1.0, 1.0]\n",
174
      "Converting ../data24/train/axial/0036.npy\n",
175
      "Number of slices for this scan: 26\n",
176
      "Interpolation factors for this scan: [0.9230769230769231, 1.0, 1.0]\n",
177
      "Converting ../data24/train/axial/0045.npy\n",
178
      "Number of slices for this scan: 46\n",
179
      "Interpolation factors for this scan: [0.5217391304347826, 1.0, 1.0]\n",
180
      "Converting ../data24/train/axial/0044.npy\n",
181
      "Number of slices for this scan: 24\n",
182
      "Interpolation factors for this scan: [1.0, 1.0, 1.0]\n",
183
      "Converting ../data24/train/axial/0046.npy\n",
184
      "Number of slices for this scan: 32\n",
185
      "Interpolation factors for this scan: [0.75, 1.0, 1.0]\n",
186
      "Converting ../data24/train/axial/0047.npy\n",
187
      "Number of slices for this scan: 24\n",
188
      "Interpolation factors for this scan: [1.0, 1.0, 1.0]\n",
189
      "Converting ../data24/train/axial/0043.npy\n",
190
      "Number of slices for this scan: 44\n",
191
      "Interpolation factors for this scan: [0.5454545454545454, 1.0, 1.0]\n",
192
      "Converting ../data24/train/axial/0042.npy\n",
193
      "Number of slices for this scan: 38\n",
194
      "Interpolation factors for this scan: [0.631578947368421, 1.0, 1.0]\n",
195
      "Converting ../data24/train/axial/0040.npy\n",
196
      "Number of slices for this scan: 29\n",
197
      "Interpolation factors for this scan: [0.8275862068965517, 1.0, 1.0]\n",
198
      "Converting ../data24/train/axial/0041.npy\n",
199
      "Number of slices for this scan: 40\n",
200
      "Interpolation factors for this scan: [0.6, 1.0, 1.0]\n",
201
      "Converting ../data24/train/axial/0049.npy\n",
202
      "Number of slices for this scan: 40\n",
203
      "Interpolation factors for this scan: [0.6, 1.0, 1.0]\n",
204
      "Converting ../data24/train/axial/0048.npy\n",
205
      "Number of slices for this scan: 34\n",
206
      "Interpolation factors for this scan: [0.7058823529411765, 1.0, 1.0]\n",
207
      "Converting ../data24/train/axial/0013.npy\n",
208
      "Number of slices for this scan: 39\n",
209
      "Interpolation factors for this scan: [0.6153846153846154, 1.0, 1.0]\n",
210
      "Converting ../data24/train/axial/0007.npy\n",
211
      "Number of slices for this scan: 32\n",
212
      "Interpolation factors for this scan: [0.75, 1.0, 1.0]\n",
213
      "Converting ../data24/train/axial/0006.npy\n",
214
      "Number of slices for this scan: 29\n",
215
      "Interpolation factors for this scan: [0.8275862068965517, 1.0, 1.0]\n",
216
      "Converting ../data24/train/axial/0012.npy\n",
217
      "Number of slices for this scan: 46\n",
218
      "Interpolation factors for this scan: [0.5217391304347826, 1.0, 1.0]\n",
219
      "Converting ../data24/train/axial/0038.npy\n",
220
      "Number of slices for this scan: 38\n",
221
      "Interpolation factors for this scan: [0.631578947368421, 1.0, 1.0]\n",
222
      "Converting ../data24/train/axial/0004.npy\n",
223
      "Number of slices for this scan: 40\n",
224
      "Interpolation factors for this scan: [0.6, 1.0, 1.0]\n",
225
      "Converting ../data24/train/axial/0010.npy\n",
226
      "Number of slices for this scan: 38\n",
227
      "Interpolation factors for this scan: [0.631578947368421, 1.0, 1.0]\n",
228
      "Converting ../data24/train/axial/0011.npy\n",
229
      "Number of slices for this scan: 44\n",
230
      "Interpolation factors for this scan: [0.5454545454545454, 1.0, 1.0]\n",
231
      "Converting ../data24/train/axial/0005.npy\n",
232
      "Number of slices for this scan: 41\n",
233
      "Interpolation factors for this scan: [0.5853658536585366, 1.0, 1.0]\n",
234
      "Converting ../data24/train/axial/0039.npy\n",
235
      "Number of slices for this scan: 36\n",
236
      "Interpolation factors for this scan: [0.6666666666666666, 1.0, 1.0]\n",
237
      "Converting ../data24/train/axial/0001.npy\n",
238
      "Number of slices for this scan: 30\n",
239
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
240
      "Converting ../data24/train/axial/0015.npy\n",
241
      "Number of slices for this scan: 32\n",
242
      "Interpolation factors for this scan: [0.75, 1.0, 1.0]\n",
243
      "Converting ../data24/train/axial/0029.npy\n",
244
      "Number of slices for this scan: 45\n",
245
      "Interpolation factors for this scan: [0.5333333333333333, 1.0, 1.0]\n",
246
      "Converting ../data24/train/axial/0028.npy\n",
247
      "Number of slices for this scan: 33\n",
248
      "Interpolation factors for this scan: [0.7272727272727273, 1.0, 1.0]\n",
249
      "Converting ../data24/train/axial/0014.npy\n",
250
      "Number of slices for this scan: 24\n",
251
      "Interpolation factors for this scan: [1.0, 1.0, 1.0]\n",
252
      "Converting ../data24/train/axial/0000.npy\n",
253
      "Number of slices for this scan: 44\n",
254
      "Interpolation factors for this scan: [0.5454545454545454, 1.0, 1.0]\n",
255
      "Converting ../data24/train/axial/0016.npy\n",
256
      "Number of slices for this scan: 48\n",
257
      "Interpolation factors for this scan: [0.5, 1.0, 1.0]\n",
258
      "Converting ../data24/train/axial/0002.npy\n",
259
      "Number of slices for this scan: 38\n",
260
      "Interpolation factors for this scan: [0.631578947368421, 1.0, 1.0]\n",
261
      "Converting ../data24/train/axial/0003.npy\n",
262
      "Number of slices for this scan: 33\n",
263
      "Interpolation factors for this scan: [0.7272727272727273, 1.0, 1.0]\n",
264
      "Converting ../data24/train/axial/0017.npy\n",
265
      "Number of slices for this scan: 25\n",
266
      "Interpolation factors for this scan: [0.96, 1.0, 1.0]\n",
267
      "===============================\n",
268
      "===============================\n",
269
      "Found 50 .npy files in ../data24/train/coronal\n",
270
      "Converting ../data24/train/coronal/0032.npy\n",
271
      "Number of slices for this scan: 31\n",
272
      "Interpolation factors for this scan: [0.7741935483870968, 1.0, 1.0]\n",
273
      "Converting ../data24/train/coronal/0026.npy\n",
274
      "Number of slices for this scan: 42\n",
275
      "Interpolation factors for this scan: [0.5714285714285714, 1.0, 1.0]\n",
276
      "Converting ../data24/train/coronal/0027.npy\n",
277
      "Number of slices for this scan: 28\n",
278
      "Interpolation factors for this scan: [0.8571428571428571, 1.0, 1.0]\n",
279
      "Converting ../data24/train/coronal/0033.npy\n",
280
      "Number of slices for this scan: 41\n",
281
      "Interpolation factors for this scan: [0.5853658536585366, 1.0, 1.0]\n",
282
      "Converting ../data24/train/coronal/0019.npy\n",
283
      "Number of slices for this scan: 32\n",
284
      "Interpolation factors for this scan: [0.75, 1.0, 1.0]\n",
285
      "Converting ../data24/train/coronal/0025.npy\n",
286
      "Number of slices for this scan: 20\n",
287
      "Interpolation factors for this scan: [1.2, 1.0, 1.0]\n",
288
      "Converting ../data24/train/coronal/0031.npy\n",
289
      "Number of slices for this scan: 35\n",
290
      "Interpolation factors for this scan: [0.6857142857142857, 1.0, 1.0]\n",
291
      "Converting ../data24/train/coronal/0030.npy\n",
292
      "Number of slices for this scan: 36\n",
293
      "Interpolation factors for this scan: [0.6666666666666666, 1.0, 1.0]\n"
294
     ]
295
    },
296
    {
297
     "name": "stdout",
298
     "output_type": "stream",
299
     "text": [
300
      "Converting ../data24/train/coronal/0024.npy\n",
301
      "Number of slices for this scan: 37\n",
302
      "Interpolation factors for this scan: [0.6486486486486487, 1.0, 1.0]\n",
303
      "Converting ../data24/train/coronal/0018.npy\n",
304
      "Number of slices for this scan: 22\n",
305
      "Interpolation factors for this scan: [1.0909090909090908, 1.0, 1.0]\n",
306
      "Converting ../data24/train/coronal/0020.npy\n",
307
      "Number of slices for this scan: 20\n",
308
      "Interpolation factors for this scan: [1.2, 1.0, 1.0]\n",
309
      "Converting ../data24/train/coronal/0034.npy\n",
310
      "Number of slices for this scan: 42\n",
311
      "Interpolation factors for this scan: [0.5714285714285714, 1.0, 1.0]\n",
312
      "Converting ../data24/train/coronal/0008.npy\n",
313
      "Number of slices for this scan: 38\n",
314
      "Interpolation factors for this scan: [0.631578947368421, 1.0, 1.0]\n",
315
      "Converting ../data24/train/coronal/0009.npy\n",
316
      "Number of slices for this scan: 27\n",
317
      "Interpolation factors for this scan: [0.8888888888888888, 1.0, 1.0]\n",
318
      "Converting ../data24/train/coronal/0035.npy\n",
319
      "Number of slices for this scan: 34\n",
320
      "Interpolation factors for this scan: [0.7058823529411765, 1.0, 1.0]\n",
321
      "Converting ../data24/train/coronal/0021.npy\n",
322
      "Number of slices for this scan: 20\n",
323
      "Interpolation factors for this scan: [1.2, 1.0, 1.0]\n",
324
      "Converting ../data24/train/coronal/0037.npy\n",
325
      "Number of slices for this scan: 22\n",
326
      "Interpolation factors for this scan: [1.0909090909090908, 1.0, 1.0]\n",
327
      "Converting ../data24/train/coronal/0023.npy\n",
328
      "Number of slices for this scan: 36\n",
329
      "Interpolation factors for this scan: [0.6666666666666666, 1.0, 1.0]\n",
330
      "Converting ../data24/train/coronal/0022.npy\n",
331
      "Number of slices for this scan: 30\n",
332
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
333
      "Converting ../data24/train/coronal/0036.npy\n",
334
      "Number of slices for this scan: 24\n",
335
      "Interpolation factors for this scan: [1.0, 1.0, 1.0]\n",
336
      "Converting ../data24/train/coronal/0045.npy\n",
337
      "Number of slices for this scan: 40\n",
338
      "Interpolation factors for this scan: [0.6, 1.0, 1.0]\n",
339
      "Converting ../data24/train/coronal/0044.npy\n",
340
      "Number of slices for this scan: 21\n",
341
      "Interpolation factors for this scan: [1.1428571428571428, 1.0, 1.0]\n",
342
      "Converting ../data24/train/coronal/0046.npy\n",
343
      "Number of slices for this scan: 18\n",
344
      "Interpolation factors for this scan: [1.3333333333333333, 1.0, 1.0]\n",
345
      "Converting ../data24/train/coronal/0047.npy\n",
346
      "Number of slices for this scan: 18\n",
347
      "Interpolation factors for this scan: [1.3333333333333333, 1.0, 1.0]\n",
348
      "Converting ../data24/train/coronal/0043.npy\n",
349
      "Number of slices for this scan: 46\n",
350
      "Interpolation factors for this scan: [0.5217391304347826, 1.0, 1.0]\n",
351
      "Converting ../data24/train/coronal/0042.npy\n",
352
      "Number of slices for this scan: 34\n",
353
      "Interpolation factors for this scan: [0.7058823529411765, 1.0, 1.0]\n",
354
      "Converting ../data24/train/coronal/0040.npy\n",
355
      "Number of slices for this scan: 20\n",
356
      "Interpolation factors for this scan: [1.2, 1.0, 1.0]\n",
357
      "Converting ../data24/train/coronal/0041.npy\n",
358
      "Number of slices for this scan: 37\n",
359
      "Interpolation factors for this scan: [0.6486486486486487, 1.0, 1.0]\n",
360
      "Converting ../data24/train/coronal/0049.npy\n",
361
      "Number of slices for this scan: 30\n",
362
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
363
      "Converting ../data24/train/coronal/0048.npy\n",
364
      "Number of slices for this scan: 30\n",
365
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
366
      "Converting ../data24/train/coronal/0013.npy\n",
367
      "Number of slices for this scan: 36\n",
368
      "Interpolation factors for this scan: [0.6666666666666666, 1.0, 1.0]\n",
369
      "Converting ../data24/train/coronal/0007.npy\n",
370
      "Number of slices for this scan: 24\n",
371
      "Interpolation factors for this scan: [1.0, 1.0, 1.0]\n",
372
      "Converting ../data24/train/coronal/0006.npy\n",
373
      "Number of slices for this scan: 23\n",
374
      "Interpolation factors for this scan: [1.0434782608695652, 1.0, 1.0]\n",
375
      "Converting ../data24/train/coronal/0012.npy\n",
376
      "Number of slices for this scan: 41\n",
377
      "Interpolation factors for this scan: [0.5853658536585366, 1.0, 1.0]\n",
378
      "Converting ../data24/train/coronal/0038.npy\n",
379
      "Number of slices for this scan: 40\n",
380
      "Interpolation factors for this scan: [0.6, 1.0, 1.0]\n",
381
      "Converting ../data24/train/coronal/0004.npy\n",
382
      "Number of slices for this scan: 34\n",
383
      "Interpolation factors for this scan: [0.7058823529411765, 1.0, 1.0]\n",
384
      "Converting ../data24/train/coronal/0010.npy\n",
385
      "Number of slices for this scan: 42\n",
386
      "Interpolation factors for this scan: [0.5714285714285714, 1.0, 1.0]\n",
387
      "Converting ../data24/train/coronal/0011.npy\n",
388
      "Number of slices for this scan: 38\n",
389
      "Interpolation factors for this scan: [0.631578947368421, 1.0, 1.0]\n",
390
      "Converting ../data24/train/coronal/0005.npy\n",
391
      "Number of slices for this scan: 38\n",
392
      "Interpolation factors for this scan: [0.631578947368421, 1.0, 1.0]\n",
393
      "Converting ../data24/train/coronal/0039.npy\n",
394
      "Number of slices for this scan: 32\n",
395
      "Interpolation factors for this scan: [0.75, 1.0, 1.0]\n",
396
      "Converting ../data24/train/coronal/0001.npy\n",
397
      "Number of slices for this scan: 20\n",
398
      "Interpolation factors for this scan: [1.2, 1.0, 1.0]\n",
399
      "Converting ../data24/train/coronal/0015.npy\n",
400
      "Number of slices for this scan: 30\n",
401
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
402
      "Converting ../data24/train/coronal/0029.npy\n",
403
      "Number of slices for this scan: 38\n",
404
      "Interpolation factors for this scan: [0.631578947368421, 1.0, 1.0]\n",
405
      "Converting ../data24/train/coronal/0028.npy\n",
406
      "Number of slices for this scan: 34\n",
407
      "Interpolation factors for this scan: [0.7058823529411765, 1.0, 1.0]\n",
408
      "Converting ../data24/train/coronal/0014.npy\n",
409
      "Number of slices for this scan: 22\n",
410
      "Interpolation factors for this scan: [1.0909090909090908, 1.0, 1.0]\n",
411
      "Converting ../data24/train/coronal/0000.npy\n",
412
      "Number of slices for this scan: 36\n",
413
      "Interpolation factors for this scan: [0.6666666666666666, 1.0, 1.0]\n",
414
      "Converting ../data24/train/coronal/0016.npy\n",
415
      "Number of slices for this scan: 44\n",
416
      "Interpolation factors for this scan: [0.5454545454545454, 1.0, 1.0]\n",
417
      "Converting ../data24/train/coronal/0002.npy\n",
418
      "Number of slices for this scan: 32\n",
419
      "Interpolation factors for this scan: [0.75, 1.0, 1.0]\n",
420
      "Converting ../data24/train/coronal/0003.npy\n",
421
      "Number of slices for this scan: 28\n",
422
      "Interpolation factors for this scan: [0.8571428571428571, 1.0, 1.0]\n",
423
      "Converting ../data24/train/coronal/0017.npy\n",
424
      "Number of slices for this scan: 25\n",
425
      "Interpolation factors for this scan: [0.96, 1.0, 1.0]\n",
426
      "===============================\n",
427
      "===============================\n",
428
      "Found 50 .npy files in ../data24/train/sagittal\n",
429
      "Converting ../data24/train/sagittal/0032.npy\n",
430
      "Number of slices for this scan: 34\n",
431
      "Interpolation factors for this scan: [0.7058823529411765, 1.0, 1.0]\n",
432
      "Converting ../data24/train/sagittal/0026.npy\n",
433
      "Number of slices for this scan: 40\n",
434
      "Interpolation factors for this scan: [0.6, 1.0, 1.0]\n",
435
      "Converting ../data24/train/sagittal/0027.npy\n",
436
      "Number of slices for this scan: 19\n",
437
      "Interpolation factors for this scan: [1.263157894736842, 1.0, 1.0]\n",
438
      "Converting ../data24/train/sagittal/0033.npy\n",
439
      "Number of slices for this scan: 44\n",
440
      "Interpolation factors for this scan: [0.5454545454545454, 1.0, 1.0]\n",
441
      "Converting ../data24/train/sagittal/0019.npy\n",
442
      "Number of slices for this scan: 30\n",
443
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
444
      "Converting ../data24/train/sagittal/0025.npy\n",
445
      "Number of slices for this scan: 24\n",
446
      "Interpolation factors for this scan: [1.0, 1.0, 1.0]\n",
447
      "Converting ../data24/train/sagittal/0031.npy\n",
448
      "Number of slices for this scan: 30\n",
449
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
450
      "Converting ../data24/train/sagittal/0030.npy\n",
451
      "Number of slices for this scan: 36\n",
452
      "Interpolation factors for this scan: [0.6666666666666666, 1.0, 1.0]\n",
453
      "Converting ../data24/train/sagittal/0024.npy\n",
454
      "Number of slices for this scan: 33\n",
455
      "Interpolation factors for this scan: [0.7272727272727273, 1.0, 1.0]\n",
456
      "Converting ../data24/train/sagittal/0018.npy\n",
457
      "Number of slices for this scan: 21\n",
458
      "Interpolation factors for this scan: [1.1428571428571428, 1.0, 1.0]\n",
459
      "Converting ../data24/train/sagittal/0020.npy\n",
460
      "Number of slices for this scan: 30\n",
461
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
462
      "Converting ../data24/train/sagittal/0034.npy\n",
463
      "Number of slices for this scan: 40\n",
464
      "Interpolation factors for this scan: [0.6, 1.0, 1.0]\n",
465
      "Converting ../data24/train/sagittal/0008.npy\n",
466
      "Number of slices for this scan: 35\n",
467
      "Interpolation factors for this scan: [0.6857142857142857, 1.0, 1.0]\n",
468
      "Converting ../data24/train/sagittal/0009.npy\n",
469
      "Number of slices for this scan: 29\n",
470
      "Interpolation factors for this scan: [0.8275862068965517, 1.0, 1.0]\n",
471
      "Converting ../data24/train/sagittal/0035.npy\n",
472
      "Number of slices for this scan: 33\n",
473
      "Interpolation factors for this scan: [0.7272727272727273, 1.0, 1.0]\n",
474
      "Converting ../data24/train/sagittal/0021.npy\n",
475
      "Number of slices for this scan: 26\n",
476
      "Interpolation factors for this scan: [0.9230769230769231, 1.0, 1.0]\n"
477
     ]
478
    },
479
    {
480
     "name": "stdout",
481
     "output_type": "stream",
482
     "text": [
483
      "Converting ../data24/train/sagittal/0037.npy\n",
484
      "Number of slices for this scan: 24\n",
485
      "Interpolation factors for this scan: [1.0, 1.0, 1.0]\n",
486
      "Converting ../data24/train/sagittal/0023.npy\n",
487
      "Number of slices for this scan: 33\n",
488
      "Interpolation factors for this scan: [0.7272727272727273, 1.0, 1.0]\n",
489
      "Converting ../data24/train/sagittal/0022.npy\n",
490
      "Number of slices for this scan: 32\n",
491
      "Interpolation factors for this scan: [0.75, 1.0, 1.0]\n",
492
      "Converting ../data24/train/sagittal/0036.npy\n",
493
      "Number of slices for this scan: 26\n",
494
      "Interpolation factors for this scan: [0.9230769230769231, 1.0, 1.0]\n",
495
      "Converting ../data24/train/sagittal/0045.npy\n",
496
      "Number of slices for this scan: 36\n",
497
      "Interpolation factors for this scan: [0.6666666666666666, 1.0, 1.0]\n",
498
      "Converting ../data24/train/sagittal/0044.npy\n",
499
      "Number of slices for this scan: 26\n",
500
      "Interpolation factors for this scan: [0.9230769230769231, 1.0, 1.0]\n",
501
      "Converting ../data24/train/sagittal/0046.npy\n",
502
      "Number of slices for this scan: 20\n",
503
      "Interpolation factors for this scan: [1.2, 1.0, 1.0]\n",
504
      "Converting ../data24/train/sagittal/0047.npy\n",
505
      "Number of slices for this scan: 26\n",
506
      "Interpolation factors for this scan: [0.9230769230769231, 1.0, 1.0]\n",
507
      "Converting ../data24/train/sagittal/0043.npy\n",
508
      "Number of slices for this scan: 46\n",
509
      "Interpolation factors for this scan: [0.5217391304347826, 1.0, 1.0]\n",
510
      "Converting ../data24/train/sagittal/0042.npy\n",
511
      "Number of slices for this scan: 36\n",
512
      "Interpolation factors for this scan: [0.6666666666666666, 1.0, 1.0]\n",
513
      "Converting ../data24/train/sagittal/0040.npy\n",
514
      "Number of slices for this scan: 27\n",
515
      "Interpolation factors for this scan: [0.8888888888888888, 1.0, 1.0]\n",
516
      "Converting ../data24/train/sagittal/0041.npy\n",
517
      "Number of slices for this scan: 35\n",
518
      "Interpolation factors for this scan: [0.6857142857142857, 1.0, 1.0]\n",
519
      "Converting ../data24/train/sagittal/0049.npy\n",
520
      "Number of slices for this scan: 32\n",
521
      "Interpolation factors for this scan: [0.75, 1.0, 1.0]\n",
522
      "Converting ../data24/train/sagittal/0048.npy\n",
523
      "Number of slices for this scan: 28\n",
524
      "Interpolation factors for this scan: [0.8571428571428571, 1.0, 1.0]\n",
525
      "Converting ../data24/train/sagittal/0013.npy\n",
526
      "Number of slices for this scan: 32\n",
527
      "Interpolation factors for this scan: [0.75, 1.0, 1.0]\n",
528
      "Converting ../data24/train/sagittal/0007.npy\n",
529
      "Number of slices for this scan: 26\n",
530
      "Interpolation factors for this scan: [0.9230769230769231, 1.0, 1.0]\n",
531
      "Converting ../data24/train/sagittal/0006.npy\n",
532
      "Number of slices for this scan: 28\n",
533
      "Interpolation factors for this scan: [0.8571428571428571, 1.0, 1.0]\n",
534
      "Converting ../data24/train/sagittal/0012.npy\n",
535
      "Number of slices for this scan: 36\n",
536
      "Interpolation factors for this scan: [0.6666666666666666, 1.0, 1.0]\n",
537
      "Converting ../data24/train/sagittal/0038.npy\n",
538
      "Number of slices for this scan: 45\n",
539
      "Interpolation factors for this scan: [0.5333333333333333, 1.0, 1.0]\n",
540
      "Converting ../data24/train/sagittal/0004.npy\n",
541
      "Number of slices for this scan: 32\n",
542
      "Interpolation factors for this scan: [0.75, 1.0, 1.0]\n",
543
      "Converting ../data24/train/sagittal/0010.npy\n",
544
      "Number of slices for this scan: 38\n",
545
      "Interpolation factors for this scan: [0.631578947368421, 1.0, 1.0]\n",
546
      "Converting ../data24/train/sagittal/0011.npy\n",
547
      "Number of slices for this scan: 38\n",
548
      "Interpolation factors for this scan: [0.631578947368421, 1.0, 1.0]\n",
549
      "Converting ../data24/train/sagittal/0005.npy\n",
550
      "Number of slices for this scan: 37\n",
551
      "Interpolation factors for this scan: [0.6486486486486487, 1.0, 1.0]\n",
552
      "Converting ../data24/train/sagittal/0039.npy\n",
553
      "Number of slices for this scan: 32\n",
554
      "Interpolation factors for this scan: [0.75, 1.0, 1.0]\n",
555
      "Converting ../data24/train/sagittal/0001.npy\n",
556
      "Number of slices for this scan: 26\n",
557
      "Interpolation factors for this scan: [0.9230769230769231, 1.0, 1.0]\n",
558
      "Converting ../data24/train/sagittal/0015.npy\n",
559
      "Number of slices for this scan: 33\n",
560
      "Interpolation factors for this scan: [0.7272727272727273, 1.0, 1.0]\n",
561
      "Converting ../data24/train/sagittal/0029.npy\n",
562
      "Number of slices for this scan: 34\n",
563
      "Interpolation factors for this scan: [0.7058823529411765, 1.0, 1.0]\n",
564
      "Converting ../data24/train/sagittal/0028.npy\n",
565
      "Number of slices for this scan: 32\n",
566
      "Interpolation factors for this scan: [0.75, 1.0, 1.0]\n",
567
      "Converting ../data24/train/sagittal/0014.npy\n",
568
      "Number of slices for this scan: 20\n",
569
      "Interpolation factors for this scan: [1.2, 1.0, 1.0]\n",
570
      "Converting ../data24/train/sagittal/0000.npy\n",
571
      "Number of slices for this scan: 36\n",
572
      "Interpolation factors for this scan: [0.6666666666666666, 1.0, 1.0]\n",
573
      "Converting ../data24/train/sagittal/0016.npy\n",
574
      "Number of slices for this scan: 42\n",
575
      "Interpolation factors for this scan: [0.5714285714285714, 1.0, 1.0]\n",
576
      "Converting ../data24/train/sagittal/0002.npy\n",
577
      "Number of slices for this scan: 32\n",
578
      "Interpolation factors for this scan: [0.75, 1.0, 1.0]\n",
579
      "Converting ../data24/train/sagittal/0003.npy\n",
580
      "Number of slices for this scan: 30\n",
581
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
582
      "Converting ../data24/train/sagittal/0017.npy\n",
583
      "Number of slices for this scan: 26\n",
584
      "Interpolation factors for this scan: [0.9230769230769231, 1.0, 1.0]\n",
585
      "===============================\n",
586
      "===============================\n",
587
      "Found 20 .npy files in ../data24/valid/axial\n",
588
      "Converting ../data24/valid/axial/1139.npy\n",
589
      "Number of slices for this scan: 33\n",
590
      "Interpolation factors for this scan: [0.7272727272727273, 1.0, 1.0]\n",
591
      "Converting ../data24/valid/axial/1138.npy\n",
592
      "Number of slices for this scan: 28\n",
593
      "Interpolation factors for this scan: [0.8571428571428571, 1.0, 1.0]\n",
594
      "Converting ../data24/valid/axial/1148.npy\n",
595
      "Number of slices for this scan: 26\n",
596
      "Interpolation factors for this scan: [0.9230769230769231, 1.0, 1.0]\n",
597
      "Converting ../data24/valid/axial/1149.npy\n",
598
      "Number of slices for this scan: 29\n",
599
      "Interpolation factors for this scan: [0.8275862068965517, 1.0, 1.0]\n",
600
      "Converting ../data24/valid/axial/1144.npy\n",
601
      "Number of slices for this scan: 42\n",
602
      "Interpolation factors for this scan: [0.5714285714285714, 1.0, 1.0]\n",
603
      "Converting ../data24/valid/axial/1145.npy\n",
604
      "Number of slices for this scan: 36\n",
605
      "Interpolation factors for this scan: [0.6666666666666666, 1.0, 1.0]\n",
606
      "Converting ../data24/valid/axial/1147.npy\n",
607
      "Number of slices for this scan: 29\n",
608
      "Interpolation factors for this scan: [0.8275862068965517, 1.0, 1.0]\n",
609
      "Converting ../data24/valid/axial/1146.npy\n",
610
      "Number of slices for this scan: 24\n",
611
      "Interpolation factors for this scan: [1.0, 1.0, 1.0]\n",
612
      "Converting ../data24/valid/axial/1142.npy\n",
613
      "Number of slices for this scan: 37\n",
614
      "Interpolation factors for this scan: [0.6486486486486487, 1.0, 1.0]\n",
615
      "Converting ../data24/valid/axial/1143.npy\n",
616
      "Number of slices for this scan: 38\n",
617
      "Interpolation factors for this scan: [0.631578947368421, 1.0, 1.0]\n",
618
      "Converting ../data24/valid/axial/1141.npy\n",
619
      "Number of slices for this scan: 38\n",
620
      "Interpolation factors for this scan: [0.631578947368421, 1.0, 1.0]\n",
621
      "Converting ../data24/valid/axial/1140.npy\n",
622
      "Number of slices for this scan: 42\n",
623
      "Interpolation factors for this scan: [0.5714285714285714, 1.0, 1.0]\n",
624
      "Converting ../data24/valid/axial/1133.npy\n",
625
      "Number of slices for this scan: 25\n",
626
      "Interpolation factors for this scan: [0.96, 1.0, 1.0]\n",
627
      "Converting ../data24/valid/axial/1132.npy\n",
628
      "Number of slices for this scan: 24\n",
629
      "Interpolation factors for this scan: [1.0, 1.0, 1.0]\n",
630
      "Converting ../data24/valid/axial/1130.npy\n",
631
      "Number of slices for this scan: 25\n",
632
      "Interpolation factors for this scan: [0.96, 1.0, 1.0]\n",
633
      "Converting ../data24/valid/axial/1131.npy\n",
634
      "Number of slices for this scan: 28\n",
635
      "Interpolation factors for this scan: [0.8571428571428571, 1.0, 1.0]\n",
636
      "Converting ../data24/valid/axial/1135.npy\n",
637
      "Number of slices for this scan: 30\n",
638
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
639
      "Converting ../data24/valid/axial/1134.npy\n",
640
      "Number of slices for this scan: 31\n",
641
      "Interpolation factors for this scan: [0.7741935483870968, 1.0, 1.0]\n",
642
      "Converting ../data24/valid/axial/1136.npy\n",
643
      "Number of slices for this scan: 52\n",
644
      "Interpolation factors for this scan: [0.46153846153846156, 1.0, 1.0]\n",
645
      "Converting ../data24/valid/axial/1137.npy\n",
646
      "Number of slices for this scan: 23\n",
647
      "Interpolation factors for this scan: [1.0434782608695652, 1.0, 1.0]\n",
648
      "===============================\n",
649
      "===============================\n",
650
      "Found 20 .npy files in ../data24/valid/coronal\n",
651
      "Converting ../data24/valid/coronal/1139.npy\n",
652
      "Number of slices for this scan: 30\n",
653
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
654
      "Converting ../data24/valid/coronal/1138.npy\n",
655
      "Number of slices for this scan: 17\n",
656
      "Interpolation factors for this scan: [1.411764705882353, 1.0, 1.0]\n"
657
     ]
658
    },
659
    {
660
     "name": "stdout",
661
     "output_type": "stream",
662
     "text": [
663
      "Converting ../data24/valid/coronal/1148.npy\n",
664
      "Number of slices for this scan: 20\n",
665
      "Interpolation factors for this scan: [1.2, 1.0, 1.0]\n",
666
      "Converting ../data24/valid/coronal/1149.npy\n",
667
      "Number of slices for this scan: 20\n",
668
      "Interpolation factors for this scan: [1.2, 1.0, 1.0]\n",
669
      "Converting ../data24/valid/coronal/1144.npy\n",
670
      "Number of slices for this scan: 35\n",
671
      "Interpolation factors for this scan: [0.6857142857142857, 1.0, 1.0]\n",
672
      "Converting ../data24/valid/coronal/1145.npy\n",
673
      "Number of slices for this scan: 42\n",
674
      "Interpolation factors for this scan: [0.5714285714285714, 1.0, 1.0]\n",
675
      "Converting ../data24/valid/coronal/1147.npy\n",
676
      "Number of slices for this scan: 20\n",
677
      "Interpolation factors for this scan: [1.2, 1.0, 1.0]\n",
678
      "Converting ../data24/valid/coronal/1146.npy\n",
679
      "Number of slices for this scan: 21\n",
680
      "Interpolation factors for this scan: [1.1428571428571428, 1.0, 1.0]\n",
681
      "Converting ../data24/valid/coronal/1142.npy\n",
682
      "Number of slices for this scan: 34\n",
683
      "Interpolation factors for this scan: [0.7058823529411765, 1.0, 1.0]\n",
684
      "Converting ../data24/valid/coronal/1143.npy\n",
685
      "Number of slices for this scan: 36\n",
686
      "Interpolation factors for this scan: [0.6666666666666666, 1.0, 1.0]\n",
687
      "Converting ../data24/valid/coronal/1141.npy\n",
688
      "Number of slices for this scan: 30\n",
689
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
690
      "Converting ../data24/valid/coronal/1140.npy\n",
691
      "Number of slices for this scan: 39\n",
692
      "Interpolation factors for this scan: [0.6153846153846154, 1.0, 1.0]\n",
693
      "Converting ../data24/valid/coronal/1133.npy\n",
694
      "Number of slices for this scan: 22\n",
695
      "Interpolation factors for this scan: [1.0909090909090908, 1.0, 1.0]\n",
696
      "Converting ../data24/valid/coronal/1132.npy\n",
697
      "Number of slices for this scan: 24\n",
698
      "Interpolation factors for this scan: [1.0, 1.0, 1.0]\n",
699
      "Converting ../data24/valid/coronal/1130.npy\n",
700
      "Number of slices for this scan: 25\n",
701
      "Interpolation factors for this scan: [0.96, 1.0, 1.0]\n",
702
      "Converting ../data24/valid/coronal/1131.npy\n",
703
      "Number of slices for this scan: 22\n",
704
      "Interpolation factors for this scan: [1.0909090909090908, 1.0, 1.0]\n",
705
      "Converting ../data24/valid/coronal/1135.npy\n",
706
      "Number of slices for this scan: 30\n",
707
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
708
      "Converting ../data24/valid/coronal/1134.npy\n",
709
      "Number of slices for this scan: 30\n",
710
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
711
      "Converting ../data24/valid/coronal/1136.npy\n",
712
      "Number of slices for this scan: 34\n",
713
      "Interpolation factors for this scan: [0.7058823529411765, 1.0, 1.0]\n",
714
      "Converting ../data24/valid/coronal/1137.npy\n",
715
      "Number of slices for this scan: 21\n",
716
      "Interpolation factors for this scan: [1.1428571428571428, 1.0, 1.0]\n",
717
      "===============================\n",
718
      "===============================\n",
719
      "Found 20 .npy files in ../data24/valid/sagittal\n",
720
      "Converting ../data24/valid/sagittal/1139.npy\n",
721
      "Number of slices for this scan: 27\n",
722
      "Interpolation factors for this scan: [0.8888888888888888, 1.0, 1.0]\n",
723
      "Converting ../data24/valid/sagittal/1138.npy\n",
724
      "Number of slices for this scan: 22\n",
725
      "Interpolation factors for this scan: [1.0909090909090908, 1.0, 1.0]\n",
726
      "Converting ../data24/valid/sagittal/1148.npy\n",
727
      "Number of slices for this scan: 22\n",
728
      "Interpolation factors for this scan: [1.0909090909090908, 1.0, 1.0]\n",
729
      "Converting ../data24/valid/sagittal/1149.npy\n",
730
      "Number of slices for this scan: 24\n",
731
      "Interpolation factors for this scan: [1.0, 1.0, 1.0]\n",
732
      "Converting ../data24/valid/sagittal/1144.npy\n",
733
      "Number of slices for this scan: 38\n",
734
      "Interpolation factors for this scan: [0.631578947368421, 1.0, 1.0]\n",
735
      "Converting ../data24/valid/sagittal/1145.npy\n",
736
      "Number of slices for this scan: 40\n",
737
      "Interpolation factors for this scan: [0.6, 1.0, 1.0]\n",
738
      "Converting ../data24/valid/sagittal/1147.npy\n",
739
      "Number of slices for this scan: 26\n",
740
      "Interpolation factors for this scan: [0.9230769230769231, 1.0, 1.0]\n",
741
      "Converting ../data24/valid/sagittal/1146.npy\n",
742
      "Number of slices for this scan: 24\n",
743
      "Interpolation factors for this scan: [1.0, 1.0, 1.0]\n",
744
      "Converting ../data24/valid/sagittal/1142.npy\n",
745
      "Number of slices for this scan: 34\n",
746
      "Interpolation factors for this scan: [0.7058823529411765, 1.0, 1.0]\n",
747
      "Converting ../data24/valid/sagittal/1143.npy\n",
748
      "Number of slices for this scan: 34\n",
749
      "Interpolation factors for this scan: [0.7058823529411765, 1.0, 1.0]\n",
750
      "Converting ../data24/valid/sagittal/1141.npy\n",
751
      "Number of slices for this scan: 30\n",
752
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
753
      "Converting ../data24/valid/sagittal/1140.npy\n",
754
      "Number of slices for this scan: 41\n",
755
      "Interpolation factors for this scan: [0.5853658536585366, 1.0, 1.0]\n",
756
      "Converting ../data24/valid/sagittal/1133.npy\n",
757
      "Number of slices for this scan: 21\n",
758
      "Interpolation factors for this scan: [1.1428571428571428, 1.0, 1.0]\n",
759
      "Converting ../data24/valid/sagittal/1132.npy\n",
760
      "Number of slices for this scan: 24\n",
761
      "Interpolation factors for this scan: [1.0, 1.0, 1.0]\n",
762
      "Converting ../data24/valid/sagittal/1130.npy\n",
763
      "Number of slices for this scan: 27\n",
764
      "Interpolation factors for this scan: [0.8888888888888888, 1.0, 1.0]\n",
765
      "Converting ../data24/valid/sagittal/1131.npy\n",
766
      "Number of slices for this scan: 23\n",
767
      "Interpolation factors for this scan: [1.0434782608695652, 1.0, 1.0]\n",
768
      "Converting ../data24/valid/sagittal/1135.npy\n",
769
      "Number of slices for this scan: 30\n",
770
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
771
      "Converting ../data24/valid/sagittal/1134.npy\n",
772
      "Number of slices for this scan: 30\n",
773
      "Interpolation factors for this scan: [0.8, 1.0, 1.0]\n",
774
      "Converting ../data24/valid/sagittal/1136.npy\n",
775
      "Number of slices for this scan: 32\n",
776
      "Interpolation factors for this scan: [0.75, 1.0, 1.0]\n",
777
      "Converting ../data24/valid/sagittal/1137.npy\n",
778
      "Number of slices for this scan: 24\n",
779
      "Interpolation factors for this scan: [1.0, 1.0, 1.0]\n",
780
      "===============================\n",
781
      "===============================\n"
782
     ]
783
    }
784
   ],
785
   "source": [
786
    "slices = 24\n",
787
    "for d in ('train','valid'):\n",
788
    "    for p in ('axial','coronal','sagittal'):\n",
789
    "        dirpath = '../data{}/{}/{}'.format(slices, d, p)\n",
790
    "        npy_files = [f for f in os.listdir(dirpath) if f[-4:]=='.npy']\n",
791
    "        print('Found {} .npy files in {}'.format(len(npy_files), dirpath))\n",
792
    "\n",
793
    "        for f in npy_files:\n",
794
    "            filepath = dirpath + '/' + f\n",
795
    "            print('Converting {}'.format(filepath))\n",
796
    "            # load the array\n",
797
    "            scanarray = np.load(filepath)\n",
798
    "            # calculate interpolation factor(s)\n",
799
    "            print('Number of slices for this scan: {}'.format(scanarray.shape[0]))\n",
800
    "            interpolation_factors = [w/float(f) for w,f in zip([slices,256,256], scanarray.shape)]\n",
801
    "            print('Interpolation factors for this scan: {}'.format(interpolation_factors))\n",
802
    "            # interpolate/zoom\n",
803
    "            interpolated_scan = nd.interpolation.zoom(scanarray, zoom=interpolation_factors)\n",
804
    "            assert interpolated_scan.shape == (slices, 256, 256)\n",
805
    "            # write over old data (since working with copy of data)\n",
806
    "            np.save(filepath, interpolated_scan)\n",
807
    "        \n",
808
    "        print('===============================')\n",
809
    "        print('===============================')        "
810
   ]
811
  }
812
 ],
813
 "metadata": {
814
  "kernelspec": {
815
   "display_name": "Python 3",
816
   "language": "python",
817
   "name": "python3"
818
  },
819
  "language_info": {
820
   "codemirror_mode": {
821
    "name": "ipython",
822
    "version": 3
823
   },
824
   "file_extension": ".py",
825
   "mimetype": "text/x-python",
826
   "name": "python",
827
   "nbconvert_exporter": "python",
828
   "pygments_lexer": "ipython3",
829
   "version": "3.7.2"
830
  }
831
 },
832
 "nbformat": 4,
833
 "nbformat_minor": 2
834
}