Commit b67d7a88 authored by Andrei-Claudiu Roibu's avatar Andrei-Claudiu Roibu 🖥
Browse files

created data_utils - a script with data processing

parent 5ee34134
import os
from glob import glob
import numpy as np
import nibabel
def dirReader(folder_location):
"""Produces a list of of data-tags which are accessible
This function looks in a large data directory, and returns a list of sub-directories which are accessible.
This is done as currently, not all UK Biobank Data is accessible due to privacy issues.
Args:
folder_location (str): A string containing the address of the required directory.
Returns:
A list of strings containing the available sub-directories. This is also printed out as a .txt file
Raises:
None
"""
out_file = open("files.txt", 'w')
subDirectoryList = []
for directory in os.listdir(folder_location):
filename = folder_location+directory
if os.access(filename, os.R_OK):
string = directory+'\n'
out_file.write(string)
subDirectoryList.append(directory)
return subDirectoryList
def tractSum():
"""Sums the tracts of different dMRI files
When performing subject-specific probabilistic diffusion tractography using standard-space protocols, 27 tracts are created.
This function loops through all the tracts, sums them and returns the summed tract map.
This function also outputs the summed tract map as a Nifti (.nii.gz) file.
Args:
None
Returns:
None
Raises:
None
"""
folder_location = '/home/andrei/functionmapper/datasets/dMRI/23425368'
if __name__ == "__main__":
# folder_location = '/well/win-biobank/projects/imaging/data/data3/subjectsAll/'
# folder_location = '/home/andrei/directory_readear/'
folder_location = '/home/andrei/functionmapper/datasets/dMRI/23425368'
subDirList = dirReader(folder_location)
print(subDirList)
\ No newline at end of file
Supports Markdown
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