Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No such file or directory when running preprocessing_tutorial.ipynb locally #72

Closed
LennartPhil opened this issue Apr 17, 2024 · 8 comments
Assignees
Labels
question Further information is requested

Comments

@LennartPhil
Copy link

LennartPhil commented Apr 17, 2024

Describe the bug
When trying to run the preprocessing_tutorial.ipynb I get a FileNotFoundError, which reads
[Errno 2] No such file or directory: Path('/Users/XXXXXXXXX/Desktop/Uni/Prowiss/Code/preprocessing/temporary_directory/atlas-space/atlas__t1c.nii.gz')

Expected behavior
As I used the exact same files from the tutorial, I expected the test files to get preprocessed as described in there.

Environment

operating system and version?

mac OS Sonoma 14.3.1

NVIDIA drivers and GPUs

no NVIDIA drivers installed

Python environment and version?

running a virtual environment with python 3.11 installed

version of brainles_preprocessing ?

0.1.1

Additional context
I think I have roughly located the location of the error within the preprocessor.py file, as self.center_modality.current can't be found after the following lines

    print("Check 03")
    print("Checking existence of directory:", self.center_modality.current)
    print("Directory exists:", os.path.exists(self.center_modality.current))

    # Register center modality to atlas
    center_file_name = f"atlas__{self.center_modality.modality_name}"
    transformation_matrix = self.center_modality.register(
        registrator=self.registrator,
        fixed_image_path=self.atlas_image_path,
        registration_dir=self.atlas_dir,
        moving_image_name=center_file_name,
    )

    print("Check 04")
    print("Checking existence of directory:", self.center_modality.current)
    print("Directory exists:", os.path.exists(self.center_modality.current))

Output:
Check 03
Checking existence of directory: /Users/XXXXXXXXX/Desktop/Uni/Prowiss/Code/preprocessing/sample_data/TCGA-DU-7294/AX_T1_POST_GD_FLAIR_TCGA-DU-7294_TCGA-DU-7294_GE_TCGA-DU-7294_AX_T1_POST_GD_FLAIR_RM_13_t1c.nii.gz
Directory exists: True
Check 04
Checking existence of directory: /Users/XXXXXXXXX/Desktop/Uni/Prowiss/Code/preprocessing/temporary_directory/atlas-space/atlas__t1c.nii.gz
Directory exists: False

@neuronflow
Copy link
Collaborator

Thanks for your interest in our preprocessing pipeline. Could you specify a bit where exactly the tutorial crashes? Which registration backend do you use?

Do you have an Intel or ARM based Mac?

@MarcelRosier could you please have a look? Might be related to:
BrainLesion/HD-BET#1

@neuronflow neuronflow added the question Further information is requested label Apr 17, 2024
@LennartPhil
Copy link
Author

I'm trying to run the code on a Apple M3 Pro chip. What exactly do you mean by registration backend?

@neuronflow
Copy link
Collaborator

Ah this is probably the issue:

   preprocessor = Preprocessor(
            center_modality=center,
            moving_modalities=moving_modalities,
            registrator=NiftyRegRegistrator(),
            brain_extractor=HDBetExtractor(),
            # optional: we provide a temporary directory as a sandbox for the preprocessin
            temp_folder="temporary_directory",
            limit_cuda_visible_devices="0",
        )

Here, you can specify the registration backend:

             registrator=NiftyRegRegistrator(),

Niftyreg does not have Mac support. You could try ANTs or eReg(experimental).

So instead, supply another registrator:

from brainles_preprocessing.registration import (
    ANTsRegistrator,
    NiftyRegRegistrator,
    eRegRegistrator,
)

...

            # choose the registration backend you want to use
            # registrator=NiftyRegRegistrator(),
            registrator=ANTsRegistrator(),
            # registrator=eRegRegistrator(),
            

@evamariie could you please update the tutorial to tell users about the different registration backends?

Arguably, ANTs should be the default for the moment as it does not only support Linux like Niftyreg. And eReg is not fully tested yet.

@neuronflow
Copy link
Collaborator

@evamariie
Also, the readme needs to be updated, please prepare a PR :)
https://github.com/BrainLesion/preprocessing?tab=readme-ov-file#registration

@LennartPhil
Copy link
Author

Thank you for your help, changing the registrator to ANTs worked wonderfully. It might also be worth noting that when using HDBetExtractor on a arm processor, one must set the device to "cpu"

@neuronflow
Copy link
Collaborator

Thank you for your help, changing the registrator to ANTs worked wonderfully. It might also be worth noting that when using HDBetExtractor on a arm processor, one must set the device to "cpu"

Sweet, thanks for reporting back. Did you try with the most recent version of our package? Above you are indicating an older version.

@MarcelRosier recently implemented a fix, which should fix the CPU issue:
BrainLesion/HD-BET#2

@LennartPhil
Copy link
Author

My bad, using the newest version resolved the cpu workaround as well

@neuronflow
Copy link
Collaborator

Sweet, thanks for reporting back, and I'm glad everything could be resolved. We highly appreciate feedback as we are still in an earlier stage of development :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants