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

Templates not loaded on Windows #89

Closed
ChristianNSchmitz opened this issue Feb 8, 2022 · 4 comments
Closed

Templates not loaded on Windows #89

ChristianNSchmitz opened this issue Feb 8, 2022 · 4 comments

Comments

@ChristianNSchmitz
Copy link

ChristianNSchmitz commented Feb 8, 2022

Hello,
we are using the templateflow python-client both on a Windows and Linux environment (WSL system) using anaconda with python 3.9. Whereas the WSL system loads the templates just fine, the templates are not loaded on the Windows environment (similar to templateflow/tpl-MNI152NLin2009cAsym#6). Initially, I thought this might be due to an erroneous SSL certificate (oftentimes the reason for issues at our institute), but both systems use the identical certificate. I tried both with and without the datalad option.
Thus, I would like to ask you whether there could be a problem with the windows system.
If you need any other information, please let me know!
Thanks a lot!
Christian

@oesteban
Copy link
Member

oesteban commented May 7, 2022

We will need further information to understand the problem. What templates are affected? In all the cases was the download successful for Linux but wasn't for Windows?

@mfschmidt
Copy link
Contributor

mfschmidt commented Apr 15, 2023

I think I can provide the necessary details here. I usually use linux without issue, but was trying to hack at a script in Windows and ran into this issue. It also popped up on neurostars. I was going to respond to that, but thought it would be more appropriate here.

When I try to replicate the error at the neurostars post, I get this in my python console.

Downloading https://templateflow.s3.amazonaws.com/tpl-MNI152NLin2009cAsym\tpl-MNI152NLin2009cAsym_res-02_atlas-HOSPA_desc-th25_dseg.nii.gz

Note the correct forward slashes in the url up to right before the filename, where there's a backslash instead. I can open the .nii.gz file in a text editor and read the xml error about how the file was not found.

<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>tpl-MNI152NLin2009cAsym\tpl-MNI152NLin2009cAsym_res-02_atlas-HOSPA_desc-th25_dseg.nii.gz</Key>
<RequestId>F1MJ79MTW7J2SPVK</RequestId>
<HostId>fxINO/E5QXCEhYuq8/p1EWsIwUTosPWwWNNVexR3R7P9tHWtQYue1TiOMYy4FNSuLMH4/MnyVE0=</HostId>
</Error>

The .nii.gz file is no longer zero-length and won't get overwritten, even though it's not a nifti file. I just get errors when I try to access it with nibabel.

I would say this is a bug in the templateflow code (probably because Windows is rarely used and it works fine on platforms using forward slashes?) at this line. When I manually execute the filepath function on Windows, the "subdir\filename" has that one backslash that wrecks the url when it's concatenated together on the next line. I verified on my Windows machine that

"subdir\\filename".replace("\\", "/")

correctly replaces the backslash.

@mfschmidt
Copy link
Contributor

I have submitted a pull request that fixes this at #107. It fixes the problem on my Windows installation, and still works on linux for me.

In addition to fixing this issue #89, I believe these other issues are the same:
#82
#69

@effigies
Copy link
Contributor

effigies commented Nov 3, 2023

Should be resolved in 23.1.0.

@effigies effigies closed this as completed Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants