|
| 1 | +# Use Koma from the Command Line |
| 2 | + |
| 3 | +KomaMRI provides the `koma` Julia app for opening the UI or running simulations from a terminal. |
| 4 | + |
| 5 | +## Installing the App |
| 6 | + |
| 7 | +Install KomaMRI with `pkg> add KomaMRI`, then install the `koma` app (Julia 1.12+): |
| 8 | +```julia-repl |
| 9 | +pkg> app add KomaMRI # Julia 1.12+ |
| 10 | +pkg> # app dev /path/to/KomaMRI.jl # Local checkout, Julia 1.12+ |
| 11 | +``` |
| 12 | + |
| 13 | +The executable is installed in `~/.julia/bin`. If `koma` is not found, add that directory to your `PATH`. |
| 14 | +The app command is named `koma`; Julia app names are executable names, not registered package names. |
| 15 | + |
| 16 | +## Basic Workflow & Input Defaults |
| 17 | + |
| 18 | +With no arguments, `koma` opens the graphical interface with default inputs: |
| 19 | +```bash |
| 20 | +koma |
| 21 | +``` |
| 22 | + |
| 23 | +Add input files without output paths to preload the UI before it opens: |
| 24 | +```bash |
| 25 | +koma -i epi.seq brain.phantom |
| 26 | +``` |
| 27 | + |
| 28 | +Input files can be passed in any order. KomaMRI identifies them by extension: `.seq`, `.phantom` or `.h5`. |
| 29 | +A scanner `.sys` file is also accepted, but it does nothing for now. |
| 30 | + |
| 31 | +## Running Simulation |
| 32 | + |
| 33 | +Add a simulation output path with `-o` or `--outputs` to run without opening the UI: |
| 34 | +```bash |
| 35 | +koma -i epi.seq brain.phantom -o raw.mrd |
| 36 | +``` |
| 37 | + |
| 38 | +Simulation output can be `.mrd` or `.mat`, selected from the output filename extension. |
| 39 | + |
| 40 | +## Reconstructing Image using MRIReco |
| 41 | + |
| 42 | +Pass a second output path to reconstruct after simulation. Reconstruction output is currently `.mat`: |
| 43 | +```bash |
| 44 | +koma -i epi.seq brain.phantom -o raw.mrd image.mat |
| 45 | +``` |
| 46 | + |
| 47 | +Use `_` to skip saving the simulation output: |
| 48 | +```bash |
| 49 | +koma -i epi.seq brain.phantom -o _ image.mat |
| 50 | +``` |
| 51 | + |
| 52 | +## Simulation and Reconstruction Parameters |
| 53 | + |
| 54 | +Simulation and reconstruction parameters can be passed as repeated `KEY=VALUE` pairs: |
| 55 | +```bash |
| 56 | +koma -i epi.seq brain.phantom -s sim_method=BlochMagnus4 -r reco=direct -o raw.mrd |
| 57 | +``` |
| 58 | + |
| 59 | +The long forms are `--sim-param` and `--recon-param`. |
| 60 | + |
| 61 | +## Backend and Threading |
| 62 | + |
| 63 | +Simulations run on multi-threaded CPU by default. GPU backends can be loaded by name: |
| 64 | +```bash |
| 65 | +koma -b Metal -i epi.seq brain.phantom -o raw.mrd |
| 66 | +``` |
| 67 | + |
| 68 | +The selected backend package must be installed in your default Julia environment. |
| 69 | + |
| 70 | +The app starts with CPU threading enabled automatically. To choose a thread count, pass Julia flags before `--` and KomaMRI arguments after it: |
| 71 | +```bash |
| 72 | +koma --threads=8 -- -i epi.seq brain.phantom -o raw.mrd |
| 73 | +``` |
| 74 | + |
| 75 | +## Default App Configuration |
| 76 | + |
| 77 | +`koma` can read CLI defaults from Julia's `LocalPreferences.toml` in the app environment. Put the file in the path that matches how the app was installed: |
| 78 | + |
| 79 | +- Installed with `pkg> app add KomaMRI` (Julia 1.12+): `~/.julia/environments/apps/KomaMRI/LocalPreferences.toml` |
| 80 | +- Installed with `pkg> app dev /path/to/KomaMRI.jl` (Julia 1.12+): `/path/to/KomaMRI.jl/LocalPreferences.toml` |
| 81 | + |
| 82 | +```toml |
| 83 | +[KomaMRI.koma] |
| 84 | +backend = "CPU" # CPU, CUDA, Metal, AMDGPU, or oneAPI |
| 85 | + |
| 86 | +[KomaMRI.koma.inputs] |
| 87 | +sequence = "mysequence.seq" |
| 88 | +phantom = "myphantom.phantom" |
| 89 | + |
| 90 | +[KomaMRI.koma.outputs] |
| 91 | +# rawdata = "raw.mrd" |
| 92 | +# image = "image.mat" |
| 93 | + |
| 94 | +[KomaMRI.koma.sim_params] |
| 95 | +# Numerical accuracy |
| 96 | +sim_method = "BlochMagnus4" |
| 97 | +precision = "f32" |
| 98 | +"Δt" = 1e-3 |
| 99 | +"Δt_rf" = 5e-5 |
| 100 | +# Memory |
| 101 | +max_block_length = 512 |
| 102 | +max_rf_block_length = inf |
| 103 | +# CPU multi-threaded |
| 104 | +Nthreads = 8 |
| 105 | +# GPU kernel launch config |
| 106 | +gpu_groupsize_precession = 256 |
| 107 | +gpu_groupsize_excitation = 256 |
| 108 | +``` |
| 109 | + |
| 110 | +CLI arguments override these defaults. |
0 commit comments