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

bug fixes - fixed split function txt file writer: added string format

parent 99df6b78
......@@ -19,7 +19,6 @@ import numpy as np
import nibabel as nib
import torch
import torch.utils.data as data
import nibabel as nb
import random
import configparser
......@@ -71,9 +70,9 @@ def data_test_train_validation_split(folder_location, train_percentage, validati
train, validation, test = np.split(subDirectoryList, [int(train_percentage/100 * len(subDirectoryList)), int((train_percentage+validation_percentage)/100 * len(subDirectoryList))])
np.savetxt('train.txt', train)
np.savetxt('test.txt', test)
np.savetxt('validation.txt', validation)
np.savetxt('train.txt', train, fmt='%s')
np.savetxt('test.txt', test, fmt='%s')
np.savetxt('validation.txt', validation, fmt='%s')
def update_shuffling_flag(file_name):
""" Update shuffling flag
......@@ -298,7 +297,7 @@ def load(file_path, orientation):
header (class): 'nibabel.nifti1.Nifti1Header' class object, containing image metadata
"""
nifty_volume, label_map = nb.load(file_path[0]), nb.load(file_path[1])
nifty_volume, label_map = nib.load(file_path[0]), nib.load(file_path[1])
volume, label_map = nifty_volume.get_fdata(), label_map.ged_fdata()
# Do we need min-max normalization here? Will need to check when debuggint and testing
......@@ -372,7 +371,7 @@ def load_and_preprocess_evaluation(file_path, orientation, min_max=True):
ValueError: "Orientation value is invalid. It must be either >>coronal<<, >>axial<< or >>sagital<< "
"""
nifty_volume = nb.load(file_path[0])
nifty_volume = nib.load(file_path[0])
volume = nifty_volume.get_fdata()
header = nifty_volume.header
......@@ -397,5 +396,5 @@ def load_and_preprocess_evaluation(file_path, orientation, min_max=True):
if __name__ == "__main__":
folder_location = '/well/win-biobank/projects/imaging/data/data3/subjectsAll/'
tract_sum_generator(folder_location)
folder_location = "../well/win-biobank/projects/imaging/data/data3/subjectsAll/"
data_test_train_validation_split(folder_location, 90, 5)
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