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

Hi it seems like something's wrong with the address of the example dataset #5

Open
AndiIsBroke opened this issue Feb 28, 2020 · 4 comments

Comments

@AndiIsBroke
Copy link

AndiIsBroke commented Feb 28, 2020

Hey guys, I'm new to nipype and was tryna run the 'smri_ants_registration.py' example and here's the 404 error:

(testenv) [hanad@ln01 ~]$ python py.py
/gs/home/hanad/nipypeTestPath
Traceback (most recent call last):
  File "py.py", line 52, in <module>
    remotefile = urllib.request.urlopen(myURL)
  File "/gs/home/hanad/.conda/envs/testenv/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/gs/home/hanad/.conda/envs/testenv/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/gs/home/hanad/.conda/envs/testenv/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/gs/home/hanad/.conda/envs/testenv/lib/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/gs/home/hanad/.conda/envs/testenv/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/gs/home/hanad/.conda/envs/testenv/lib/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

dunno if that means something went wrong with my env or the dataset. Pls help.
Andi 28Feb

@effigies
Copy link
Member

Hi @AndiIsBroke, could you share the contents of py.py?

@kaczmarj
Copy link
Member

The urls return 404 errors:

MyFileURLs = [
('http://slicer.kitware.com/midas3/download?bitstream=13121',
'01_T1_half.nii.gz'),
('http://slicer.kitware.com/midas3/download?bitstream=13122',
'02_T1_half.nii.gz'),

jakub@dash:~$ curl --fail --head http://slicer.kitware.com/midas3/download?bitstream=13121
curl: (22) The requested URL returned error: 404 Not Found
jakub@dash:~$ curl --fail --head http://slicer.kitware.com/midas3/download?bitstream=13122
curl: (22) The requested URL returned error: 404 Not Found

@effigies
Copy link
Member

Ah, good find. I was unable to find files by those names in https://slicer.kitware.com/midas3/folder/298.

It looks this example was contributed by @hjmjohnson in nipy/nipype@c2c10ef. Possibly he might know how to find these?

@AndiIsBroke
Copy link
Author

AndiIsBroke commented Feb 29, 2020

Hi @AndiIsBroke, could you share the contents of py.py?

pls see below
`
#!/usr/bin/env python

emacs: -- mode: python; py-indent-offset: 4; indent-tabs-mode: nil --

vi: set ft=python sts=4 ts=4 sw=4 et:

from future import print_function, unicode_literals
from builtins import open

from future import standard_library

standard_library.install_aliases()

import os

import urllib.request
import urllib.error
import urllib.parse

from nipype.interfaces.ants import Registration
from nipype.testing import example_data

homeDir = os.getenv("HOME")
requestedPath = os.path.join(homeDir, 'nipypeTestPath')
mydatadir = os.path.realpath(requestedPath)
if not os.path.exists(mydatadir):
os.makedirs(mydatadir)
print(mydatadir)

MyFileURLs = [
('http://slicer.kitware.com/midas3/download?bitstream=13121',
'01_T1_half.nii.gz'),
('http://slicer.kitware.com/midas3/download?bitstream=13122',
'02_T1_half.nii.gz'),
]
for tt in MyFileURLs:
myURL = tt[0]
localFilename = os.path.join(mydatadir, tt[1])
if not os.path.exists(localFilename):
remotefile = urllib.request.urlopen(myURL)

    localFile = open(localFilename, 'wb')
    localFile.write(remotefile.read())
    localFile.close()
    print("Downloaded file: {0}".format(localFilename))
else:
    print("File previously downloaded {0}".format(localFilename))

input_images = [
os.path.join(mydatadir, '01_T1_half.nii.gz'),
os.path.join(mydatadir, '02_T1_half.nii.gz'),
]

reg = Registration(
from_file=example_data('smri_ants_registration_settings.json'))
reg.inputs.fixed_image = input_images[0]
reg.inputs.moving_image = input_images[1]

`
it's just an example given by nipype

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

3 participants