CERN/TIGRE

TIGRE installed with pip fails to load_head_phantom

ChemEng227 opened this issue · 5 comments

Expected Behavior

tigre.utilities.sample_loader.load_head_phantom shall reutrn a shepp-logan head phantom.

Actual Behavior

an FileNotFoundError was thrown.
the Error info was:
FileNotFoundError: [Errno 2] No such file or directory: '/path/to/anaconda3/envs/TIGRE/lib/python3.11/site-packages/tigre/utilities/./../../data/head.mat'

Code to reproduce the problem (If applicable)

any python demo.
The TIGRE source was downloaded directly from github, at commit 0638104 .
TIGRE was compiled and installed with pip install ..

Specifications

  • MATLAB/python version:3.10.4
  • OS: Ubuntu 22.04 LTS
  • CUDA version: 12.2

Yes, I know this issue could be fixed simply by copy-pasting some files. I just want to report that such issue exists.

Thanka for the report! This is an unintended bug from recent change to pip install.

I theory, "python setup.py install" should still work and do it correctly. Trying to fix this at the moment.

Thank you for the report. I could reproduce the phenomena, and found that head.mat was located at /path/to/anaconda3/envs/conda_env_name/data/head.mat.

It can be fixed if sample_loader.py is modified as...

def load_head_phantom(number_of_voxels=None):
    if number_of_voxels is None:
        number_of_voxels = np.array((128, 128, 128))
    list_relative_path = [
        "../../../Common/data/head.mat", # Local
        "../../data/head.mat",   # setup.py
        "../../../../data/head.mat"  # pip 
    ]
    found = False
    for relative_path in list_relative_path:
        abs_path = os.path.join(os.path.dirname(__file__), relative_path)
        if os.path.isfile(abs_path):
            found = True
            break
    if found:
        test_data = scipy.io.loadmat(abs_path)
        
    # Loads data in F_CONTIGUOUS MODE (column major), convert to Row major

I think there must be a more elegant way, though...

@tsadakane Ideally we slowly deprecate using setup.py and only advocate for pip, so we can only have the pip one I think, however maybe this is a good temporary solution until we make sure pip works 100%.

#492 is vague, but it has only started happening since the pip install update for me, and some others have also reported the issue, but I am not 100% sure if its caused by it, I will do tests this week.

This has been now added to the latest commit, once I can verify it works in a couple of other machines I can close the issue