Added subspace reco.

This commit is contained in:
jupfi 2024-07-15 14:26:22 +02:00
parent 93df93f12b
commit 7ee78882d7

View file

@ -130,7 +130,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"id": "5abe217f-02ba-4ca4-9de2-7862af2d0ce6",
"metadata": {},
"outputs": [
@ -139,9 +139,9 @@
"output_type": "stream",
"text": [
"# The BART used in this notebook:\n",
"/home/jpfitzer/bart-0.9.00/bart\n",
"/home/jpfitzer/git/bart/bart\n",
"# BART version: \n",
"v0.9.00\n"
"v0.9.00-425-g169d805\n"
]
}
],
@ -215,7 +215,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 4,
"id": "c60a8e73-8a0b-4cb8-9724-891d860307e4",
"metadata": {},
"outputs": [
@ -224,7 +224,7 @@
"output_type": "stream",
"text": [
"# The BART viewer used in this notebook:\n",
"/usr/bin/view\n"
"/home/jpfitzer/git/view/view\n"
]
}
],
@ -245,7 +245,7 @@
},
{
"cell_type": "code",
"execution_count": 151,
"execution_count": 11,
"id": "f7b7800e-8a4c-4852-b94c-2b47cd4a52de",
"metadata": {},
"outputs": [],
@ -378,7 +378,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 12,
"id": "f1883fa9-f260-47a3-9598-474905d10f89",
"metadata": {},
"outputs": [
@ -428,7 +428,7 @@
},
{
"cell_type": "code",
"execution_count": 208,
"execution_count": 13,
"id": "96b28fec-ff5a-44a3-8a0c-9b01b60cff0c",
"metadata": {},
"outputs": [],
@ -447,7 +447,7 @@
},
{
"cell_type": "code",
"execution_count": 209,
"execution_count": 14,
"id": "5f93fcca-48ab-4d42-9061-91361aadfb35",
"metadata": {},
"outputs": [
@ -473,6 +473,19 @@
"DIM_Z=16"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "77d36186-04bb-422d-9ec3-a2032fcbceda",
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"# Correct dimension\n",
"bart transpose 0 2 data/kSpace data/ksp\n",
"bart transpose 3 5 data/ksp data/ksp"
]
},
{
"cell_type": "markdown",
"id": "188249e4-dbbb-4f7b-9d28-e28338de14c3",
@ -663,6 +676,22 @@
"bart invert data/R2_map data/T2_map "
]
},
{
"cell_type": "markdown",
"id": "9b49f422-7373-4f2e-8994-872c4bcd1622",
"metadata": {},
"source": [
"## 2.3 PICS Reco Fully Sampled Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a0a45c91-da70-4fdf-b1ab-a35b5d92b63c",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "f8d7d303-2747-4f41-bf5d-153bc83f2382",
@ -1033,7 +1062,7 @@
},
{
"cell_type": "code",
"execution_count": 246,
"execution_count": 32,
"id": "0882a788-ecd2-4968-9715-a57816d66e9c",
"metadata": {},
"outputs": [
@ -1088,7 +1117,7 @@
},
{
"cell_type": "code",
"execution_count": 247,
"execution_count": 33,
"id": "d14780bc-dd5a-4710-a52b-ef491caae213",
"metadata": {},
"outputs": [
@ -1110,7 +1139,7 @@
"# Compute pattern (just to check)\n",
"bart pattern data/kSpace_upat_combined data/calc_pattern\n",
"\n",
"bart nlinv -i 30 -x 80:80:16 -S data/kSpace_upat_combined data/nlinv_upat_combined\n",
"bart nlinv -i 30 -x 80:80:16 -S data/kSpace_upat_combined data/nlinv_upat_combined data/nlinv_coilsens\n",
"# bart fft -i $(bart bitmask 0 1 2) data/kSpace_upat data/fft_upat\n",
"\n",
"# bart transpose 3 5 data/fft_upat data/fft_upat_transposed\n",
@ -1135,7 +1164,7 @@
},
{
"cell_type": "code",
"execution_count": 248,
"execution_count": 34,
"id": "821f937e-64ef-4ad3-9848-df50ee3faac3",
"metadata": {},
"outputs": [
@ -1153,7 +1182,7 @@
"<IPython.core.display.Image object>"
]
},
"execution_count": 248,
"execution_count": 34,
"metadata": {
"image/png": {
"width": 1000
@ -1169,6 +1198,84 @@
"Image(\"fig/upat_combined_mask.png\", width=1000)"
]
},
{
"cell_type": "markdown",
"id": "5c20ab89-d347-45ac-9833-7a5dd2c85fbf",
"metadata": {},
"source": [
"### 3.3.1 Uniform Undersampling PICS\n",
"Reco with pics"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "3ea47c87-480b-434e-a451-f5dc246968c2",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Done.\n"
]
}
],
"source": [
"%%bash\n",
"bart ecalib -m1 data/kSpace_upat_combined data/upat_coilsens"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "5b6a3b3d-9bd1-4e2f-b4b1-fd33513f984c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Size: 2048000 Samples: 1228800 Acc: 1.67\n",
"l1 regularization: 0.030000\n",
"Regularization terms: 1, Supporting variables: 0\n",
"FISTA\n",
"Total Time: 6.242878\n"
]
}
],
"source": [
"%%bash\n",
"bart pics -RI:$(bart bitmask 5):3e-2 -i150 -S data/kSpace_upat_combined data/nlinv_coilsens data/pics2_upat \n",
"#bart pics -l1 -r 0.03 -i 150 -S data/kSpace_upat_combined data/nlinv_coilsens data/pics3_upat"
]
},
{
"cell_type": "code",
"execution_count": 37,
"id": "c28b7fa1-4acb-4cfc-98b3-d8af9cf21025",
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"# Fit the model:\n",
"bart mobafit -T data/echo_times_final data/pics_upat data/fit_upat_pics\n",
"\n",
"# Now some values will be very large so we can apply a threshold to obtain a mask\n",
"MAX_T2=1000\n",
"\n",
"bart threshold -M $MAX_T2 data/fit_upat_pics data/mask_upat_pics\n",
"\n",
"# Multiply the fit with the mask\n",
"bart fmac data/fit_upat_pics data/mask_upat_pics data/fit_mask_upat_pics\n",
"\n",
"# Select slice\n",
"bart slice 6 1 data/fit_mask_upat_pics data/R2_map_upat_pics\n",
"\n",
"# Invert the data to get T2\n",
"bart invert data/R2_map_upat_pics data/T2_map_upat_pics"
]
},
{
"cell_type": "markdown",
"id": "d6fd6361-4ff8-4fc8-9b59-c2ccc75aa997",
@ -1322,10 +1429,128 @@
"bart invert data/R2_map_upat_combined_ip data/T2_map_upat_combined_ip"
]
},
{
"cell_type": "markdown",
"id": "16448609-399c-4967-896c-126819be8fec",
"metadata": {},
"source": [
"## 4.0 Subspace Reco"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "c74d227b-ff58-4ffb-a511-be3865c5618e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Basis: [ 80 80 16 1 1 20 3 1 1 1 1 1 1 1 1 1 ]\n",
"Max: [ 80 80 16 1 1 1 3 1 1 1 1 1 1 1 1 1 ]\n",
"Size: 2048000 Samples: 2047999 Acc: 1.00\n",
"Regularization terms: 0, Supporting variables: 0\n",
"conjugate gradients\n",
"Total Time: 2.095993\n"
]
}
],
"source": [
"%%bash\n",
"bart signal -S -n20 -2 10e-3:0.5:1000 -e10e-3 data/sig\n",
"bart transpose 2 5 data/sig data/sig\n",
"bart squeeze data/sig data/sig\n",
"\n",
"bart svd -e data/sig data/U data/S data/V\n",
"\n",
"#Optionally view S so we can see how quickly we capture all information\n",
"# bart show data/S\n",
"\n",
"bart extract 1 0 3 data/U data/basis_tmp # Three coeffs are enough\n",
"bart transpose 1 6 data/basis_tmp data/basis_tmp\n",
"bart transpose 0 5 data/basis_tmp data/basis\n",
"\n",
"# Basis dim: AoD: 1 1 1 1 1 20 3 1 1 ... for pics\n",
"\n",
"# Now we get a coefficient map\n",
"# bart nlinv -B data/basis data/kSpace data/coeff data/sens\n",
"bart pics -B data/basis data/ksp data/nlinv_coilsens data/coeff\n",
"\n",
"# From the coefficients and the basis we can get the image\n",
"bart fmac -s $(bart bitmask 6) data/basis data/coeff data/imgs\n",
"\n",
"# We perform the T2 fit on the image\n",
"bart mobafit -T data/echo_times_final data/imgs data/t2"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "bd942687-35f8-455f-a794-922bf19eb822",
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"# Now some values will be very large so we can apply a threshold to obtain a mask\n",
"MAX_T2=1000\n",
"\n",
"bart threshold -M $MAX_T2 data/t2 data/t2_subreco\n",
"\n",
"# Multiply the fit with the mask\n",
"bart fmac data/t2 data/t2_subreco data/t2_fit_subreco\n",
"\n",
"# Select slice\n",
"bart slice 6 1 data/t2_fit_subreco data/R2_fit_subreco\n",
"\n",
"# Invert the data to get T2\n",
"bart invert data/R2_fit_subreco data/T2_fit_subreco"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "450ddbe5-dad6-4f34-89c1-58db4ca1968c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Basis: [ 80 80 16 1 1 20 3 1 1 1 1 1 1 1 1 1 ]\n",
"Max: [ 80 80 16 1 1 1 3 1 1 1 1 1 1 1 1 1 ]\n",
"Size: 2048000 Samples: 1228800 Acc: 1.67\n",
"Regularization terms: 0, Supporting variables: 0\n",
"conjugate gradients\n",
"Total Time: 2.317959\n"
]
}
],
"source": [
"%%bash\n",
"# Now we get a coefficient map\n",
"# bart nlinv -B data/basis data/kSpace_upat_combined data/coeff_upat data/sens_upat\n",
"bart pics -B data/basis data/kSpace_upat_combined data/nlinv_coilsens data/coeff_upat\n",
"\n",
"## Coeffs are on dim 7\n",
"\n",
"# From the coefficients and the basis we can get the image\n",
"bart fmac -s $(bart bitmask 6) data/basis data/coeff_upat data/imgs_upat\n",
"\n",
"# We perform the T2 fit on the image \n",
"bart mobafit -T data/echo_times_final data/imgs_upat data/R2_fit_subreco_upat\n",
"\n",
"# Select slice\n",
"bart slice 6 1 data/R2_fit_subreco_upat data/R2_fit_subreco_upat\n",
"\n",
"# Invert the data to get T2\n",
"bart invert data/R2_fit_subreco_upat data/T2_fit_subreco_upat"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7c3668de-d997-4a76-b711-c413c7378bca",
"id": "cde1499e-4d97-4d21-b413-a2cccc21bd04",
"metadata": {},
"outputs": [],
"source": []