Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: slice indices must be integers or None or have an index method #339

Open
kimm51 opened this issue May 2, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@kimm51
Copy link

kimm51 commented May 2, 2024

Hello,

I'm encountering an error message: "TypeError: slice indices must be integers or None or have an index method" while implementing CS for a brain dataset using the equispaced mask. This error occurs at a specific section of the code, indicating an issue that I'm having trouble understanding.

In the subsample.py file within the equispaced function, I made the following modification:

if offset is None:
    offset = self.rng.randint(0, high=round(acceleration))

mask = np.zeros(num_cols, dtype=np.float32)
mask[offset::acceleration] = 1

return mask

I added the following code snippet:

else:
    offset_value = offset[0] if isinstance(offset, tuple) else offset
    offset = int(offset_value) if offset is not None else None

This modification resolved the issue for a single volume, but when applied to multiple volumes, it did not work as expected.

Additionally, in the transform.py file, I couldn't get the mask function. Here's the relevant code snippet from the apply_mask function:

mask, num_low_frequencies = mask_func(shape, offset, seed)

if padding is not None:
    mask[..., : padding[0], :] = 0
    mask[..., padding[1] :, :] = 0  # padding value inclusive on the right of zeros

masked_data = data * mask + 0.0  # the + 0.0 removes the sign of the zeros

return masked_data, mask, num_low_frequencies

I have attached a screenshot of the error message for reference.

image

Best regards,

@kimm51 kimm51 added the bug Something isn't working label May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant