"For most neuroimaging dataformats reading an image is as simple as calling `nibabel.load`."
]
},
{
...
...
@@ -49,10 +49,11 @@
"\n",
"# display header object\n",
"imhdr = imobj.header\n",
"print('header', imhdr)\n",
"\n",
"# extract data (as a numpy array)\n",
"imdat = imobj.get_fdata()\n",
"print(imdat.shape)"
"print('data', imdat.shape)"
]
},
{
...
...
@@ -152,6 +153,26 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"If you don't want to have to worry about the difference between `qform` and `sform`,\n",
"you can just let `nibabel` return what it thinks is the appropriate `affine`:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print('affine', imobj.affine) "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"> Note that we access the `affine` attribute from the image object here, not the image header (like above).\n",
"> Accessing the affine this way has the advantage that it will also work for data types, where the affine is stored in a different way in the header.\n",