Skip to content

fix(p_loraks.py): remove incorrect S-matrix operator_shape doubling i… - #15

Open
wzlk655 wants to merge 1 commit into
schmidt-jo:mainfrom
wzlk655:patch-1
Open

fix(p_loraks.py): remove incorrect S-matrix operator_shape doubling i…#15
wzlk655 wants to merge 1 commit into
schmidt-jo:mainfrom
wzlk655:patch-1

Conversation

@wzlk655

@wzlk655 wzlk655 commented Aug 3, 2026

Copy link
Copy Markdown

Pull Request Description

Problem

When using P-LORAKS with the S-matrix operator type and multi-coil data, reconstruction failed with the error:

RuntimeError: shape '[125000, 98]' is invalid for input of size 3062500

This occurred in s_operator() at the line indices_rev = indices.view(matrix_shape).flip(dims=(0,)).

Root Cause Analysis

Complete data-flow trace through the S-matrix pipeline:

Step Object Elements Shape
1. get_linear_indices() returns indices 3,062,500 (62500, 49) = (ns, nb)
2. _initialize_matrix_indices() incorrectly doubles matrix_operator_shape (125000, 98) = (2×ns, 2×nb)
3. s_operator() calls indices.view(matrix_shape) indices 3,062,500 → needs 12,250,000 ❌

The s_operator function internally handles S-matrix doubling via quadrant concatenation:

s_u = concatenate([(s_p - s_m).real, -(s_p - s_m).imag], dim=1)
s_d = concatenate([(s_p + s_m).imag, (s_p + s_m).real], dim=1)
s  = concatenate([s_u, s_d], dim=-1)
# Final: [..., 2×nb, 2×ns] → correct S-matrix size

No external doubling of matrix_operator_shape is needed — the doubling inside s_operator already produces the correct (2×nb, 2×ns) dimensions.

Fix

File: p_loraks.py

Removed the 2 lines that incorrectly doubled matrix_operator_shape for S-matrix:

 def _initialize_matrix_indices(self):
     self.indices, self.matrix_operator_shape = get_linear_indices(
         self.k_space_shape[1:],
         self.patch_shape,
         self.sample_directions
     )
-    if self.operator_type == OperatorType.S:
-        self.matrix_operator_shape = tuple(2 * d for d in self.matrix_operator_shape)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant