Skip to content

Oasis unet reconstruction#40

Merged
MatthiasLen merged 21 commits into
mainfrom
oasis_unet_reconstruction
May 15, 2026
Merged

Oasis unet reconstruction#40
MatthiasLen merged 21 commits into
mainfrom
oasis_unet_reconstruction

Conversation

@ydu0117
Copy link
Copy Markdown
Collaborator

@ydu0117 ydu0117 commented May 7, 2026

Summary

  • Add OASIS inference plotting example
  • Add OASIS U-Net checkpoint loading through the shared fastMRI U-Net module
  • Enable OASIS k-space distortions and document reconstruction_only download link

Tests

  • uv run pre-commit run --all-files
  • uv run pytest

@MatthiasLen MatthiasLen added enhancement New feature or request recon labels May 7, 2026
@MatthiasLen MatthiasLen self-requested a review May 8, 2026 07:38
@MatthiasLen MatthiasLen self-assigned this May 8, 2026
Copy link
Copy Markdown
Owner

@MatthiasLen MatthiasLen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear @ydu0117 , thank you for the PR. I have reviewed it.

  • there was some functionality missing related to automated model download. In my latest commit I have added SHA256 certified automated download. This means certification will fail if the model weights are updated. This it intentional to fix model weight versions etc. ... Good news is , the user gets the model automatically and no manual dowloading from GCP is needed. please have a look at my changes.
  • I could resolve a small merge conflict
  • I have added some missing dependencies in the pyproject.toml.

Open point I kindly ask you to support:
It could you add OASIS to the FastMRI reconstruction example in the same "lightweight way" as the other reconstructors ? Important: In case the OASIS and FastMRI dataset convention differ I would suggest to move this is a small separate adaptor class . The example code , the reconstructor API should not be "blown-up". If you have questions, please, ping me in teams or tag me here. Thanks 👍

@ydu0117
Copy link
Copy Markdown
Collaborator Author

ydu0117 commented May 14, 2026

Dear @MatthiasLen, I have updated the PR by:

  • Added the OASIS example to fastmri_example_plot
  • Added theoasis_adapter in utils folder
  • Implemented a helper function to download the split_csv file
  • Documented the usage in the README

If there is any other issues feel free to suggest

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for OASIS-based single-coil U-Net reconstruction: a new OASIS dataset adapter and centered-FFT physics, a OASISSinglecoilUnetReconstructor that auto-downloads a packaged manifest/checkpoint from Google Drive, a new PartialFourierDistortion, broader axis support for CartesianUndersampling, and an extended inference plotting example. README and nibabel dependency are updated accordingly.

Changes:

  • New OasisSliceDataset, OasisCenteredFFTPhysics, and FFT helpers under mri_recon/utils/oasis_adapter.py, plus a Google Drive downloader in mri_recon/utils/io.py.
  • New OASISSinglecoilUnetReconstructor with manifest-based checkpoint resolution and a Lightning-aware state-dict loader in mri_recon/reconstruction/deep.py.
  • New PartialFourierDistortion, expanded axis choices for CartesianUndersampling, and OASIS path in examples/fastmri_inference_plot.py, with corresponding tests and docs.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pyproject.toml / uv.lock Add nibabel>=5.3.2 dependency.
README.md Document OASIS reconstructor and inference example usage.
mri_recon/utils/io.py Add Google Drive downloader with virus-scan confirm flow.
mri_recon/utils/oasis_adapter.py New OASIS dataset, centered-FFT helpers and physics adapter.
mri_recon/utils/init.py Export new OASIS helpers and Google Drive download function.
mri_recon/reconstruction/deep.py Add OASISSinglecoilUnetReconstructor with manifest-based checkpoint resolution.
mri_recon/reconstruction/init.py Export OASISSinglecoilUnetReconstructor.
mri_recon/distortions/undersampling.py Allow axis=-1 and add PartialFourierDistortion; expand docstrings.
mri_recon/distortions/init.py Export PartialFourierDistortion.
mri_recon/distortions/resolution.py, biasfield.py Docstring expansions only.
examples/fastmri_inference_plot.py OASIS dataset/physics path and new CLI flags.
tests/test_*.py Tests for new download flow, OASIS reconstructor, and partial Fourier mask.
Comments suppressed due to low confidence (1)

mri_recon/utils/oasis_adapter.py:114

  • _num_slices is defined but never referenced anywhere in the codebase. _create_sample_list derives slice counts from the CSV's last column rather than from the image header. Either wire this helper into the sample-list construction (e.g. to validate the CSV count against the actual volume shape) or remove it to avoid carrying dead code.
    def _num_slices(self, image_path: Path) -> int:
        shape = tuple(dim for dim in self._nib.load(str(image_path)).shape if dim != 1)
        if len(shape) < 2:
            raise ValueError(f"Expected at least 2D OASIS image, got shape {shape}.")
        return shape[1]

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +116 to +122
def _get_volume(self, subject_id: str) -> np.ndarray:
image_data = self._nib.load(str(self.subject_paths[subject_id])).get_fdata(dtype=np.float32)
volume = np.ascontiguousarray(
np.transpose(np.squeeze(image_data), (1, 0, 2)),
dtype=np.float32,
)
return volume
Comment thread mri_recon/utils/io.py
Comment on lines +86 to +94
with self.split_csv.open("r", encoding="utf-8") as handle:
for line in handle:
row = [item.strip() for item in line.split(",")]
if not row or not row[0]:
continue
try:
rows.append((row[0], int(row[-1])))
except ValueError:
continue
@MatthiasLen MatthiasLen merged commit b827afc into main May 15, 2026
6 checks passed
@MatthiasLen MatthiasLen deleted the oasis_unet_reconstruction branch May 15, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request recon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants