08_fslpy.ipynb 69.5 KB
Newer Older
Paul McCarthy's avatar
Paul McCarthy committed
1
2
3
4
5
6
7
8
9
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# `fslpy`\n",
    "\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
10
11
12
13
    "**Important:** Portions of this practical require `fslpy` 2.9.0, due to be\n",
    "released with FSL 6.0.4, in Spring 2020.\n",
    "\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
14
15
    "[`fslpy`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/) is a\n",
    "Python library which is built into FSL, and contains a range of functionality\n",
Paul McCarthy's avatar
Paul McCarthy committed
16
    "for working with FSL and with neuroimaging data from Python.\n",
Paul McCarthy's avatar
Paul McCarthy committed
17
18
19
20
21
22
23
24
25
26
27
    "\n",
    "\n",
    "This practical highlights some of the most useful features provided by\n",
    "`fslpy`. You may find `fslpy` useful if you are writing Python code to\n",
    "perform analyses and image processing in conjunction with FSL.\n",
    "\n",
    "\n",
    "* [The `Image` class, and other data types](#the-image-class-and-other-data-types)\n",
    "  * [Creating images](#creating-images)\n",
    "  * [Working with image data](#working-with-image-data)\n",
    "  * [Loading other file types](#loading-other-file-types)\n",
Paul McCarthy's avatar
Paul McCarthy committed
28
    "  * [NIfTI coordinate systems](#nifti-coordinate-systems)\n",
29
    "  * [Transformations and resampling](#transformations-and-resampling)\n",
Paul McCarthy's avatar
Paul McCarthy committed
30
    "* [FSL wrapper functions](#fsl-wrapper-functions)\n",
Paul McCarthy's avatar
Paul McCarthy committed
31
32
33
    "  * [In-memory images](#in-memory-images)\n",
    "  * [Loading outputs into Python](#loading-outputs-into-python)\n",
    "  * [The `fslmaths` wrapper](#the-fslmaths-wrapper)\n",
Paul McCarthy's avatar
Paul McCarthy committed
34
35
36
37
38
    "* [The `FileTree`](#the-filetree)\n",
    "  * [Describing your data](#describing-your-data)\n",
    "  * [Using the `FileTree`](#using-the-filetree)\n",
    "  * [Building a processing pipeline with `FileTree`](#building-a-processing-pipeline-with-filetree)\n",
    "  * [The `FileTreeQuery`](#the-filetreequery)\n",
Paul McCarthy's avatar
Paul McCarthy committed
39
    "* [Calling shell commands](#calling-shell-commands)\n",
Paul McCarthy's avatar
Paul McCarthy committed
40
41
    "  * [The `runfsl` function](#the-runfsl-function)\n",
    "  * [Submitting to the cluster](#submitting-to-the-cluster)\n",
Paul McCarthy's avatar
Paul McCarthy committed
42
    "  * [Redirecting output](#redirecting-output)\n",
Paul McCarthy's avatar
Paul McCarthy committed
43
44
45
46
47
48
    "* [FSL atlases](#fsl-atlases)\n",
    "  * [Querying atlases](#querying-atlases)\n",
    "  * [Loading atlas images](#loading-atlas-images)\n",
    "  * [Working with atlases](#working-with-atlases)\n",
    "\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
49
50
51
52
53
    "> **Note**: `fslpy` is distinct from `fslpython` - `fslpython` is the Python\n",
    "> environment that is baked into FSL. `fslpy` is a Python library which is\n",
    "> installed into the `fslpython` environment.\n",
    "\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
    "Let's start with some standard imports and environment set-up:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "import os\n",
    "import os.path as op\n",
    "import nibabel as nib\n",
    "import numpy as np\n",
    "import warnings\n",
Paul McCarthy's avatar
Paul McCarthy committed
70
71
    "warnings.filterwarnings(\"ignore\")\n",
    "np.set_printoptions(suppress=True, precision=4)"
Paul McCarthy's avatar
Paul McCarthy committed
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And a little function that we can use to generate a simple orthographic plot:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
87
    "def ortho(data, voxel, fig=None, cursor=False, **kwargs):\n",
Paul McCarthy's avatar
Paul McCarthy committed
88
89
    "    \"\"\"Simple orthographic plot of a 3D array using matplotlib.\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
90
91
92
93
    "    :arg data:   3D numpy array\n",
    "    :arg voxel:  XYZ coordinates for each slice\n",
    "    :arg fig:    Existing figure and axes for overlay plotting\n",
    "    :arg cursor: Show a cursor at the `voxel`\n",
Paul McCarthy's avatar
Paul McCarthy committed
94
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
95
    "    All other arguments are passed through to the `imshow` function.\n",
Paul McCarthy's avatar
Paul McCarthy committed
96
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
97
    "    :returns:   The figure and orthogaxes (which can be passed back in as the\n",
Paul McCarthy's avatar
Paul McCarthy committed
98
99
    "                `fig` argument to plot overlays).\n",
    "    \"\"\"\n",
Paul McCarthy's avatar
Paul McCarthy committed
100
    "\n",
101
102
    "    voxel = [int(round(v)) for v in voxel]\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
103
104
105
    "    data            = np.asanyarray(data, dtype=np.float)\n",
    "    data[data <= 0] = np.nan\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
    "    x, y, z = voxel\n",
    "    xslice  = np.flipud(data[x, :, :].T)\n",
    "    yslice  = np.flipud(data[:, y, :].T)\n",
    "    zslice  = np.flipud(data[:, :, z].T)\n",
    "\n",
    "    if fig is None:\n",
    "        fig = plt.figure()\n",
    "        xax = fig.add_subplot(1, 3, 1)\n",
    "        yax = fig.add_subplot(1, 3, 2)\n",
    "        zax = fig.add_subplot(1, 3, 3)\n",
    "    else:\n",
    "        fig, xax, yax, zax = fig\n",
    "\n",
    "    xax.imshow(xslice, **kwargs)\n",
    "    yax.imshow(yslice, **kwargs)\n",
    "    zax.imshow(zslice, **kwargs)\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
123
124
125
126
127
128
129
130
131
    "    if cursor:\n",
    "        cargs = {'color' : (0, 1, 0), 'linewidth' : 1}\n",
    "        xax.axvline(                y, **cargs)\n",
    "        xax.axhline(data.shape[2] - z, **cargs)\n",
    "        yax.axvline(                x, **cargs)\n",
    "        yax.axhline(data.shape[2] - z, **cargs)\n",
    "        zax.axvline(                x, **cargs)\n",
    "        zax.axhline(data.shape[1] - y, **cargs)\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
    "    for ax in (xax, yax, zax):\n",
    "        ax.set_xticks([])\n",
    "        ax.set_yticks([])\n",
    "    fig.tight_layout(pad=0)\n",
    "\n",
    "    return (fig, xax, yax, zax)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And another function which uses FSLeyes for more complex plots:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def render(cmdline):\n",
Paul McCarthy's avatar
Paul McCarthy committed
154
155
156
157
    "\n",
    "    import shlex\n",
    "    import IPython.display as display\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
158
    "    prefix = '-of screenshot.png -hl -c 2 '\n",
Paul McCarthy's avatar
Paul McCarthy committed
159
160
161
162
163
164
165
166
167
168
169
170
    "\n",
    "    try:\n",
    "        from fsleyes.render import main\n",
    "        main(shlex.split(prefix + cmdline))\n",
    "\n",
    "    except ImportError:\n",
    "        # fall-back for macOS - we have to run\n",
    "        # FSLeyes render in a separate process\n",
    "        from fsl.utils.run import runfsl\n",
    "        prefix = 'render ' + prefix\n",
    "        runfsl(prefix + cmdline, env={})\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
171
172
173
174
175
176
177
    "    return display.Image('screenshot.png')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
    "<a class=\"anchor\" id=\"the-image-class-and-other-data-types\"></a>\n",
    "## The `Image` class, and other data types\n",
    "\n",
    "\n",
    "The\n",
    "[`fsl.data.image`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.image.html#fsl.data.image.Image)\n",
    "module provides the `Image` class, which sits on top of `nibabel` and contains\n",
    "some handy functionality if you need to work with coordinate transformations,\n",
    "or do some FSL-specific processing. The `Image` class provides features such\n",
    "as:\n",
    "\n",
    "- Support for NIFTI1, NIFTI2, and ANALYZE image files\n",
    "- Access to affine transformations between the voxel, FSL and world coordinate\n",
    "  systems\n",
    "- Ability to load metadata from BIDS sidecar files\n",
    "\n",
    "\n",
195
196
197
198
199
200
201
202
    "> The `Image` class behaves differently to the `nibabel.Nifti1Image`. For\n",
    "> example, when you create an `Image` object, the default behaviour is to load\n",
    "> the image data into memory. This is configurable however; take a look at\n",
    "> [the\n",
    "> documentation](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.image.html#fsl.data.image.Image)\n",
    "> to explore all of the options.\n",
    "\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
    "Some simple image processing routines are also provided - these are covered\n",
    "[below](#image-processing).\n",
    "\n",
    "\n",
    "<a class=\"anchor\" id=\"creating-images\"></a>\n",
    "### Creating images\n",
    "\n",
    "\n",
    "It's easy to create an `Image` - you can create one from a file name:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from fsl.data.image import Image\n",
    "\n",
    "stddir = op.expandvars('${FSLDIR}/data/standard/')\n",
    "\n",
    "# load a FSL image - the file\n",
    "# suffix is optional, just like\n",
    "# in real FSL-land!\n",
Paul McCarthy's avatar
Paul McCarthy committed
227
228
    "std1mm = Image(op.join(stddir, 'MNI152_T1_1mm'))\n",
    "print(std1mm)"
Paul McCarthy's avatar
Paul McCarthy committed
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can create an `Image` from an existing `nibabel` image:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# load a nibabel image, and\n",
    "# convert it into an FSL image\n",
    "nibimg = nib.load(op.join(stddir, 'MNI152_T1_1mm.nii.gz'))\n",
Paul McCarthy's avatar
Paul McCarthy committed
247
    "std1mm = Image(nibimg)"
Paul McCarthy's avatar
Paul McCarthy committed
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Or you can create an `Image` from a `numpy` array:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
263
    "data = np.zeros((182, 218, 182))\n",
Paul McCarthy's avatar
Paul McCarthy committed
264
265
266
    "img = Image(data, xform=np.eye(4))"
   ]
  },
Paul McCarthy's avatar
Paul McCarthy committed
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If you have generated some data from another `Image` (or from a\n",
    "`nibabel.Nifti1Image`) you can use the `header` option to set\n",
    "the header information on the new image:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "img = Image(data, header=std1mm.header)"
   ]
  },
Paul McCarthy's avatar
Paul McCarthy committed
285
286
287
288
289
290
291
292
293
294
295
296
297
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can save an image to file via the `save` method:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
298
299
    "img.save('empty')\n",
    "!ls"
Paul McCarthy's avatar
Paul McCarthy committed
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`Image` objects have all of the attributes you might expect:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "stddir = op.expandvars('${FSLDIR}/data/standard/')\n",
    "std1mm = Image(op.join(stddir, 'MNI152_T1_1mm'))\n",
    "\n",
    "print('name:         ', std1mm.name)\n",
    "print('file:         ', std1mm.dataSource)\n",
    "print('NIfTI version:', std1mm.niftiVersion)\n",
    "print('ndim:         ', std1mm.ndim)\n",
    "print('shape:        ', std1mm.shape)\n",
    "print('dtype:        ', std1mm.dtype)\n",
    "print('nvals:        ', std1mm.nvals)\n",
    "print('pixdim:       ', std1mm.pixdim)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "and a number of useful methods:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "std2mm  = Image(op.join(stddir, 'MNI152_T1_2mm'))\n",
Paul McCarthy's avatar
Paul McCarthy committed
342
    "mask2mm = Image(op.join(stddir, 'MNI152_T1_2mm_brain_mask'))\n",
Paul McCarthy's avatar
Paul McCarthy committed
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
    "\n",
    "print(std1mm.sameSpace(std2mm))\n",
    "print(std2mm.sameSpace(mask2mm))\n",
    "print(std2mm.getAffine('voxel', 'world'))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "An `Image` object is a high-level wrapper around a `nibabel` image object -\n",
    "you can always work directly with the `nibabel` object via the `nibImage`\n",
    "attribute:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(std2mm)\n",
    "print(std2mm.nibImage)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a class=\"anchor\" id=\"working-with-image-data\"></a>\n",
    "### Working with image data\n",
    "\n",
    "\n",
    "You can get the image data as a `numpy` array via the `data` attribute:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = std2mm.data\n",
Paul McCarthy's avatar
Paul McCarthy committed
386
387
    "print(data.min(), data.max())\n",
    "ortho(data, (45, 54, 45))"
Paul McCarthy's avatar
Paul McCarthy committed
388
389
390
391
392
393
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
394
395
    "> Note that `Image.data` will give you the data in its underlying type, unlike\n",
    "> the `nibabel.get_fdata` method, which up-casts image data to floating-point.\n",
Paul McCarthy's avatar
Paul McCarthy committed
396
397
398
399
400
401
402
403
404
405
406
407
    "\n",
    "\n",
    "You can also read and write data directly via the `Image` object:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "slc = std2mm[:, :, 45]\n",
Paul McCarthy's avatar
Paul McCarthy committed
408
    "std2mm[0:10, :, :] *= 2"
Paul McCarthy's avatar
Paul McCarthy committed
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Doing so has some advantages that may or may not be useful, depending on your\n",
    "use-case:\n",
    " - The image data will be kept on disk - only the parts that you access will\n",
    "   be loaded into RAM (you will also need to pass`loadData=False` when creating\n",
    "   the `Image` to achieve this).\n",
    " - The `Image` object will keep track of modifications to the data - this can\n",
    "   be queried via the `saveState` attribute.\n",
    "\n",
    "\n",
    "<a class=\"anchor\" id=\"loading-other-file-types\"></a>\n",
    "### Loading other file types\n",
    "\n",
    "\n",
    "The\n",
    "[`fsl.data`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.html#module-fsl.data)\n",
    "package has a number of other classes for working with different types of FSL\n",
    "and neuroimaging data. Most of these are higher-level wrappers around the\n",
    "corresponding `nibabel` types:\n",
    "\n",
    "* The\n",
    "  [`fsl.data.bitmap.Bitmap`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.bitmap.html)\n",
Paul McCarthy's avatar
Paul McCarthy committed
436
    "  class can be used to load a bitmap image (e.g. `jpg`, `png`, etc) and\n",
Paul McCarthy's avatar
Paul McCarthy committed
437
438
439
440
441
442
    "  convert it to a NIfTI image.\n",
    "* The\n",
    "  [`fsl.data.dicom.DicomImage`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.dicom.html)\n",
    "  class uses `dcm2niix` to load NIfTI images contained within a DICOM\n",
    "  directory<sup>*</sup>.\n",
    "* The\n",
Paul McCarthy's avatar
Paul McCarthy committed
443
    "  [`fsl.data.mghimage.MGHImage`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.mghimage.html)\n",
Paul McCarthy's avatar
Paul McCarthy committed
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
    "  class can be used too load `.mgh`/`.mgz` images (they are converted into\n",
    "  NIfTI images).\n",
    "* The\n",
    "  [`fsl.data.dtifit`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.dtifit.html)\n",
    "  module contains functions for loading and working with the output of the\n",
    "  FSL `dtifit` tool.\n",
    "* The\n",
    "  [`fsl.data.featanalysis`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.featanalysis.html),\n",
    "  [`fsl.data.featimage`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.featimage.html),\n",
    "  and\n",
    "  [`fsl.data.featdesign`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.featdesign.html)\n",
    "  modules contain classes and functions for loading data from FEAT\n",
    "  directories.\n",
    "* Similarly, the\n",
    "  [`fsl.data.melodicanalysis`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.melodicanalysis.html)\n",
    "  and\n",
    "  [`fsl.data.melodicimage`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.melodicimage.html)\n",
    "  modules contain classes and functions for loading data from MELODIC\n",
    "  directories.\n",
    "* The\n",
    "  [`fsl.data.gifti`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.gifti.html),\n",
    "  [`fsl.data.freesurfer`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.freesurfer.html),\n",
    "  and\n",
    "  [`fsl.data.vtk`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.vtk.html)\n",
    "  modules contain functionality form loading surface data from GIfTI,\n",
Paul McCarthy's avatar
Paul McCarthy committed
469
    "  freesurfer, and ASCII VTK files respectively.\n",
Paul McCarthy's avatar
Paul McCarthy committed
470
471
    "\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
472
473
474
    "> <sup>*</sup>You must make sure that\n",
    "> [`dcm2niix`](https://github.com/rordenlab/dcm2niix/) is installed on your\n",
    "> system in order to use this class.\n",
Paul McCarthy's avatar
Paul McCarthy committed
475
476
    "\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
477
478
    "<a class=\"anchor\" id=\"nifti-coordinate-systems\"></a>\n",
    "### NIfTI coordinate systems\n",
Paul McCarthy's avatar
Paul McCarthy committed
479
480
    "\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
    "The `Image.getAffine` method gives you access to affine transformations which\n",
    "can be used to convert coordinates between the different coordinate systems\n",
    "associated with a NIfTI image. Have some MNI coordinates you'd like to convert\n",
    "to voxels? Easy!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "stddir = op.expandvars('${FSLDIR}/data/standard/')\n",
    "std2mm = Image(op.join(stddir, 'MNI152_T1_2mm'))\n",
    "\n",
    "mnicoords = np.array([[0,   0,  0],\n",
    "                      [0, -18, 18]])\n",
Paul McCarthy's avatar
Paul McCarthy committed
498
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
499
500
    "world2vox = std2mm.getAffine('world', 'voxel')\n",
    "vox2world = std2mm.getAffine('voxel', 'world')\n",
Paul McCarthy's avatar
Paul McCarthy committed
501
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
502
503
    "# Apply the world->voxel\n",
    "# affine to the coordinates\n",
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
    "voxcoords = (np.dot(world2vox[:3, :3], mnicoords.T)).T + world2vox[:3, 3]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The code above is a bit fiddly, so instead of figuring it out, you can just\n",
    "use the\n",
    "[`affine.transform`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.transform.affine.html#fsl.transform.affine.transform)\n",
    "function:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
523
    "from fsl.transform.affine import transform\n",
524
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
    "voxcoords = transform(mnicoords, world2vox)\n",
    "\n",
    "# just to double check, let's transform\n",
    "# those voxel coordinates back into world\n",
    "# coordinates\n",
    "backtomni = transform(voxcoords, vox2world)\n",
    "\n",
    "for m, v, b in zip(mnicoords, voxcoords, backtomni):\n",
    "    print(m, '->', v, '->', b)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> The `Image.getAffine` method can give you transformation matrices\n",
    "> between any of these coordinate systems:\n",
    ">\n",
    ">  - `'voxel'`: Image data voxel coordinates\n",
    ">  - `'world'`: mm coordinates, defined by the sform/qform of an image\n",
    ">  - `'fsl'`: The FSL coordinate system, used internally by many FSL tools\n",
    ">    (e.g. FLIRT)\n",
    "\n",
    "\n",
    "Oh, that example was too easy I hear you say? Try this one on for size. Let's\n",
    "say we have run FEAT on some task fMRI data, and want to get the MNI\n",
    "coordinates of the voxel with peak activation.\n",
    "\n",
    "\n",
    "> This is what people used to use `Featquery` for, back in the un-enlightened\n",
    "> days.\n",
    "\n",
    "\n",
    "Let's start by identifying the voxel with the biggest t-statistic:"
Paul McCarthy's avatar
Paul McCarthy committed
559
560
561
562
563
564
565
566
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
567
    "featdir = op.join('08_fslpy', 'fmri.feat')\n",
Paul McCarthy's avatar
Paul McCarthy committed
568
569
570
571
572
573
574
575
576
577
578
    "\n",
    "tstat1 = Image(op.join(featdir, 'stats', 'tstat1')).data\n",
    "\n",
    "# Recall from the numpy practical that\n",
    "# argmax gives us a 1D index into a\n",
    "# flattened view of the array. We can\n",
    "# use the unravel_index function to\n",
    "# convert it into a 3D index.\n",
    "peakvox = np.abs(tstat1).argmax()\n",
    "peakvox = np.unravel_index(peakvox, tstat1.shape)\n",
    "print('Peak voxel coordinates for tstat1:', peakvox, tstat1[peakvox])"
Paul McCarthy's avatar
Paul McCarthy committed
579
580
581
582
583
584
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
585
586
587
    "Now that we've got the voxel coordinates in functional space, we need to\n",
    "transform them into MNI space. FEAT provides a transformation which goes\n",
    "directly from functional to standard space, in the `reg` directory:"
Paul McCarthy's avatar
Paul McCarthy committed
588
589
590
591
592
593
594
595
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
596
    "func2std = np.loadtxt(op.join(featdir, 'reg', 'example_func2standard.mat'))"
Paul McCarthy's avatar
Paul McCarthy committed
597
598
599
600
601
602
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
603
604
605
606
607
608
    "But ... wait a minute ... this is a FLIRT matrix! We can't just plug voxel\n",
    "coordinates into a FLIRT matrix and expect to get sensible results, because\n",
    "FLIRT works in an internal FSL coordinate system, which is not quite\n",
    "`'voxel'`, and not quite `'world'`. So we need to do a little more work.\n",
    "Let's start by loading our functional image, and the MNI152 template (the\n",
    "source and reference images of our FLIRT matrix):"
Paul McCarthy's avatar
Paul McCarthy committed
609
610
611
612
613
614
615
616
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
617
618
    "func = Image(op.join(featdir, 'reg', 'example_func'))\n",
    "std  = Image(op.expandvars(op.join('$FSLDIR', 'data', 'standard', 'MNI152_T1_2mm')))"
Paul McCarthy's avatar
Paul McCarthy committed
619
620
621
622
623
624
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
625
626
627
628
629
630
631
    "Now we can use them to get affines which convert between all of the different\n",
    "coordinate systems - we're going to combine them into a single uber-affine,\n",
    "which transforms our functional-space voxels into MNI world coordinates via:\n",
    "\n",
    "   1. functional voxels -> FLIRT source space\n",
    "   2. FLIRT source space -> FLIRT reference space\n",
    "   3. FLIRT referece space -> MNI world coordinates"
Paul McCarthy's avatar
Paul McCarthy committed
632
633
634
635
636
637
638
639
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
640
641
    "vox2fsl = func.getAffine('voxel', 'fsl')\n",
    "fsl2mni = std .getAffine('fsl',   'world')"
Paul McCarthy's avatar
Paul McCarthy committed
642
643
644
645
646
647
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
648
649
    "Combining two affines into one is just a simple dot-product. There is a\n",
    "`concat()` function which does this for us, for any number of affines:"
Paul McCarthy's avatar
Paul McCarthy committed
650
651
652
653
654
655
656
657
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
658
    "from fsl.transform.affine import concat\n",
Paul McCarthy's avatar
Paul McCarthy committed
659
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
660
661
662
    "# To combine affines together, we\n",
    "# have to list them in reverse -\n",
    "# linear algebra is *weird*.\n",
Paul McCarthy's avatar
Paul McCarthy committed
663
664
    "funcvox2mni = concat(fsl2mni, func2std, vox2fsl)\n",
    "print(funcvox2mni)"
Paul McCarthy's avatar
Paul McCarthy committed
665
666
667
668
669
670
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
671
    "> In the next section we will use the\n",
Paul McCarthy's avatar
Paul McCarthy committed
672
673
674
675
    "> [`fsl.transform.flirt.fromFlirt`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.transform.flirt.html#fsl.transform.flirt.fromFlirt)\n",
    "> function, which does all of the above for us.\n",
    "\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
676
677
    "So we've now got some voxel coordinates from our functional data, and an\n",
    "affine to transform into MNI world coordinates. The rest is easy:"
Paul McCarthy's avatar
Paul McCarthy committed
678
679
680
681
682
683
684
685
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
686
687
688
689
690
    "mnicoords = transform(peakvox, funcvox2mni)\n",
    "mnivoxels = transform(mnicoords, std.getAffine('world', 'voxel'))\n",
    "mnivoxels = [int(round(v)) for v in mnivoxels]\n",
    "print('Peak activation (MNI coordinates):', mnicoords)\n",
    "print('Peak activation (MNI voxels):     ', mnivoxels)"
Paul McCarthy's avatar
Paul McCarthy committed
691
692
693
694
695
696
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
697
698
699
700
    "Note that in the above example we are only applying a linear transformation\n",
    "into MNI space - in reality you would also want to apply your non-linear\n",
    "structural-to-standard transformation too. This is covered in the next\n",
    "section.\n",
Paul McCarthy's avatar
Paul McCarthy committed
701
702
    "\n",
    "\n",
703
704
    "<a class=\"anchor\" id=\"transformations-and-resampling\"></a>\n",
    "### Transformations and resampling\n",
Paul McCarthy's avatar
Paul McCarthy committed
705
706
707
708
709
710
711
712
    "\n",
    "\n",
    "Now, it's all well and good to look at t-statistic values and voxel\n",
    "coordinates and so on and so forth, but let's spice things up a bit and look\n",
    "at some images. Let's display our peak activation location in MNI space. To do\n",
    "this, we're going to resample our functional image into MNI space, so we can\n",
    "overlay it on the MNI template. This can be done using some handy functions\n",
    "from the\n",
713
714
    "[`fsl.transform.flirt`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.transform.flirt.html)\n",
    "and\n",
Paul McCarthy's avatar
Paul McCarthy committed
715
    "[`fsl.utils.image.resample`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.utils.image.resample.html)\n",
716
717
718
719
    "modules.\n",
    "\n",
    "\n",
    "Let's make sure we've got our source and reference images loaded:"
Paul McCarthy's avatar
Paul McCarthy committed
720
721
722
723
724
725
726
727
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
728
729
    "featdir = op.join(op.join('08_fslpy', 'fmri.feat'))\n",
    "tstat1  = Image(op.join(featdir, 'stats', 'tstat1'))\n",
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
    "std     = Image(op.expandvars(op.join('$FSLDIR', 'data', 'standard', 'MNI152_T1_2mm')))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we'll load the `example_func2standard` FLIRT matrix, and adjust it so that\n",
    "it transforms from functional *world* coordinates into standard *world*\n",
    "coordinates - this is what is expected by the `resampleToReference` function,\n",
    "used below:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from fsl.transform.flirt import fromFlirt\n",
Paul McCarthy's avatar
Paul McCarthy committed
750
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
751
    "func2std = np.loadtxt(op.join(featdir, 'reg', 'example_func2standard.mat'))\n",
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
    "func2std = fromFlirt(func2std, tstat1, std, 'world', 'world')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we can use `resampleToReference` to resample our functional data into\n",
    "MNI152 space. This function returns a `numpy` array containing the resampled\n",
    "data, and an adjusted voxel-to-world affine transformation. But in this case,\n",
    "we know that the data will be aligned to MNI152, so we can ignore the affine:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from fsl.utils.image.resample import resampleToReference\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
773
774
    "std_tstat1 = resampleToReference(tstat1, std, func2std)[0]\n",
    "std_tstat1 = Image(std_tstat1, header=std.header)"
Paul McCarthy's avatar
Paul McCarthy committed
775
776
777
778
779
780
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
781
782
    "Now that we have our t-statistic image in MNI152 space, we can plot it in\n",
    "standard space using `matplotlib`:"
Paul McCarthy's avatar
Paul McCarthy committed
783
784
785
786
787
788
789
790
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
791
792
    "stddir = op.expandvars('${FSLDIR}/data/standard/')\n",
    "std2mm = Image(op.join(stddir, 'MNI152_T1_2mm'))\n",
Paul McCarthy's avatar
Paul McCarthy committed
793
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
794
795
    "std_tstat1                 = std_tstat1.data\n",
    "std_tstat1[std_tstat1 < 3] = 0\n",
Paul McCarthy's avatar
Paul McCarthy committed
796
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
797
    "fig = ortho(std2mm.data, mnivoxels, cmap=plt.cm.gray)\n",
Paul McCarthy's avatar
Paul McCarthy committed
798
    "fig = ortho(std_tstat1,  mnivoxels, cmap=plt.cm.inferno, fig=fig, cursor=True)"
Paul McCarthy's avatar
Paul McCarthy committed
799
800
   ]
  },
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the example above, we resampled some data from functional space into\n",
    "standard space using a linear transformation. But we all know that this is not\n",
    "how things work in the real world - linear transformations are for kids. The\n",
    "real world is full of lions and tigers and bears and warp fields.\n",
    "\n",
    "\n",
    "The\n",
    "[`fsl.transform.fnirt`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.transform.fnirt.html#fsl.transform.fnirt.fromFnirt)\n",
    "and\n",
    "[`fsl.transform.nonlinear`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.transform.nonlinear.html)\n",
    "modules contain classes and functions for working with FNIRT-style warp fields\n",
    "(modules for working with lions, tigers, and bears are still under\n",
    "development).\n",
    "\n",
    "\n",
    "Let's imagine that we have defined an ROI in MNI152 space, and we want to\n",
    "project it into the space of our functional data.  We can do this by combining\n",
    "the nonlinear structural to standard registration produced by FNIRT with the\n",
    "linear functional to structural registration generated by FLIRT.  First of\n",
    "all, we'll load images from each of the functional, structural, and standard\n",
    "spaces:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "featdir = op.join('08_fslpy', 'fmri.feat')\n",
    "func    = Image(op.join(featdir, 'reg', 'example_func'))\n",
    "struc   = Image(op.join(featdir, 'reg', 'highres'))\n",
    "std     = Image(op.expandvars(op.join('$FSLDIR', 'data', 'standard', 'MNI152_T1_2mm')))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, let's say we have obtained our seed location in MNI152 coordinates. Let's\n",
    "convert them to MNI152 voxels just to double check:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "seedmni    = [-48, -74, -9]\n",
    "seedmnivox = transform(seedmni, std.getAffine('world', 'voxel'))\n",
    "ortho(std.data, seedmnivox, cursor=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we'll load the FNIRT warp field, which encodes a nonlinear transformation\n",
    "from structural space to standard space. FNIRT warp fields are often stored as\n",
    "*coefficient* fields to reduce the file size, but in order to use it, we must\n",
    "convert the coefficient field into a *deformation* (a.k.a. *displacement*)\n",
    "field. This takes a few seconds:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from fsl.transform.fnirt     import readFnirt\n",
    "from fsl.transform.nonlinear import coefficientFieldToDeformationField\n",
    "\n",
    "struc2std = readFnirt(op.join(featdir, 'reg', 'highres2standard_warp'), struc, std)\n",
    "struc2std = coefficientFieldToDeformationField(struc2std)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We'll also load our FLIRT functional to structural transformation, adjust it\n",
    "so that it transforms between voxel coordinate systems instead of the FSL\n",
    "coordinate system, and invert so it can transform from structural voxels to\n",
    "functional voxels:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from fsl.transform.affine import invert\n",
    "func2struc = np.loadtxt(op.join(featdir, 'reg', 'example_func2highres.mat'))\n",
    "func2struc = fromFlirt(func2struc, func, struc, 'voxel', 'voxel')\n",
    "struc2func = invert(func2struc)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we can transform our seed coordinates from MNI152 space into functional\n",
    "space in two stages. First, we'll use our deformation field to transform from\n",
    "MNI152 space into structural space:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
920
    "seedstruc = struc2std.transform(seedmni, 'world', 'voxel')\n",
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
    "seedfunc  = transform(seedstruc, struc2func)\n",
    "\n",
    "print('Seed location in MNI coordinates:  ', seedmni)\n",
    "print('Seed location in functional voxels:', seedfunc)\n",
    "ortho(func.data, seedfunc, cursor=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> FNIRT warp fields kind of work backwards - we can use them to transform\n",
    "> reference coordinates into source coordinates, but would need to invert the\n",
    "> warp field using `invwarp` if we wanted to transform from source coordinates\n",
    "> into referemce coordinates.\n",
    "\n",
    "\n",
    "Of course, we can also use our deformation field to resample an image from\n",
    "structural space into MNI152 space. The `applyDeformation` function takes an\n",
    "`Image` and a `DeformationField`, and returns a `numpy` array containing the\n",
    "resampled data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from fsl.transform.nonlinear import applyDeformation\n",
    "\n",
    "strucmni = applyDeformation(struc, struc2std)\n",
    "\n",
    "# remove low-valued voxels,\n",
    "# just for visualisation below\n",
    "strucmni[strucmni < 1] = 0\n",
    "\n",
    "fig = ortho(std.data, [45, 54, 45], cmap=plt.cm.gray)\n",
    "fig = ortho(strucmni, [45, 54, 45], fig=fig)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The `premat` option to `applyDeformation` can be used to specify our linear\n",
    "functional to structural transformation, and hence resample a functional image\n",
    "into MNI152 space:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "tstatmni = applyDeformation(tstat1, struc2std, premat=func2struc)\n",
    "tstatmni[tstatmni < 3] = 0\n",
    "\n",
    "fig = ortho(std.data, [45, 54, 45], cmap=plt.cm.gray)\n",
    "fig = ortho(tstatmni, [45, 54, 45], fig=fig)"
   ]
  },
Paul McCarthy's avatar
Paul McCarthy committed
984
985
986
987
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
Paul McCarthy's avatar
Paul McCarthy committed
988
    "There are a few other useful functions tucked away in the\n",
989
990
991
992
    "[`fsl.utils.image`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.utils.image.html)\n",
    "and\n",
    "[`fsl.transform`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.transform.html)\n",
    "packages, with more to be added in the future.\n",
Paul McCarthy's avatar
Paul McCarthy committed
993
994
    "\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
995
996
997
998
    "<a class=\"anchor\" id=\"fsl-wrapper-functions\"></a>\n",
    "## FSL wrapper functions\n",
    "\n",
    "\n",
Paul McCarthy's avatar
Paul McCarthy committed
999
1000
    "The\n",
    "[fsl.wrappers](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.wrappers.html)\n",
For faster browsing, not all history is shown. View entire blame