diff --git a/fsleyes_plugin_shimming_toolbox/tabs/b0shim_tab.py b/fsleyes_plugin_shimming_toolbox/tabs/b0shim_tab.py index 4e7d6b8..619eb17 100644 --- a/fsleyes_plugin_shimming_toolbox/tabs/b0shim_tab.py +++ b/fsleyes_plugin_shimming_toolbox/tabs/b0shim_tab.py @@ -169,7 +169,8 @@ def create_sizer_dynamic_shim(self, metadata=None): }, ] component_slice_int = InputComponent(self, input_text_box_metadata_slice, cli=dynamic_cli) - component_slice_seq = InputComponent(self, input_text_box_metadata_slice, cli=dynamic_cli) + component_slice_asc = InputComponent(self, input_text_box_metadata_slice, cli=dynamic_cli) + component_slice_des = InputComponent(self, input_text_box_metadata_slice, cli=dynamic_cli) output_metadata = [ { @@ -277,7 +278,16 @@ def create_sizer_dynamic_shim(self, metadata=None): ] component_reg_factor_lsq = InputComponent(self, reg_factor_metadata, cli=dynamic_cli) component_reg_factor_qp = InputComponent(self, reg_factor_metadata, cli=dynamic_cli) - + + weighting_signal_loss_metadata = [ + { + "button_label": "Weighting signal loss", + "name": "weighting-signal-loss", + "default_text": "0.01", + }, + ] + component_slice_w_sig_loss = InputComponent(self, weighting_signal_loss_metadata, cli=dynamic_cli) + criteria_dropdown_metadata = [ { "label": "Mean Squared Error", @@ -290,15 +300,23 @@ def create_sizer_dynamic_shim(self, metadata=None): { "label": "Root Mean Squared Error", "option_value": "rmse", + }, + { + "label": "Mean Squared Error + Z gradient", + "option_value": "grad", } - ] + ] dropdown_crit = DropdownComponent( panel=self, dropdown_metadata=criteria_dropdown_metadata, label="Optimizer Criteria", option_name='optimizer-criteria', - cli=dynamic_cli + cli=dynamic_cli, + list_components=[self.create_empty_component(), + self.create_empty_component(), + self.create_empty_component(), + component_slice_w_sig_loss] ) dropdown_opt_metadata = [ @@ -335,8 +353,12 @@ def create_sizer_dynamic_shim(self, metadata=None): "option_value": "auto" }, { - "label": "Sequential", - "option_value": "sequential" + "label": "Ascending", + "option_value": "ascending" + }, + { + "label": "Descending", + "option_value": "descending" }, { "label": "Interleaved", @@ -345,7 +367,7 @@ def create_sizer_dynamic_shim(self, metadata=None): { "label": "Volume", "option_value": "volume" - }, + } ] self.dropdown_slice_dyn = DropdownComponent( @@ -355,7 +377,8 @@ def create_sizer_dynamic_shim(self, metadata=None): cli=dynamic_cli, option_name='slices', list_components=[self.create_empty_component(), - component_slice_seq, + component_slice_asc, + component_slice_des, component_slice_int, self.create_empty_component()] ) diff --git a/installer/install_shimming_toolbox.sh b/installer/install_shimming_toolbox.sh index 10b39f2..d612a9c 100644 --- a/installer/install_shimming_toolbox.sh +++ b/installer/install_shimming_toolbox.sh @@ -14,7 +14,7 @@ rm -rf "${ST_DIR}/shimming-toolbox" print info "Downloading Shimming-Toolbox" -ST_VERSION="cf28d353240fd510de1e8aa492c6c23ae57e66bd" +ST_VERSION="cb579afefb8ac742909e5d706a85c2c6dc091274" curl -L "https://github.com/shimming-toolbox/shimming-toolbox/archive/${ST_VERSION}.zip" > "shimming-toolbox-${ST_VERSION}.zip" diff --git a/test/gui/test_b0shim_tab.py b/test/gui/test_b0shim_tab.py index 773d464..7c0f099 100644 --- a/test/gui/test_b0shim_tab.py +++ b/test/gui/test_b0shim_tab.py @@ -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', @@ -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')