Oasis unet reconstruction#40
Conversation
There was a problem hiding this comment.
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 👍
…oasis_unet_reconstruction # Conflicts: # README.md # examples/fastmri_inference_plot.py # mri_recon/reconstruction/deep.py # mri_recon/utils/__init__.py
|
Dear @MatthiasLen, I have updated the PR by:
If there is any other issues feel free to suggest |
There was a problem hiding this comment.
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 undermri_recon/utils/oasis_adapter.py, plus a Google Drive downloader inmri_recon/utils/io.py. - New
OASISSinglecoilUnetReconstructorwith manifest-based checkpoint resolution and a Lightning-aware state-dict loader inmri_recon/reconstruction/deep.py. - New
PartialFourierDistortion, expandedaxischoices forCartesianUndersampling, and OASIS path inexamples/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_slicesis defined but never referenced anywhere in the codebase._create_sample_listderives 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.
| 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 |
| 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 |
Summary
Tests