StanfordMIMI / skm-tea

Repository for the Stanford Knee MRI Multi-Task Evaluation (SKM-TEA) Dataset
MIT License
77 stars 15 forks source link

data transform precompute masks function gets stuck in loop forever at 433 it #9

Closed anilrgukt closed 2 years ago

anilrgukt commented 2 years ago

You can use the below code to reproduce it.

import os
os.environ["MEDDLR_DATASETS_DIR"] = "/mnt/datadir"

import sys 
sys.path.insert(0, './skm-teacode/')

from meddlr.data.transforms.subsample import build_mask_func
from skm_tea.data.transform import qDESSDataTransform

from meddlr.config import get_cfg

cfg = get_cfg()
cfg.merge_from_file('./skm-teacode/configs/baselines-neurips/raw-data-track/recon/unet.yaml')  ###
cfg.format_fields(unroll=True)
cfg.freeze()

mask_func_kwargs = (
    {"module": "sigpy"} # if cfg.AUG_TRAIN.UNDERSAMPLE.NAME == "PoissonDiskMaskFunc" else {}
)
mask_func = build_mask_func(cfg.AUG_TRAIN, **mask_func_kwargs)
data_transform = qDESSDataTransform(cfg, mask_func=mask_func, is_test=False)
print('precomputing the masks')
data_transform._subsampler.precompute_masks(
                acq_shapes={(416, 80), (416, 88), (416, 72)},
                N=100000,
                accelerations=8, # ADDED 
                seed=123,
                cache='./check_precomp_masks/',
                num_workers=0
                )
anilrgukt commented 2 years ago

And some seed values result in ValueError: Cannot generate mask to satisfy accel=8 from sigpy/mri/samp.py library. Is there a right parameter configuration?

thanks, Anil

ad12 commented 2 years ago

Hi Anil, thanks for these questions. There is an ongoing issue in the meddlr repository (one of the dependencies) that notes the Poisson Disc generation in sigpy can hang. We are working on finding a long-term solution.

For now, I would recommend downloading the masks from Google drive and moving them to the appropriate cache folder. We will add a utility for doing this in our upcoming minor release.

If you would like to precompute the masks yourself, I would recommend setting seed=None. It may also be useful to increase the num_workers count to speed up the computation.

anilrgukt commented 2 years ago

zarr library is not able to open the precomputed masks

import zarr
import os

PATH='./precomputed-masks/N=100000-acc=None-mode=2D-seed=None--PoissonDiskMaskFunc-accelerations=(8,)-calib_size=(24, 24)-max_attempts=5-crop_corner=True.zarr'
if os.path.exists(PATH):
    f = zarr.open(PATH,mode="r")

results in zarr.errors.PathNotFoundError: nothing found at path ''

I tried with absolute path as well and running into the same error. I tried f = zarr.open(path=PATH, mode="r"). Is there anything that I am missing?

thanks, Anil

ad12 commented 2 years ago

Thanks for the catch - just fixed the file and it works with the code above

ad12 commented 2 years ago

Closing for now but feel free to open this again.