Skip to content

Commit

Permalink
add note about python and bart
Browse files Browse the repository at this point in the history
  • Loading branch information
jtamir committed Oct 15, 2018
1 parent 9bd722f commit 4e9eee9
Showing 1 changed file with 38 additions and 7 deletions.
45 changes: 38 additions & 7 deletions demos/gfactor-demo/gfactor-demo-real_data.ipynb
Expand Up @@ -36,7 +36,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import numpy as np\n",
Expand All @@ -53,6 +55,22 @@
"rcParams['figure.figsize'] = 7, 7"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Running BART commands in Python\n",
"As of v0.4.03, BART commands are run with the python module under `bart/python/bart.py`. This module writes data to disk with `cfl.writecfl`, runs a bart command in the shell, and then loads the result with `cfl.readcfl`. This leads to large writes to disk, which can be slow. It is suggested to make a RAM disk to speed this up.\n",
"\n",
"Alternatively, the master branch has an experimental interface called `pyBART`, which does not write to disk. However, it is not yet in a finished state.\n",
"\n",
"After importing bart, commands are run like this:\n",
"```python\n",
"out1, out2, out3 = bart(3, 'command -x arg1 -y arg2 -z arg3', input1, input2)\n",
"```\n",
"Here, the first argument tells bart that three outputs are returned. The second argument is the actual command. The later arguments are the numpy files that the command will use. When running the commands, output will be seen in the terminal/notebook shell."
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -64,7 +82,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"print('loading data')\n",
Expand Down Expand Up @@ -105,7 +125,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"noise_flat = np.reshape(noise, (-1, nc))\n",
Expand Down Expand Up @@ -152,7 +174,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"assert np.linalg.norm(mask - (np.linalg.norm(ksp, axis=2) != 0)) < 1E-5, 'mask does not match data!'\n",
Expand All @@ -175,7 +199,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"reco = bart(1, 'pics -S -i 150', ksp[:,:,None,:], sens[:,:,None,:])\n",
Expand Down Expand Up @@ -221,6 +247,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"scrolled": true
},
"outputs": [],
Expand Down Expand Up @@ -253,7 +280,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"recons_noise = np.zeros((nx, ny, n_mc), dtype=np.complex)\n",
Expand All @@ -279,7 +308,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"recons_std = np.std(recons.real, axis=2)\n",
Expand Down

0 comments on commit 4e9eee9

Please sign in to comment.