-
Notifications
You must be signed in to change notification settings - Fork 58
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
[ENH] rudimentary support for nimads #763
Changes from all commits
edc3521
562731c
83cbdc8
485faac
b42c89d
1b0072f
0d1fbb3
5262c61
6aa9788
cbe57cd
9f13241
910037e
f8a1377
3684e89
69cb840
56d935b
9dc93b3
612b595
fab9c4f
7f01880
7d8394e
fb5f05c
2051086
3ef5eb1
3993cb6
4f08818
afae242
4092e52
e87e46c
c691c37
586f603
6bac7db
39f91ec
833bf2f
3145965
e27edc7
3b55549
7d2a540
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
""" | ||
|
||
.. _nimads_object: | ||
|
||
======================== | ||
Using NIMADS with NiMARE | ||
======================== | ||
|
||
How to use the NeuroImaging Meta-Analysis Data Structure | ||
`(NIMADS) <https://neurostuff.github.io/NIMADS/>`_ with NiMARE. | ||
""" | ||
from requests import request | ||
|
||
from nimare.io import convert_nimads_to_dataset | ||
from nimare.nimads import Studyset | ||
|
||
############################################################################### | ||
# Download Data from NeuroStore | ||
# ----------------------------------------------------------------------------- | ||
|
||
|
||
def download_file(url): | ||
"""Download a file from NeuroStore.""" | ||
response = request("GET", url) | ||
return response.json() | ||
|
||
|
||
nimads_studyset = download_file( | ||
"https://neurostore.org/api/studysets/Cv2LLUqG76W9?nested=true" | ||
) | ||
nimads_annotation = download_file( | ||
"https://neurostore.org/api/annotations/76PyNqoTNEsE" | ||
) | ||
|
||
|
||
############################################################################### | ||
# Load Data | ||
# ----------------------------------------------------------------------------- | ||
# Load the json files into a NiMADS Studyset object. | ||
|
||
studyset = Studyset(nimads_studyset, nimads_annotation) | ||
|
||
|
||
############################################################################### | ||
# Convert to NiMARE Dataset | ||
# ----------------------------------------------------------------------------- | ||
# Convert the NiMADS Studyset object to a NiMARE Dataset object. | ||
# Then you can run NiMARE analyses on the Dataset object. | ||
|
||
nimare_dset = studyset.to_dataset() | ||
nimare_dset.coordinates.head() | ||
|
||
############################################################################### | ||
# Directly to NiMARE Dataset | ||
# ----------------------------------------------------------------------------- | ||
# Alternatively, you can convert the NiMADS json files directly to a NiMARE Dataset object | ||
# if you wish to skip using the nimads studyset object directly. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When does it make sense to use the Studyset object directly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I consider this the first step towards replacing the nimare dataset object with the nimads studyset object, right now there is not much benefit besides the representation/terms being more consistent (e.g., analysis is called contrast in a nimare dset). but eventually, a user should be able to use a studyset object with all the estimators and have it work. |
||
|
||
nimare_dset_2 = convert_nimads_to_dataset(nimads_studyset, nimads_annotation) | ||
nimare_dset_2.coordinates.head() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment: I'm not sure this function is that useful since you only use it twice (below).
Maybe you could make this more useful and use it throughout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, my threshold for wanting to write a function was pretty low, it's possible other examples could be downloaded down the line using this function.