Skip to content

Commit

Permalink
Add test for signal loss optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
4rnaudB committed Jun 27, 2024
1 parent e81919e commit 3cc431e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fsleyes_plugin_shimming_toolbox/tabs/b0shim_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def create_sizer_dynamic_shim(self, metadata=None):

weighting_signal_loss_metadata = [
{
"button_label": "weighting signal loss",
"button_label": "Weighting signal loss",
"name": "weighting-signal-loss",
"default_text": "0.01",
},
Expand Down
2 changes: 1 addition & 1 deletion installer/install_shimming_toolbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rm -rf "${ST_DIR}/shimming-toolbox"

print info "Downloading Shimming-Toolbox"

ST_VERSION="e136db64e0cf9110adf321a1adc957453009f475"
ST_VERSION="420905677bf624228e2e1088d842178de1f30196"

curl -L "https://github.com/shimming-toolbox/shimming-toolbox/archive/${ST_VERSION}.zip" > "shimming-toolbox-${ST_VERSION}.zip"

Expand Down
23 changes: 23 additions & 0 deletions test/gui/test_b0shim_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ def _test_st_plugin_b0shim_dyn(view, overlayList, displayCtx, options=options):


def test_st_plugin_b0shim_dyn_lsq_mae():
options = {'optimizer-method': 'Least Squares',
'optimizer-criteria': 'Mean Squared Error + Z gradient',
'weighting-signal-loss': '0.01',
'slices': 'Auto detect',
'scanner-coil-order': '1',
'output-file-format-scanner': 'Slicewise per Channel',
'output-file-format-coil': 'Slicewise per Channel',
'output-value-format': 'delta'
}

def _test_st_plugin_b0shim_dyn(view, overlayList, displayCtx, options=options):
__test_st_plugin_b0shim_dyn(view, overlayList, displayCtx, options=options)
run_with_orthopanel(_test_st_plugin_b0shim_dyn)


def test_st_plugin_b0shim_dyn_lsq_grad():
options = {'optimizer-method': 'Least Squares',
'optimizer-criteria': 'Mean Absolute Error',
'slices': 'Auto detect',
Expand Down Expand Up @@ -106,6 +122,13 @@ def __test_st_plugin_b0shim_dyn(view, overlayList, displayCtx, options):

with tempfile.TemporaryDirectory(prefix='st_' + pathlib.Path(__file__).stem) as tmp:
nii_fmap, nii_anat, nii_mask, nii_coil, fm_data, anat_data, coil_data, _ = _define_inputs(fmap_dim=3)

# Duplicate nii_fmap's last dimension
if 'weighting-signal-loss' in options.keys():
fmap = nii_fmap.get_fdata()
fmap = np.repeat(fmap, 5, axis=2)
nii_fmap = nib.Nifti1Image(fmap, nii_fmap.affine, header=nii_fmap.header)

fname_fmap = os.path.join(tmp, 'fmap.nii.gz')
fname_fm_json = os.path.join(tmp, 'fmap.json')
fname_mask = os.path.join(tmp, 'mask.nii.gz')
Expand Down

0 comments on commit 3cc431e

Please sign in to comment.