Skip to content

Commit

Permalink
added 35-shell isbi2015 data
Browse files Browse the repository at this point in the history
  • Loading branch information
rutgerfick committed Feb 19, 2018
1 parent 986e2ff commit 19ea3f6
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 2 deletions.
24 changes: 23 additions & 1 deletion dmipy/data/saved_acquisition_schemes.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import numpy as np
from os.path import join
import os
import pkg_resources
import urllib2
from ..core.acquisition_scheme import (
acquisition_scheme_from_bvalues,
acquisition_scheme_from_gradient_strengths)
acquisition_scheme_from_gradient_strengths,
acquisition_scheme_from_schemefile)

_GRADIENT_TABLES_PATH = pkg_resources.resource_filename(
'dmipy', 'data/gradient_tables'
Expand Down Expand Up @@ -66,3 +69,22 @@ def duval_cat_spinal_cord_3d_acquisition_scheme():
TE[:] = 0.0472
return acquisition_scheme_from_gradient_strengths(
G, bvecs, delta, Delta, TE, min_b_shell_distance=20e6)


def isbi2015_white_matter_challenge_scheme():
"Returns 35-shell ISBI 2015 challenge DmipyAcquisitionScheme."
isbi_data_path = join(DATA_PATH, 'isbi2015_white_matter_challenge')
if not os.path.exists(isbi_data_path):
os.makedirs(isbi_data_path)

path_schemefile = (
"http://cmic.cs.ucl.ac.uk/wmmchallenge/ISBIdata/seenScheme.txt")
filename = 'isbi_schemefile.txt'

response = urllib2.urlopen(path_schemefile)
data = response.read()
file_ = open(join(isbi_data_path, filename), 'w')
file_.write(data)
file_.close()

return acquisition_scheme_from_schemefile(join(isbi_data_path, filename))
51 changes: 51 additions & 0 deletions dmipy/data/saved_data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from os.path import join
import os
import urllib2
import pkg_resources
import nibabel as nib
import numpy as np
Expand Down Expand Up @@ -128,6 +130,55 @@ def __init__(self):
return scheme, data


def isbi2015_white_matter_challenge():
"""
Downloads and returns the 35-shell multi-delta/Delta/G scheme and data for
the fornix and genu data that was used for the ISBI 2015 white matter
challenge [1]_.
Returns
-------
scheme: DmipyAcquisitionScheme instance,
acquisition scheme of the challenge data.
data_genu: array of size (3612, 6),
contains the DWIs for 6 genu voxels.
data_fornix: array of size (3612, 6),
contains the DWIs for 6 fornix voxels.
References
----------
.. [1] Ferizi, Uran, et al. "Diffusion MRI microstructure models with in
vivo human brain Connectome data: results from a multi-group
comparison." NMR in Biomedicine 30.9 (2017)
"""
isbi_data_path = join(DATA_PATH, 'isbi2015_white_matter_challenge')

if not os.path.exists(isbi_data_path):
os.makedirs(isbi_data_path)

path_genu = (
"http://cmic.cs.ucl.ac.uk/wmmchallenge/ISBIdata/seenSignal.txt")
path_fornix = (
"http://cmic.cs.ucl.ac.uk/wmmchallenge/ISBIdata/seenSignaX.txt")

filenames = ['genu.txt', 'fornix.txt']
paths = [path_genu, path_fornix]

for filename, path in zip(filenames, paths):
response = urllib2.urlopen(path)
data = response.read()
file_ = open(join(isbi_data_path, filename), 'w')
file_.write(data)
file_.close()

data_genu = np.loadtxt(join(isbi_data_path, 'genu.txt'), skiprows=1)
data_fornix = np.loadtxt(join(isbi_data_path, 'fornix.txt'), skiprows=1)
scheme = (
saved_acquisition_schemes.isbi2015_white_matter_challenge_scheme()
)
return scheme, data_genu, data_fornix


def synthetic_camino_data_parallel():
"""The parallel data was generated using the Camino Monte-Carlo
Diffusion Simulator. See http://camino.cs.ucl.ac.uk/.
Expand Down
4 changes: 3 additions & 1 deletion dmipy/data/tests/test_saved_data.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from dmipy.data.saved_data import (
duval_cat_spinal_cord_2d,
duval_cat_spinal_cord_3d
duval_cat_spinal_cord_3d,
isbi2015_white_matter_challenge
)


def test_loading_saved_duval_data_2dand3d():
scheme, data = duval_cat_spinal_cord_2d()
scheme, data = duval_cat_spinal_cord_3d()
scheme, data1, data2 = isbi2015_white_matter_challenge()

0 comments on commit 19ea3f6

Please sign in to comment.