Skip to content
Snippets Groups Projects
Commit 30ba861a authored by Jan Fousek's avatar Jan Fousek
Browse files

HDG access check and request

parent aede6704
No related branches found
Tags 8.0.6
No related merge requests found
%% Cell type:markdown id:ef541df6-5c1a-4a0f-a069-24f110a7bf1d tags: %% Cell type:markdown id:ef541df6-5c1a-4a0f-a069-24f110a7bf1d tags:
## 1000BRAINS study, connectivity data ## 1000BRAINS study, connectivity data
%% Cell type:code id:5b441713-77b4-4e57-a188-9959c09784bd tags: %% Cell type:code id:5b441713-77b4-4e57-a188-9959c09784bd tags:
``` python ``` python
from tvb_ebrains_data import Brains1000Dataset from tvb_ebrains_data import Brains1000Dataset
``` ```
%% Output
2022-02-11 11:40:43,461 - WARNING - tvb.simulator.common - psutil module not available: no warnings will be issued when a
simulation may require more memory than available
INFO log level set to INFO
/home/izaak/local_repos/nostromo/tvb-ebrains-data/env/lib/python3.6/site-packages/tvb/datatypes/surfaces.py:63: UserWarning: Geodesic distance module is unavailable; some functionality for surfaces will be unavailable.
warnings.warn(msg)
WARNING Token required outside collaboratory environment. Set EBRAINS_TOKEN in the environment or provide directly.
%% Cell type:code id:2f47000a-9bbe-4ecb-bac1-b09490af7d7b tags: %% Cell type:code id:2f47000a-9bbe-4ecb-bac1-b09490af7d7b tags:
``` python ``` python
dataset = Brains1000Dataset() dataset = Brains1000Dataset()
print(dataset.__doc__) print(dataset.__doc__)
``` ```
%% Output %% Output
Caspers, S. et al (2021). Caspers, S. et al (2021).
1000BRAINS study, connectivity data. 1000BRAINS study, connectivity data.
https://doi.org/10.25493/6640-3XH v1.0: https://doi.org/10.25493/61QA-KP8
v1.1: https://doi.org/10.25493/6640-3XH
%% Cell type:code id:af94d470-386c-4b33-ab1a-5c4b9482c535 tags:
``` python
dataset.have_access()
```
%% Output
True
%% Cell type:markdown id:38af980a-7a02-4a13-947a-729f84494c96 tags:
If the call above returns `False`, the access request can be triggered by visiting the KG page of the dataset, or calling:
```python
dataset.request_access()
```
%% Cell type:code id:f608b41a-2bff-47b6-b30d-c99810cdb1f4 tags: %% Cell type:code id:f608b41a-2bff-47b6-b30d-c99810cdb1f4 tags:
``` python ``` python
subjs = dataset.list_subjects() subjs = dataset.list_subjects()
``` ```
%% Cell type:code id:e4c15491-0fbe-4339-b11c-dd9305a3be9d tags: %% Cell type:code id:e4c15491-0fbe-4339-b11c-dd9305a3be9d tags:
``` python ``` python
len(set(subjs)), subjs[:10] len(set(subjs)), subjs[:10]
``` ```
%% Output %% Output
(1031, (1031,
['sub_00000', ['sub_00000',
'sub_00001', 'sub_00001',
'sub_00002', 'sub_00002',
'sub_00003', 'sub_00003',
'sub_00004', 'sub_00004',
'sub_00005', 'sub_00005',
'sub_00006', 'sub_00006',
'sub_00007', 'sub_00007',
'sub_00008', 'sub_00008',
'sub_00009']) 'sub_00009'])
%% Cell type:code id:c6c583f3-8efe-4758-9ebb-6e9d9681cbb1 tags: %% Cell type:code id:c6c583f3-8efe-4758-9ebb-6e9d9681cbb1 tags:
``` python ``` python
W = dataset.load_sc('sub_00008') W = dataset.load_sc('sub_00008')
``` ```
%% Cell type:code id:4709f50f-8284-4a41-9de7-c357a9514399 tags: %% Cell type:code id:4709f50f-8284-4a41-9de7-c357a9514399 tags:
``` python ``` python
W.shape W.shape
``` ```
%% Output %% Output
(100, 100) (100, 100)
%% Cell type:markdown id:d5996ac2-f8cd-49ac-91a6-cd8c0938e15d tags: %% Cell type:markdown id:d5996ac2-f8cd-49ac-91a6-cd8c0938e15d tags:
## Parcellation-based structural connectomes (HCP) ## Parcellation-based structural connectomes (HCP)
%% Cell type:code id:2e5431ed-cbfe-42bb-9357-b4f292eae0cf tags: %% Cell type:code id:2e5431ed-cbfe-42bb-9357-b4f292eae0cf tags:
``` python ``` python
from tvb_ebrains_data import HCPDataset from tvb_ebrains_data import HCPDataset
``` ```
%% Cell type:code id:8954ff48-9b28-4dd9-95f6-02de0924e817 tags: %% Cell type:code id:8954ff48-9b28-4dd9-95f6-02de0924e817 tags:
``` python ``` python
dataset = HCPDataset() dataset = HCPDataset()
``` ```
%% Cell type:code id:a9c1fd3c-fac1-4208-bc97-d18b375263d0 tags: %% Cell type:code id:a9c1fd3c-fac1-4208-bc97-d18b375263d0 tags:
``` python ``` python
print(dataset.__doc__) print(dataset.__doc__)
``` ```
%% Output %% Output
Domhof, J. W. M., Jung, K., Eickhoff, S. B., & Popovych, O. V. (2021). Domhof, J. W. M., Jung, K., Eickhoff, S. B., & Popovych, O. V. (2021).
Parcellation-based structural and resting-state functional brain Parcellation-based structural and resting-state functional brain
connectomes of a healthy cohort [Data set]. EBRAINS. connectomes of a healthy cohort [Data set]. EBRAINS.
https://doi.org/10.25493%2F81EV-ZVT https://doi.org/10.25493%2F81EV-ZVT
%% Cell type:code id:fc84c8f1-5dc9-47ed-8df2-f14a747fa709 tags: %% Cell type:code id:fc84c8f1-5dc9-47ed-8df2-f14a747fa709 tags:
``` python ``` python
dataset.list_parcellations() dataset.list_parcellations()
``` ```
%% Output %% Output
['031-MIST', ['031-MIST',
'038-CraddockSCorr2Level', '038-CraddockSCorr2Level',
'048-HarvardOxfordMaxProbThr0', '048-HarvardOxfordMaxProbThr0',
'056-CraddockSCorr2Level', '056-CraddockSCorr2Level',
'056-MIST', '056-MIST',
'070-DesikanKilliany', '070-DesikanKilliany',
'079-Shen2013', '079-Shen2013',
'086-EconomoKoskinas', '086-EconomoKoskinas',
'092-AALV2', '092-AALV2',
'096-HarvardOxfordMaxProbThr0', '096-HarvardOxfordMaxProbThr0',
'100-Schaefer17Networks', '100-Schaefer17Networks',
'103-MIST', '103-MIST',
'108-CraddockSCorr2Level', '108-CraddockSCorr2Level',
'150-Destrieux', '150-Destrieux',
'156-Shen2013', '156-Shen2013',
'160-CraddockSCorr2Level', '160-CraddockSCorr2Level',
'167-MIST', '167-MIST',
'200-Schaefer17Networks', '200-Schaefer17Networks',
'210-Brainnetome'] '210-Brainnetome']
%% Cell type:code id:286635b0-99e2-42c2-889a-dc1126752df7 tags: %% Cell type:code id:286635b0-99e2-42c2-889a-dc1126752df7 tags:
``` python ``` python
subjs = dataset.list_subjects(parcellation='200-Schaefer17Networks') subjs = dataset.list_subjects(parcellation='200-Schaefer17Networks')
len(subjs), subjs[:10] len(subjs), subjs[:10]
``` ```
%% Output %% Output
(200, ['000', '001', '002', '003', '004', '005', '006', '007', '008', '009']) (200, ['000', '001', '002', '003', '004', '005', '006', '007', '008', '009'])
%% Cell type:code id:00af414e-941a-408d-ae3a-0010f430e00a tags: %% Cell type:code id:00af414e-941a-408d-ae3a-0010f430e00a tags:
``` python ``` python
W, D = dataset.load_sc(subject='003', parcellation='200-Schaefer17Networks') W, D = dataset.load_sc(subject='003', parcellation='200-Schaefer17Networks')
``` ```
%% Cell type:code id:44bfe644-8822-4075-b828-844c92d8b507 tags: %% Cell type:code id:44bfe644-8822-4075-b828-844c92d8b507 tags:
``` python ``` python
W.shape, D.shape W.shape, D.shape
``` ```
%% Output %% Output
((200, 200), (200, 200)) ((200, 200), (200, 200))
......
...@@ -71,8 +71,28 @@ class DataProxyConnectivityDataset: ...@@ -71,8 +71,28 @@ class DataProxyConnectivityDataset:
def load_sc(self, subject): def load_sc(self, subject):
raise NotImplementedError() raise NotImplementedError()
def have_access(self):
response = requests.get(
url = f'{self.DATA_PROXY_ENDPOINT}/datasets/{self.BUCKET_NAME}/stats',
headers = self.AUTHORIZATION_HEADERS
)
if response.ok:
return True
elif response.status_code == 401:
return False
else:
raise Exception(f'Failed request: {response.reason}')
def request_access(self):
response = requests.post(
url = f'{self.DATA_PROXY_ENDPOINT}/datasets/{self.BUCKET_NAME}',
headers = self.AUTHORIZATION_HEADERS
)
if not response.ok:
raise Exception(f'Failed request: {response.reason}')
else:
print('Request for access submitted, check mail.')
class HCPDataset(DataProxyConnectivityDataset): class HCPDataset(DataProxyConnectivityDataset):
...@@ -114,11 +134,15 @@ class Brains1000Dataset(DataProxyConnectivityDataset): ...@@ -114,11 +134,15 @@ class Brains1000Dataset(DataProxyConnectivityDataset):
Caspers, S. et al (2021). Caspers, S. et al (2021).
1000BRAINS study, connectivity data. 1000BRAINS study, connectivity data.
https://doi.org/10.25493/6640-3XH v1.0: https://doi.org/10.25493/61QA-KP8
v1.1: https://doi.org/10.25493/6640-3XH
""" """
def __init__(self, version='v1.1', token=None): def __init__(self, version='v1.1', token=None):
self.version = version self.version = version
super().__init__(bucket_name="83407c06-b494-4307-861e-d06a5aecdf8a", token=token) if version=='v1.1':
super().__init__(bucket_name="83407c06-b494-4307-861e-d06a5aecdf8a", token=token)
elif version=='v1.0':
super().__init__(bucket_name="e428cb6b-0110-4205-94ac-533ca5de6bb5", token=token)
def list_subjects(self): # TODO cache this ? def list_subjects(self): # TODO cache this ?
prefix = f'{self.version}/Julich-Brain/Streamlines' prefix = f'{self.version}/Julich-Brain/Streamlines'
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment