diff --git a/shimmingtoolbox/cli/create_coil_profiles.py b/shimmingtoolbox/cli/create_coil_profiles.py index 43e5d684..7f4eb4ab 100644 --- a/shimmingtoolbox/cli/create_coil_profiles.py +++ b/shimmingtoolbox/cli/create_coil_profiles.py @@ -18,17 +18,19 @@ from shimmingtoolbox.masking.threshold import threshold as mask_threshold CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) -GAMMA = 42.576E6 # in Hz/Tesla +GAMMA = 42.576E6 # in Hz/Tesla logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) @click.group(context_settings=CONTEXT_SETTINGS, - help="Create coil profiles according to the specified algorithm as an argument e.g. st_create_coil_profiles xxxxx") + help="Create coil profiles according to the specified algorithm as an argument e.g. st_create_coil_" + "profiles xxxxx") def coil_profiles_cli(): pass + @click.command( context_settings=CONTEXT_SETTINGS, ) @@ -39,7 +41,7 @@ def coil_profiles_cli(): @click.option('--relative-path', 'path_relative', type=click.Path(exists=True), required=False, default=None, help="Path to add before each file in the config file. This allows to have relative paths in the config " "file. If this option is not specified, absolute paths must be provided in the config file.") -@click.option('--unwrapper', type=click.Choice(['prelude']), default='prelude', show_default=True, +@click.option('--unwrapper', type=click.Choice(['prelude', 'skimage']), default='prelude', show_default=True, help="Algorithm for unwrapping") @click.option('--threshold', type=float, required=True, help="Threshold for masking. Allowed range: [0, 1] where all scaled values lower than the threshold are " @@ -55,9 +57,10 @@ def coil_profiles_cli(): help="Output filename of the coil profiles NIfTI file. Supported types : '.nii', '.nii.gz'") @click.option('-v', '--verbose', type=click.Choice(['info', 'debug']), default='info', help="Be more verbose") def from_field_maps(fname_json, path_relative, autoscale, unwrapper, threshold, gaussian_filter, sigma, - fname_output, verbose): - """ Create \u0394B\u2080 coil profiles from acquisitions defined in the input json file. The output is in Hz/ where - current depends on the value in the configuration file""" + fname_output, verbose): + """ Create \u0394B\u2080 coil profiles from acquisitions defined in the input json file. The output is in + Hz/ where current depends on the value in the configuration file + """ # Set logger level set_all_loggers(verbose) @@ -311,7 +314,7 @@ def from_field_maps(fname_json, path_relative, autoscale, unwrapper, threshold, "position (in mm). Input should be --offset x y z. Defaulted to 0 0 0") @click.option('--flip', 'dims_to_flip', required=False, type=(float, float, float), default=(1, 1, 1), help="Dimensions (XYZ order) to flip in the wires' geometry (1 for no flip, -1 for flip). " - "Input should be --flip x y z. Defaulted to 1 1 1.") + "Input should be --flip x y z. Defaulted to 1 1 1.") @click.option('--software', type=click.Choice(['autocad']), default='autocad', help=f"Software from which the geometries were extracted.") @click.option('--coil_name', 'coil_name', required=False, type=click.STRING, default="new", diff --git a/shimmingtoolbox/unwrap/skimage_unwrap.py b/shimmingtoolbox/unwrap/skimage_unwrap.py index 57f336fe..dc06063a 100644 --- a/shimmingtoolbox/unwrap/skimage_unwrap.py +++ b/shimmingtoolbox/unwrap/skimage_unwrap.py @@ -58,7 +58,7 @@ def skimage_unwrap(nii_wrapped_phase, mag=None, mask=None, threshold=None, fname nib.save(nii_mask, fname_save_mask) # Unwrap the phase - ma_wrapped_phase = ma.array(wrapped_phase, mask=~unwrap_mask) + ma_wrapped_phase = ma.array(wrapped_phase, mask=~unwrap_mask.astype(bool)) ma_unwrapped_phase = unwrap_phase(ma_wrapped_phase, rng=0) # Fill the masked values with 0 diff --git a/test/cli/test_cli_create_coil_profiles.py b/test/cli/test_cli_create_coil_profiles.py index fa8ececb..06351430 100644 --- a/test/cli/test_cli_create_coil_profiles.py +++ b/test/cli/test_cli_create_coil_profiles.py @@ -54,7 +54,6 @@ } -@pytest.mark.prelude def test_create_coil_profiles(): runner = CliRunner() @@ -70,6 +69,7 @@ def test_create_coil_profiles(): ['from-field-maps', '-i', fname_config, '--relative-path', os.path.join(__dir_testing__, 'ds_b0', 'sub-fieldmap', 'fmap'), + '--unwrapper', 'skimage', '--threshold', '0.4', '-o', fname_output], catch_exceptions=False) @@ -77,7 +77,6 @@ def test_create_coil_profiles(): assert os.path.isfile(fname_output) -@pytest.mark.prelude def test_create_coil_profiles_dead_channel1(): runner = CliRunner() @@ -97,6 +96,7 @@ def test_create_coil_profiles_dead_channel1(): ['from-field-maps', '-i', fname_config, '--relative-path', os.path.join(__dir_testing__, 'ds_b0', 'sub-fieldmap', 'fmap'), + '--unwrapper', 'skimage', '--threshold', '0.4', '-o', fname_output], catch_exceptions=False) @@ -105,7 +105,6 @@ def test_create_coil_profiles_dead_channel1(): assert nib.load(fname_output).shape == (128, 76, 10, 2) -@pytest.mark.prelude def test_create_coil_profiles_dead_channel2(): runner = CliRunner() @@ -126,6 +125,7 @@ def test_create_coil_profiles_dead_channel2(): ['from-field-maps', '-i', fname_config, '--relative-path', os.path.join(__dir_testing__, 'ds_b0', 'sub-fieldmap', 'fmap'), + '--unwrapper', 'skimage', '--threshold', '0.4', '-o', fname_output], catch_exceptions=False)