Skip to content

Commit

Permalink
updated doc aws downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
rutgerfick committed Jan 31, 2018
1 parent edbadc8 commit 9816b87
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions dmipy/hcp_interface/downloader_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class HCPInterface:
Parameters
----------
aws_key : string
your_aws_public_key : string
user aws public key
aws_secret : string
your_aws_secret_key : string
user aws secret key
"""

Expand All @@ -46,13 +46,27 @@ def __init__(self, your_aws_public_key, your_aws_secret_key):
if not os.path.exists(self.hcp_directory):
os.makedirs(self.hcp_directory)

def download_and_prepare_dmipy_example_dataset(self, subject=100307):
self.download_subject(subject)
self.prepare_example_slice(subject)

def download_subject(self, subject):

hcp_data_path = os.path.join(self.hcp_directory, str(subject))
def download_and_prepare_dmipy_example_dataset(self):
"""
Downloads subect 100307 of the Wu-Minn HCP data and prepares it to be
used for the dmipy example notebooks.
"""
subject_ID = 100307
self.download_subject(subject_ID)
self.prepare_example_slice(subject_ID)

def download_subject(self, subject_ID):
"""
Downloads Wu-Minn HCP subject data to the dmipy data folder.
The downloaded data includes the b-values, gradient orientations,
diffusion-weighted images and the binary brain mask.
Parameters
----------
subject_ID: integer
the identification number of the Wu-Minn HCP subject
"""
hcp_data_path = os.path.join(self.hcp_directory, str(subject_ID))

if not os.path.exists(hcp_data_path):
os.makedirs(hcp_data_path)
Expand All @@ -64,7 +78,7 @@ def download_subject(self, subject):
path = pathlib.Path(key.name)
if (
len(path.parts) == 5 and
subject == int(path.parts[1]) and
subject_ID == int(path.parts[1]) and
path.parts[-2] == "Diffusion"
):
if (
Expand All @@ -81,7 +95,8 @@ def download_subject(self, subject):
if counter == 4:
break

def prepare_example_slice(self, subject):
def prepare_example_slice(self, subject_ID):
"Prepares a coronal slice for the dmipy example notebooks."
msg = "Preparing coronal slice for dmipy examples"
print (msg)

Expand All @@ -90,7 +105,7 @@ def prepare_example_slice(self, subject):
if not os.path.exists(example_directory):
os.makedirs(example_directory)

subject_data_path = os.path.join(self.hcp_directory, str(subject))
subject_data_path = os.path.join(self.hcp_directory, str(subject_ID))

data = nib.load(os.path.join(
subject_data_path, 'data.nii.gz')).get_data()
Expand Down

0 comments on commit 9816b87

Please sign in to comment.