diff --git a/.gitignore b/.gitignore index 7a540e3f..e94a2bee 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,8 @@ docs_build .mypy_cache/ .ipynb_checkpoints/ .ropeproject/ - +__pycache__/ +*.egg-info/ _version.py *.mrd diff --git a/examples/example_gpu_anat_spirals_slice.py b/examples/example_gpu_anat_spirals_slice.py index 84b755a4..c7a7e225 100644 --- a/examples/example_gpu_anat_spirals_slice.py +++ b/examples/example_gpu_anat_spirals_slice.py @@ -13,7 +13,6 @@ # %% # Imports -import numpy as np import matplotlib.pyplot as plt from snake.core.simulation import SimConfig, default_hardware, GreConfig diff --git a/src/cli-conf/scenario2-2d.yaml b/src/cli-conf/scenario2-2d.yaml new file mode 100644 index 00000000..011a3785 --- /dev/null +++ b/src/cli-conf/scenario2-2d.yaml @@ -0,0 +1,92 @@ +# This files contains the configuration to produce the scenario 2 of the Snkf paper but with a 2D slice acquisition and reconstruction. + +defaults: + - base_config + - handlers: + - activation-block + - sampler: + - stack-of-spiral + - reconstructors: + - adjoint + #- sequential + - _self_ + +cache_dir: ${oc.env:PWD}/cache +result_dir: results/scenario2 +filename: ${cache_dir}/scenario2_2d_${engine.model}_${engine.snr}_${sampler.stack-of-spiral.constant}_${sampler.stack-of-spiral.accelz}.mrd + +sim_conf: + max_sim_time: 360 + seq: {TR: 50, TE: 25, FA: 12} + hardware: + n_coils: 1 + dwell_time_ms: 0.001 + shape: [60, 72, 60] + fov_mm: [181.0, 217.0, 181.0] + +phantom: + name: brainweb + sub_id: 4 + tissue_file: "tissue_7T" + +handlers: + activation-block: + event_name: block_on + block_on: 20 # seconds + block_off: 20 #seconds + duration: 360 # seconds + +sampler: + stack-of-spiral: + acsz: 1 + accelz: 1 + nb_revolutions: 10 + constant: true + spiral_name: "galilean" + +engine: + n_jobs: 1 + chunk_size: 10 + model: "simple" + snr: 10000 + nufft_backend: "gpuNUFFT" + slice_2d: true + +reconstructors: + adjoint: + nufft_backend: "gpuNUFFT" + density_compensation: "pipe" + # sequential: + # nufft_backend: "gpuNUFFT" + # density_compensation: false + # restart_strategy: WARM + # max_iter_per_frame: 50 + # wavelet: "sym4" + + + + + +hydra: + job: + chdir: true + + run: + dir: ${result_dir}/outputs/${hydra.job.name}/${now:%Y-%m-%d_%H-%M-%S} + sweep: + dir: ${result_dir}/multirun/${hydra.job.name}/${now:%Y-%m-%d_%H-%M-%S} + subdir: ${hydra.job.num} + + callbacks: + # gather_files: + # _target_: hydra_callbacks.MultiRunGatherer + # aggregator: + # _partial_: true + # _target_: snkf.cli.utils.aggregate_results + + log_job: + _target_: hydra.experimental.callbacks.LogJobReturnCallback + latest_run: + _target_: hydra_callbacks.LatestRunLink + run_base_dir: ${result_dir}/outputs + multirun_base_dir: ${result_dir}/multirun diff --git a/src/cli-conf/scenario2.yaml b/src/cli-conf/scenario2.yaml index aff266d7..5d5d039d 100644 --- a/src/cli-conf/scenario2.yaml +++ b/src/cli-conf/scenario2.yaml @@ -87,4 +87,4 @@ hydra: latest_run: _target_: hydra_callbacks.LatestRunLink run_base_dir: ${result_dir}/outputs - multirun_base_dir: ${result_dir}/multirun + multirun_base_dir: ${result_dir}/multirun \ No newline at end of file diff --git a/src/snake/core/engine/base.py b/src/snake/core/engine/base.py index be98dcc0..ab602ce0 100644 --- a/src/snake/core/engine/base.py +++ b/src/snake/core/engine/base.py @@ -209,7 +209,17 @@ def __call__( `_job_model_simple` methods. """ # Create the base dataset - make_base_mrd(filename, sampler, phantom, sim_conf, handlers, smaps, coil_cov) + make_base_mrd( + filename, + sampler, + phantom, + sim_conf, + handlers, + smaps, + coil_cov, + self.model, + self.slice_2d, + ) # Guesstimate the workload if worker_chunk_size <= 0: diff --git a/src/snake/core/engine/cartesian.py b/src/snake/core/engine/cartesian.py index ded70f6d..186b71f1 100644 --- a/src/snake/core/engine/cartesian.py +++ b/src/snake/core/engine/cartesian.py @@ -1,6 +1,5 @@ """Acquisition engine for Cartesian trajectories.""" -from typing import Any from collections.abc import Sequence from copy import deepcopy diff --git a/src/snake/core/sampling/samplers.py b/src/snake/core/sampling/samplers.py index 42575795..405856c5 100644 --- a/src/snake/core/sampling/samplers.py +++ b/src/snake/core/sampling/samplers.py @@ -1,7 +1,6 @@ """Samplers generate kspace trajectories.""" from __future__ import annotations -from typing import Literal import ismrmrd as mrd import numpy as np from numpy.typing import NDArray @@ -32,7 +31,8 @@ class NonCartesianAcquisitionSampler(BaseSampler): obs_time_ms: int Time spent to acquire a single shot in_out: bool - If true, the trajectory is acquired with a double join pattern from/to the periphery + If true, the trajectory is acquired with a double join pattern + from/to the periphery ndim: int Number of dimensions of the trajectory (2 or 3) """ @@ -198,7 +198,8 @@ class LoadTrajectorySampler(NonCartesianAcquisitionSampler): obs_time_ms: int Time spent to acquire a single shot in_out: bool - If true, the trajectory is acquired with a double join pattern from/to the periphery + If true, the trajectory is acquired with a double join pattern + from/to the periphery """ __sampler_name__ = "load-trajectory" diff --git a/src/snake/core/simulation.py b/src/snake/core/simulation.py index 181ff414..f14898aa 100644 --- a/src/snake/core/simulation.py +++ b/src/snake/core/simulation.py @@ -28,7 +28,6 @@ def _repr_html_(obj: Any, vertical: bool = True) -> str: '