CERN / TIGRE

TIGRE: Tomographic Iterative GPU-based Reconstruction Toolbox
BSD 3-Clause "New" or "Revised" License
529 stars 180 forks source link

TIGRE installed with pip fails to load_head_phantom #493

Closed ChemEng227 closed 7 months ago

ChemEng227 commented 9 months ago

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 https://github.com/CERN/TIGRE/commit/0638104b7e411b127c0e65eefd19bde219b23313 . TIGRE was compiled and installed with pip install ..

Specifications

ChemEng227 commented 9 months ago

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

AnderBiguri commented 9 months ago

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.

tsadakane commented 9 months ago

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...

AnderBiguri commented 9 months ago

@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.

AnderBiguri commented 8 months ago

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