Skip to content

Commit

Permalink
set a timeout on socket connections (8 s) (nilearn#2461)
Browse files Browse the repository at this point in the history
* set a timeout on socket connections (8 s)
  • Loading branch information
jeromedockes authored May 20, 2020
1 parent 02b6ae5 commit b021ba9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions examples/07_advanced/plot_ica_neurovault.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@
print("Fetching Neurovault images; "
"if you haven't downloaded any Neurovault data before "
"this will take several minutes.")
nv_data = fetch_neurovault(max_images=80, fetch_neurosynth_words=True)
nv_data = fetch_neurovault(max_images=30, fetch_neurosynth_words=True)

images = nv_data['images']
term_weights = nv_data['word_frequencies']
vocabulary = nv_data['vocabulary']
if term_weights is None:
term_weights = np.ones((len(images), 2))
vocabulary = np.asarray(
["Neurosynth is down", "Please try again later"])

# Clean and report term scores
term_weights[term_weights < 0] = 0
Expand Down Expand Up @@ -103,7 +107,7 @@
# We use a very small number of components as we have downloaded only 80
# images. For better results, increase the number of images downloaded
# and the number of components
n_components = 16
n_components = 8
fast_ica = FastICA(n_components=n_components, random_state=0)
ica_maps = fast_ica.fit_transform(X.T).T

Expand Down
3 changes: 3 additions & 0 deletions nilearn/datasets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
import sys
import tarfile
import urllib
import socket
import warnings
import zipfile

socket.setdefaulttimeout(8)


def md5_hash(string):
m = hashlib.md5()
Expand Down

0 comments on commit b021ba9

Please sign in to comment.