Skip to content

RandKSpaceSpikeNoise got an unexpected keyword argument 'dim' #3867

Description

@mibaumgartner

Describe the bug
RandKSpaceSpikeNoise does not work with NumPy array if intensity_range is not set manually.

In case a NumPy array is provided, the linked part will call np.mean(.., dim=...) but NumPy does not support dim arguments (should be axis). The implementation works fine for torch.Tensors.

mod = torch if isinstance(k, torch.Tensor) else np
log_abs = mod.log(mod.absolute(k) + 1e-10)
shifted_means = mod.mean(log_abs, dim=tuple(range(-n_dims, 0))) * 2.5

To Reproduce
Call transform on NumPy array with default values (specifically intensity_range =None).

Expected behavior
No crash.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment

Ensuring you use the relevant python executable, please paste the output of:

python -c 'import monai; monai.config.print_debug_info()'

Additional context
Add any other context about the problem here.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions