Skip to content

Commit 54ecf12

Browse files
committed
First version of scripts
0 parents  commit 54ecf12

File tree

221 files changed

+14215
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+14215
-0
lines changed

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Skip
2+
*.cfl
3+
*.hdr
4+
*.txt
5+
*.code-workspace
6+
*.log
7+
*/out*
8+
9+
# Add anyway
10+
!*/vertices/*.cfl
11+
!*/vertices/*.hdr
12+
!00_gold_standard_nist/ref_values_nist.txt
13+
!05_IR-bSSFP_NIST/ref_values_nist.txt
14+
!06_IR-bSSFP_invivo/tables.txt
15+
!s03_multi_trf_analysis/tables.txt

LICENSE

+397
Large diffs are not rendered by default.

README.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Quantitative Multi-Parameter Mapping in Magnetic Resonance Imaging
2+
3+
This repository includes the scripts to create the Figures for chapter 5 of
4+
5+
> #### Quantitative Multi-Parameter Mapping in Magnetic Resonance Imaging
6+
> Scholand, N. Doctoral thesis, 2023.
7+
> [doi: 10.53846/goediss-10028](http://dx.doi.org/10.53846/goediss-10028)
8+
9+
The scripts for the figures of chapter 4 can be found on [Github](https://github.com/mrirecon/bloch-moba).
10+
11+
## Requirements
12+
This repository has been tested on Debian 11, but is assumed to work on other Linux-based operating systems, too.
13+
14+
### Reconstruction
15+
Pre-processing, reconstruction and post-processing is performed with the [BART toolbox](https://github.com/mrirecon/bart).
16+
The provided scripts are compatible with commit `f1192bc` or later.
17+
If you experience any compatibility problems with later BART versions please contact us!
18+
19+
[//]: <> (FIXME: Add DOI for BART version including the Bloch model-based reconstruction)
20+
21+
For running the reconstructions access to a GPU is recommended.
22+
If the CPU should be used, please remove `-g` flags from `bart moba ...`, `bart pics ...` and `bart rtnlinv ...` calls.
23+
24+
### Visualization
25+
The visualizations have been tested with Python on version 3.9.2 and require numpy, copy, matplotlib, mpl_toolkits, sys, os, math, time, and scipy. Ensure to have set a DISPLAY variable, when the results should be visualized.
26+
27+
## Data
28+
The data is hosted on [ZENODO](https://zenodo.org/) and must be downloaded first.
29+
30+
* Manual download: https://zenodo.org/record/7837312
31+
* Download via script: Run the download script in the `./data` folder.
32+
* **All** files: `bash load-all.sh`
33+
* **Individual** files: `bash load.sh 7654462 <FILENAME> . ` or `bash load.sh 6992763 <FILENAME> . ` for the scripts in the folder `init_test`
34+
35+
Note: The data must be stored in the `./data` folder!
36+
37+
38+
## Folders
39+
Each folder contains a README file explaining how the figure can be reproduced.
40+
41+
42+
[//]: <> (FIXME: Add Runtime!)
43+
44+
## Feedback
45+
Please feel free to send us feedback about this scripts!
46+
We would be happy to learn how to improve this and future script publications.
47+
48+
49+
## License
50+
This work is licensed under a **Creative Commons Attribution 4.0 International License**.
51+
You should have received a copy of the license along with this
52+
work. If not, see <https://creativecommons.org/licenses/by/4.0/>.

b0_invivo/README.mkd

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
To run a reconstruction with a specific model run `./run_reco.sh <MODEL>`.
2+
3+
All reconstruction can be run using `./run.sh`.
4+
5+
For running all models and creating the final figure enter `./run_figs.sh`.
6+
7+
You might want to specify the reconstruction parameters in `func/opts.sh`.
8+
9+
To clean up the folder run `./clean_up.sh`.

b0_invivo/b0map/load_b0map.sh

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
# B0 Mapping with Siemens Sequence "gre_field_mapping" based on
4+
# Nayak, K.S. and Nishimura, D.G. (2000),
5+
# Automatic field map generation and off-resonance correction for projection reconstruction imaging.
6+
# Magn. Reson. Med., 43: 151-154.
7+
# https://doi.org/10.1002/(SICI)1522-2594(200001)43:1<151::AID-MRM19>3.0.CO;2-K
8+
9+
# Estimate relative paths
10+
FULL_PATH=$(realpath ${0})
11+
REL_PATH=$(dirname ${FULL_PATH})
12+
13+
TE1=0.00492 # Early TE
14+
TE2=0.00738 # Late TE
15+
16+
# Load data
17+
# bart twixread -A /home/ague/archive/vol/2023-03-14_MRTG-BLMB-0008/raw/meas_MID00043_FID06084_gre_field_mapping_BR256_S01.dat raw
18+
bart copy ${REL_PATH}/../data/ksp_b0map raw
19+
20+
# Estimate Coil sensitivities
21+
bart ecalib -c 0 -m 1 raw sens
22+
23+
# Phase preserving PI reconstruction
24+
bart pics -g -e -S -d 5 raw sens _reco
25+
rm {sens,raw}.{cfl,hdr}
26+
27+
SAMPLES=$(bart show -d 0 _reco)
28+
bart resize -c 0 $((SAMPLES/2)) _reco reco
29+
30+
bart slice 5 0 reco te1
31+
bart slice 5 1 reco te2
32+
rm {,_}reco.{cfl,hdr}
33+
34+
# Estimate B0 = phase(reco(TE2) * conj(reco(TE2))) / (TE2 - TE1)
35+
# Nayak & Nishimura, MRM, 2000.
36+
37+
bart conj te1 te1c
38+
bart fmac te2 te1c prod
39+
bart carg prod ph
40+
bart scale -- $(echo $TE1 $TE2 | awk '{printf "%f\n", -1/($2-$1)}') ph _b0map # [rad/s]
41+
rm {ph,te1,te1c,te2,prod}.{cfl,hdr}
42+
43+
# Resize for input in moba
44+
bart resize -c 0 $SAMPLES 1 $SAMPLES _b0map __b0map
45+
bart transpose 0 1 __b0map b0map
46+
rm {_,}_b0map.{cfl,hdr}

b0_invivo/b1map/arccos.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
@author: nscho
5+
"""
6+
import sys
7+
import os
8+
sys.path.insert(0, os.path.join(os.environ['TOOLBOX_PATH'], 'python'))
9+
import cfl
10+
11+
import numpy as np
12+
13+
14+
if __name__ == "__main__":
15+
16+
#Error if wrong number of parameters
17+
if( len(sys.argv) != 3):
18+
print( "arccos(input)" )
19+
print( "#-----------------------------------------------" )
20+
print( "Usage: arccos.py <input> <output>" )
21+
exit()
22+
23+
sysargs = sys.argv
24+
25+
out = np.arccos(cfl.readcfl(sysargs[1]).squeeze())
26+
27+
# Load input
28+
cfl.writecfl(sysargs[2], out)
29+

b0_invivo/b1map/load_b1map.sh

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
3+
# B1+ Mapping with Siemens Sequence "tfl_b1map" based on
4+
# Chung, S., Kim, D., Breton, E. and Axel, L. (2010),
5+
# Rapid B1+ mapping using a preconditioning RF pulse with TurboFLASH readout.
6+
# Magn. Reson. Med., 64: 439-446.
7+
# https://doi.org/10.1002/mrm.22423
8+
9+
set -eux
10+
11+
# Estimate relative paths
12+
FULL_PATH=$(realpath ${0})
13+
REL_PATH=$(dirname ${FULL_PATH})
14+
15+
# Load b1 raw data
16+
# bart twixread -A /home/ague/archive/vol/2023-03-14_MRTG-BLMB-0008/raw/meas_MID00044_FID06085_B1Map_for_MRF_BR256.dat raw_asym
17+
bart copy ${REL_PATH}/../data/ksp_b1map raw_asym
18+
19+
# Compensate for asymetric echo
20+
## Mirror kspace to fill missing lines
21+
FREQ_ASYM=$(bart show -d 0 raw_asym)
22+
PHASE=$(bart show -d 1 raw_asym)
23+
DIFF=$(($((PHASE*2))-FREQ_ASYM))
24+
25+
bart extract 0 $((FREQ_ASYM-DIFF)) $FREQ_ASYM raw_asym miss
26+
bart flip $(bart bitmask 0) raw_asym tmp
27+
bart join -a 0 tmp miss _raw
28+
bart flip $(bart bitmask 0) _raw raw
29+
30+
rm {raw_asym,miss,tmp,_raw}.{cfl,hdr}
31+
32+
33+
# Estimate Coil sensitivities
34+
bart ecalib -c 0 -m 1 raw sens
35+
36+
# Phase preserving PI reconstruction
37+
bart pics -g -e -S -d 5 raw sens _reco
38+
39+
SAMPLES=$(bart show -d 0 _reco)
40+
41+
bart resize -c 0 $PHASE _reco reco
42+
43+
rm {raw,sens,_reco}.{cfl,hdr}
44+
45+
bart slice 11 0 reco pd
46+
bart slice 11 1 reco pre
47+
48+
rm reco.{cfl,hdr}
49+
50+
# Calculate: SSPre / PD
51+
bart invert pd pdi
52+
bart fmac pre pdi tmp
53+
54+
# Calculate: arccos(SSPre / PD)
55+
python3 ${REL_PATH}/arccos.py tmp acos
56+
57+
FA_NOM=80 # [deg] Just from raw data..., IDEA internal... -> vim *.dat and /PrepFlipAngle
58+
59+
# Calculate: kappa = arccos(SSPre / PD) / FA_NOM = b1map
60+
bart scale -- $(echo $FA_NOM | awk '{printf "%f\n", 1/(3.141592653589793 * $1 / 180)}') acos _b1map
61+
62+
rm {pd,pdi,pre,tmp,acos}.{cfl,hdr}
63+
64+
65+
# Resize for input in moba
66+
bart resize -c 0 $SAMPLES 1 $SAMPLES _b1map __b1map
67+
bart transpose 0 1 __b1map b1map
68+
69+
rm _{,_}b1map.{cfl,hdr}

b0_invivo/clean_up.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
[ -d out ] && rm -rf out
4+
# [ -d mask ] && rm -rf mask

b0_invivo/data/load_data.sh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
4+
# Estimate absolute paths
5+
6+
FULL_PATH=$(realpath ${0})
7+
ABS_PATH=$(dirname ${FULL_PATH})
8+
9+
10+
# Get and rename data for this analysis
11+
## FIXME: remove rename and load data directly
12+
13+
FILES=(
14+
data_invivo_b0map
15+
data_invivo_b1map
16+
data_invivo_irflash
17+
data_invivo_irbssfp
18+
data_invivo_irbssfp_shim
19+
)
20+
21+
OUT=(
22+
ksp_b0map
23+
ksp_b1map
24+
ksp_flash
25+
ksp_bssfp
26+
ksp_bssfp_shim
27+
)
28+
29+
for (( i=0; i<${#FILES[@]}; i++ ));
30+
do
31+
if [[ ! -f "${ABS_PATH}/${OUT[$i]}.cfl" ]];
32+
then
33+
34+
bart copy ${ABS_PATH}/../../data/${FILES[$i]} ${ABS_PATH}/${OUT[$i]}
35+
36+
echo "Generated output file: ${ABS_PATH}/${OUT[$i]}.{cfl,hdr}" >&2
37+
fi
38+
done

0 commit comments

Comments
 (0)