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

RF + DOC: Add MNI template reference. Also import it into the dipy.da… #681

Merged
merged 4 commits into from Aug 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion dipy/data/__init__.py
Expand Up @@ -47,7 +47,9 @@ def loads_compat(bytes):
fetch_stanford_pve_maps,
read_stanford_pve_maps,
fetch_cenir_multib,
read_cenir_multib)
read_cenir_multib,
fetch_mni_template,
read_mni_template)

from ..utils.arrfuncs import as_native_array
from dipy.tracking.streamline import relist_streamlines
Expand Down
87 changes: 50 additions & 37 deletions dipy/data/fetcher.py
Expand Up @@ -557,36 +557,60 @@ def read_syn_data():
b0 = nib.load(b0_name)
return t1, b0

mni_notes = \
"""
Notes
-----
The templates were downloaded from the MNI (McGill University) `website <http://www.bic.mni.mcgill.ca/ServicesAtlases/ICBM152NLin2009>`_
in July 2015.

The following publications should be referenced when using these templates:

.. [1] VS Fonov, AC Evans, K Botteron, CR Almli, RC McKinstry, DL Collins
and BDCG, Unbiased average age-appropriate atlases for pediatric
studies, NeuroImage, 54:1053-8119, DOI: 10.1016/j.neuroimage.2010.07.033

.. [2] VS Fonov, AC Evans, RC McKinstry, CR Almli and DL Collins,
Unbiased nonlinear average age-appropriate brain templates from
birth to adulthood, NeuroImage, 47:S102
Organization for Human Brain Mapping 2009 Annual Meeting,
DOI: http://dx.doi.org/10.1016/S1053-8119(09)70884-5

License for the MNI templates:
-----------------------------
Copyright (C) 1993-2004, Louis Collins McConnell Brain Imaging Centre,
Montreal Neurological Institute, McGill University. Permission to use,
copy, modify, and distribute this software and its documentation for any
purpose and without fee is hereby granted, provided that the above
copyright notice appear in all copies. The authors and McGill University
make no representations about the suitability of this software for any
purpose. It is provided "as is" without express or implied warranty. The
authors are not responsible for any data loss, equipment damage, property
loss, or injury to subjects or patients resulting from the use or misuse
of this software package.
"""



def fetch_mni_template():
"""
Fetch the MNI T2 and T1 template files (~35 MB)
"""
url = \
folder = pjoin(dipy_home, 'mni_template')
baseurl = \
'https://digital.lib.washington.edu/researchworks/bitstream/handle/1773/33312/'

fname_list = ['COPYING',
'mni_icbm152_t2_tal_nlin_asym_09a.nii',
'mni_icbm152_t1_tal_nlin_asym_09a.nii']
url_list = [url + ff for ff in fname_list]
md5_list = ['6e2168072e80aa4c0c20f1e6e52ec0c8',
'f41f2e1516d880547fbf7d6a83884f0d',
'1ea8f4f1e41bc17a94602e48141fdbc8']
folder = pjoin(dipy_home, 'mni_template')
if not os.path.exists(folder):
print('Creating new directory %s' % folder)
os.makedirs(folder)
print('Downloading T2 and T1 MNI templates (~35 MB)...')

for i in range(len(md5_list)):
_get_file_data(pjoin(folder, fname_list[i]), url_list[i])
check_md5(pjoin(folder, fname_list[i]), md5_list[i])

print('Done.')
print('Files copied in folder %s' % folder)
print("The copyright notice is provided in the file: %s" %
pjoin(folder, fname_list[0]))
else:
_already_there_msg(folder)
files = {}
for f, m in zip(fname_list, md5_list):
files[f] = (baseurl + f, m)
fetch_data(files, folder)
return files, folder


def read_mni_template(contrast="T2"):
Expand All @@ -611,33 +635,22 @@ def read_mni_template(contrast="T2"):
>>> T2_nifti = read_mni_template("T2") # doctest: +SKIP
Get both files in this order:
>>> T1_nifti, T2_nifti = read_mni_template(["T1", "T2"]) # doctest: +SKIP

"""
folder = pjoin(dipy_home, 'mni_template')
files, folder = fetch_mni_template()
file_dict = {"T1":pjoin(folder, 'mni_icbm152_t1_tal_nlin_asym_09a.nii'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @arokem, why do you prefer the ICBM152 2009a version and not the 2009c version?
http://www.bic.mni.mcgill.ca/ServicesAtlases/ICBM152NLin2009

Also now that you are on it can you also fetch the rest of the maps PDs etc?
We can definitely use them for other projects like the Tissue classifiers etc.

I would recommend fetching the 1x1x1 atlases but also fetching the 0.5x0.5x0.5
atlases those will be useful for performing high resolution anatomical tracking.

I hope this is not much to ask. It would be great to fetch the IIT atlas too at some point.
I will need to ask permission from Arfanakis for that. But I think it's possible!
Exciting!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'c' atlas is symmetric, and so does not represent an average brain. It's main use is when you want to compare directly between the two hemispheres, so I don't think it should be the default.

It sounds like the IIT atlas has an inconvenient license, so we should be careful when fetching that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt about that @matthew-brett It clearly says in the MNI website
http://www.bic.mni.mcgill.ca/ServicesAtlases/ICBM152NLin2009
that there is a symmetric and asymmetric version of the 'c' atlas.
Look at the last bullet point.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know well the person who wrote the atlas and I don't think he had the intention to have a hard-boiled license. I will speak to him about that. Maybe they would love to update their license. Or they don't mind fetching it in DIPY.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes - sorry - you are right about 2009c. Then - do you know the difference between 2009a and 2009c? The page mentions only the different version numbers for the intensity correction method and different 'resampling'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No rush. The ROIs that we are using for tractography segmentation are all
based on the MNI template anyway.

On Thu, Aug 6, 2015 at 10:18 AM, Samuel St-Jean notifications@github.com
wrote:

In dipy/data/fetcher.py
#681 (comment):

 """
  • folder = pjoin(dipy_home, 'mni_template')
  • files, folder = fetch_mni_template()
    file_dict = {"T1":pjoin(folder, 'mni_icbm152_t1_tal_nlin_asym_09a.nii'),

They also have a seperate license for commercial and non commercial usage,
so maybe you can just point a download link for people while the
re-licensing happens, so that people might have it in the meantime if it's
that important.


Reply to this email directly or view it on GitHub
https://github.com/nipy/dipy/pull/681/files#r36440520.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(that might also be the reason we are using 'a')

On Thu, Aug 6, 2015 at 10:20 AM, Ariel Rokem arokem@gmail.com wrote:

No rush. The ROIs that we are using for tractography segmentation are all
based on the MNI template anyway.

On Thu, Aug 6, 2015 at 10:18 AM, Samuel St-Jean notifications@github.com
wrote:

In dipy/data/fetcher.py
#681 (comment):

 """
  • folder = pjoin(dipy_home, 'mni_template')
  • files, folder = fetch_mni_template()
    file_dict = {"T1":pjoin(folder, 'mni_icbm152_t1_tal_nlin_asym_09a.nii'),

They also have a seperate license for commercial and non commercial
usage, so maybe you can just point a download link for people while the
re-licensing happens, so that people might have it in the meantime if it's
that important.


Reply to this email directly or view it on GitHub
https://github.com/nipy/dipy/pull/681/files#r36440520.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no preference for a as oppose to c. If c is better, let's go with
that

On Thursday, August 6, 2015, Ariel Rokem notifications@github.com wrote:

In dipy/data/fetcher.py
#681 (comment):

 """
  • folder = pjoin(dipy_home, 'mni_template')
  • files, folder = fetch_mni_template()
    file_dict = {"T1":pjoin(folder, 'mni_icbm152_t1_tal_nlin_asym_09a.nii'),

No rush. The ROIs that we are using for tractography segmentation are all
based on the MNI template anyway.
… <#14f040978a952b82_>
On Thu, Aug 6, 2015 at 10:18 AM, Samuel St-Jean <notifications@github.com
javascript:_e(%7B%7D,'cvml','notifications@github.com');> wrote: In
dipy/data/fetcher.py <
https://github.com/nipy/dipy/pull/681#discussion_r36440520>: > """ > -
folder = pjoin(dipy_home, 'mni_template') > + files, folder =
fetch_mni_template() > file_dict = {"T1":pjoin(folder,
'mni_icbm152_t1_tal_nlin_asym_09a.nii'), They also have a seperate license
for commercial and non commercial usage, so maybe you can just point a
download link for people while the re-licensing happens, so that people
might have it in the meantime if it's that important. — Reply to this email
directly or view it on GitHub <
https://github.com/nipy/dipy/pull/681/files#r36440520>.


Reply to this email directly or view it on GitHub
https://github.com/nipy/dipy/pull/681/files#r36440755.

Jason D. Yeatman, PhD
Assistant Professor, Institute for Learning & Brain Sciences (I-LABS)
Department of Speech & Hearing Sciences
University of Washington
http://depts.washington.edu/bdelab/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably the ROIs were made based on 'a'?

On Thu, Aug 6, 2015 at 11:03 AM, Jason D. Yeatman notifications@github.com
wrote:

In dipy/data/fetcher.py
#681 (comment):

 """
  • folder = pjoin(dipy_home, 'mni_template')
  • files, folder = fetch_mni_template()
    file_dict = {"T1":pjoin(folder, 'mni_icbm152_t1_tal_nlin_asym_09a.nii'),

I have no preference for a as oppose to c. If c is better, let's go with
that
… <#14f042e76c609d20_>
On Thursday, August 6, 2015, Ariel Rokem notifications@github.com
wrote: In dipy/data/fetcher.py <
https://github.com/nipy/dipy/pull/681#discussion_r36440755>: > """ > -
folder = pjoin(dipy_home, 'mni_template') > + files, folder =
fetch_mni_template() > file_dict = {"T1":pjoin(folder,
'mni_icbm152_t1_tal_nlin_asym_09a.nii'), No rush. The ROIs that we are
using for tractography segmentation are all based on the MNI template
anyway. … <#14f040978a952b82_> On Thu, Aug 6, 2015 at 10:18 AM, Samuel
St-Jean <notifications@github.com <javascript:_e(%7B%7D,'cvml','
notifications@github.com');>> wrote: In dipy/data/fetcher.py <
https://github.com/nipy/dipy/pull/681#discussion_r36440520>: > """ > -
folder = pjoin(dipy_home, 'mni_template') > + files, folder =
fetch_mni_template() > file_dict = {"T1":pjoin(folder,
'mni_icbm152_t1_tal_nlin_asym_09a.nii'), They also have a seperate license
for commercial and non commercial usage, so maybe you can just point a
download link for people while the re-licensing happens, so that people
might have it in the meantime if it's that important. — Reply to this email
directly or view it on GitHub <
https://github.com/nipy/dipy/pull/681/files#r36440520>. — Reply to this
email directly or view it on GitHub <
https://github.com/nipy/dipy/pull/681/files#r36440755>.
-- Jason D. Yeatman, PhD Assistant Professor, Institute for Learning &
Brain Sciences (I-LABS) Department of Speech & Hearing Sciences University
of Washington http://depts.washington.edu/bdelab/


Reply to this email directly or view it on GitHub
https://github.com/nipy/dipy/pull/681/files#r36445341.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guys, you can fetch both and check if the ROIs correspond.

"T2":pjoin(folder, 'mni_icbm152_t2_tal_nlin_asym_09a.nii')}

md5_dict = {'T1': '1ea8f4f1e41bc17a94602e48141fdbc8',
'T2': 'f41f2e1516d880547fbf7d6a83884f0d'}

try:
# If a string was provided, you only wanted one of them:
if isinstance(contrast, str):
check_md5(file_dict[contrast], md5_dict[contrast])
return nib.load(file_dict[contrast])

# Otherwise, we construct a list of outputs
if isinstance(contrast, str):
return nib.load(file_dict[contrast])
else:
out_list = []
for k in contrast:
check_md5(file_dict[k], md5_dict[k])
out_list.append(nib.load(file_dict[k]))
return out_list

return out_list

except IOError:
msg = "Could not find the MNI template files, "
msg += "please run `fetch_mni_template` first"
print(msg)
# Add the references to both MNI-related functions:
read_mni_template.__doc__ += mni_notes
fetch_mni_template.__doc__ += mni_notes


def fetch_cenir_multib(with_raw=False):
Expand Down