Open osbm opened 2 weeks ago
Here is the minimal code that reproduces the error.
from fastmri.data.subsample import create_mask_for_mask_type from fastmri.data.transforms import apply_mask, to_tensor, center_crop import numpy as np mask_func =create_mask_for_mask_type( mask_type_str="magic_fraction", center_fractions=[0.37], accelerations=[4] ) kspace = np.load("data/prostate1_kspace.npy") print(kspace.shape) # (34, 14, 640, 451) kspace = to_tensor(kspace) print(kspace.shape) # torch.Size([34, 14, 640, 451, 2]) subsampled_kspace, mask, num_low_frequencies = apply_mask( kspace, mask_func, seed=1 )
The error:
Traceback (most recent call last): File "test.py", line 15, in <module> subsampled_kspace, mask, num_low_frequencies = apply_mask( ^^^^^^^^^^^ File ".venv/lib/python3.12/site-packages/fastmri/data/transforms.py", line 77, in apply_mask mask, num_low_frequencies = mask_func(shape, offset, seed) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".venv/lib/python3.12/site-packages/fastmri/data/subsample.py", line 105, in __call__ center_mask, accel_mask, num_low_frequencies = self.sample_mask( ^^^^^^^^^^^^^^^^^ File ".venv/lib/python3.12/site-packages/fastmri/data/subsample.py", line 469, in sample_mask self.calculate_acceleration_mask( File ".venv/lib/python3.12/site-packages/fastmri/data/subsample.py", line 384, in calculate_acceleration_mask offset = self.rng.randint(0, high=acceleration) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "numpy/random/mtrand.pyx", line 798, in numpy.random.mtrand.RandomState.randint File "numpy/random/_bounded_integers.pyx", line 1334, in numpy.random._bounded_integers._rand_int64 ValueError: high <= 0
But this works fine when mask_type_str is equal to the equispaced, random, magic but not the equispaced_fraction or magic_fraction.
mask_type_str
equispaced
random
magic
equispaced_fraction
magic_fraction
I might be missing something as i dont understand what adding "fraction" changes in the behaviour of the masking function.
Here is the minimal code that reproduces the error.
The error:
But this works fine when
mask_type_str
is equal to theequispaced
,random
,magic
but not theequispaced_fraction
ormagic_fraction
.I might be missing something as i dont understand what adding "fraction" changes in the behaviour of the masking function.