From 30e8c66178e66e363a1ae721dcc960265302797b Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Tue, 24 Mar 2020 22:22:01 +0000 Subject: [PATCH] RF: little tweaks --- advanced_topics/08_fslpy.ipynb | 16 +++++++++++----- advanced_topics/08_fslpy.md | 12 +++++++++--- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/advanced_topics/08_fslpy.ipynb b/advanced_topics/08_fslpy.ipynb index acda784..546c1f7 100644 --- a/advanced_topics/08_fslpy.ipynb +++ b/advanced_topics/08_fslpy.ipynb @@ -67,7 +67,8 @@ "import nibabel as nib\n", "import numpy as np\n", "import warnings\n", - "warnings.filterwarnings(\"ignore\")" + "warnings.filterwarnings(\"ignore\")\n", + "np.set_printoptions(suppress=True, precision=4)" ] }, { @@ -432,7 +433,7 @@ "\n", "* The\n", " [`fsl.data.bitmap.Bitmap`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.bitmap.html)\n", - " class can be used to load a bitmap image (e.g. `jpg, `png`, etc) and\n", + " class can be used to load a bitmap image (e.g. `jpg`, `png`, etc) and\n", " 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", @@ -659,7 +660,8 @@ "# To combine affines together, we\n", "# have to list them in reverse -\n", "# linear algebra is *weird*.\n", - "funcvox2mni = concat(fsl2mni, func2std, vox2fsl)" + "funcvox2mni = concat(fsl2mni, func2std, vox2fsl)\n", + "print(funcvox2mni)" ] }, { @@ -915,7 +917,7 @@ "metadata": {}, "outputs": [], "source": [ - "seedstruc = struc2std.transform([seedmni], 'world', 'voxel')[0]\n", + "seedstruc = struc2std.transform(seedmni, 'world', 'voxel')\n", "seedfunc = transform(seedstruc, struc2func)\n", "\n", "print('Seed location in MNI coordinates: ', seedmni)\n", @@ -1015,7 +1017,7 @@ "metadata": {}, "outputs": [], "source": [ - "from fsl.wrappers import bet, robustfov, LOAD\n", + "from fsl.wrappers import robustfov\n", "\n", "robustfov('08_fslpy/bighead', 'bighead_cropped')\n", "\n", @@ -1059,6 +1061,8 @@ "metadata": {}, "outputs": [], "source": [ + "from fsl.wrappers import bet\n", + "\n", "bet('bighead_cropped', 'bighead_cropped_brain', f=0.3, m=True, s=True)\n", "\n", "render('bighead_cropped -b 40 '\n", @@ -1132,6 +1136,8 @@ "metadata": {}, "outputs": [], "source": [ + "from fsl.wrappers import LOAD\n", + "\n", "cropped = Image('bighead_cropped')\n", "\n", "# The loaded result is called \"output\",\n", diff --git a/advanced_topics/08_fslpy.md b/advanced_topics/08_fslpy.md index b8fb3b2..043dfab 100644 --- a/advanced_topics/08_fslpy.md +++ b/advanced_topics/08_fslpy.md @@ -57,6 +57,7 @@ import nibabel as nib import numpy as np import warnings warnings.filterwarnings("ignore") +np.set_printoptions(suppress=True, precision=4) ``` @@ -321,7 +322,7 @@ corresponding `nibabel` types: * The [`fsl.data.bitmap.Bitmap`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.bitmap.html) - class can be used to load a bitmap image (e.g. `jpg, `png`, etc) and + class can be used to load a bitmap image (e.g. `jpg`, `png`, etc) and convert it to a NIfTI image. * The [`fsl.data.dicom.DicomImage`](https://users.fmrib.ox.ac.uk/~paulmc/fsleyes/fslpy/latest/fsl.data.dicom.html) @@ -496,6 +497,7 @@ from fsl.transform.affine import concat # have to list them in reverse - # linear algebra is *weird*. funcvox2mni = concat(fsl2mni, func2std, vox2fsl) +print(funcvox2mni) ``` > In the next section we will use the @@ -668,7 +670,7 @@ MNI152 space into structural space: ``` -seedstruc = struc2std.transform([seedmni], 'world', 'voxel')[0] +seedstruc = struc2std.transform(seedmni, 'world', 'voxel') seedfunc = transform(seedstruc, struc2func) print('Seed location in MNI coordinates: ', seedmni) @@ -744,7 +746,7 @@ corresponding tool via the command-line: ``` -from fsl.wrappers import bet, robustfov, LOAD +from fsl.wrappers import robustfov robustfov('08_fslpy/bighead', 'bighead_cropped') @@ -780,6 +782,8 @@ positional arguments, and pass the additional options as keyword arguments: ``` +from fsl.wrappers import bet + bet('bighead_cropped', 'bighead_cropped_brain', f=0.3, m=True, s=True) render('bighead_cropped -b 40 ' @@ -837,6 +841,8 @@ files produced by the tool automatically loaded into memory for you: ``` +from fsl.wrappers import LOAD + cropped = Image('bighead_cropped') # The loaded result is called "output", -- GitLab