108 lines
3.5 KiB
Python
Executable File
108 lines
3.5 KiB
Python
Executable File
#X:\datasets\radboud_lesions_2022
|
|
#/data/pca-rad/experiments/fix-radboud-data/export/pat0777-2016.nii.gz
|
|
|
|
#'experiments/fix-radboud-data/export'
|
|
#'datasets/radboud_lesions_2022'
|
|
|
|
########### Read in the file ##############
|
|
# with open('./../data/Nijmegen paths/t2.txt', 'r') as file :
|
|
# filedata = file.read()
|
|
|
|
# filedata = filedata.replace('/diffusie_cro/b-1400','/t2_tse_tra')
|
|
# import numpy as np
|
|
# print(np.shape(filedata))
|
|
|
|
############# check for missing files ############
|
|
import numpy as np
|
|
import os
|
|
|
|
serie = 'b2000'
|
|
file1 = f'./../data/Nijmegen paths/{serie}.txt'
|
|
file2 = f'./../data/Test paths/{serie}.txt'
|
|
file3 = './../../qvlohuizen/fastMRI_PCa/data/path_lists/pirads_4plus/current_dwi.txt'
|
|
# X:\qvlohuizen\fastMRI_PCa\data\path_lists\pirads_4plus
|
|
with open(file3) as fp:
|
|
data = fp.readlines()
|
|
|
|
UMCG = [i for i, s in enumerate(data) if '-U-' in s]
|
|
Martini = [i for i, s in enumerate(data) if '-M-' in s]
|
|
patient_id = [os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(data[index]))))[-9:-6] for index in Martini]
|
|
patient_id = [item.replace("/", "") for item in patient_id]
|
|
patient_id = [item.replace("y", "") for item in patient_id]
|
|
patient_id.sort()
|
|
Martini_data = [data[index] for index in Martini]
|
|
|
|
Martini_Diffusie = [i for i, s in enumerate(Martini_data) if not 'Diffusie' in s]
|
|
|
|
print(patient_id)
|
|
print(np.shape(Martini_data))
|
|
print(len(Martini_Diffusie))
|
|
print([Martini_data[index] for index in Martini_Diffusie])
|
|
quit()
|
|
############# merge radboud and umcg files ############
|
|
import numpy as np
|
|
import os
|
|
|
|
serie = 'b2000'
|
|
file1 = './../../qvlohuizen/fastMRI_PCa/data/path_lists/pirads_4plus/current_dwi.txt'
|
|
# X:\qvlohuizen\fastMRI_PCa\data\path_lists\pirads_4plus
|
|
with open(file1) as fp:
|
|
data = fp.readlines()
|
|
# Reading data from file2
|
|
with open(file2) as fp:
|
|
data2 = fp.read()
|
|
|
|
# Merging 2 files
|
|
# To add the data of file2
|
|
# from next line
|
|
data += "\n"
|
|
data += data2
|
|
|
|
with open (f'{serie}.txt', 'w') as fp:
|
|
fp.write(data)
|
|
|
|
quit()
|
|
############ find more martini data ##############
|
|
import numpy as np
|
|
|
|
high_b_data = './../../qvlohuizen/fastMRI_PCa/data/path_lists/pirads_4plus/current_dwi.txt'
|
|
adc_data = './../../qvlohuizen/fastMRI_PCa/data/path_lists/pirads_4plus/current_adc.txt'
|
|
t2_data = './../../qvlohuizen/fastMRI_PCa/data/path_lists/pirads_4plus/current_t2w.txt'
|
|
seg_data = './../../qvlohuizen/fastMRI_PCa/data/path_lists/pirads_4plus/seg_new.txt'
|
|
|
|
with open(high_b_data, 'r') as file :
|
|
high_b_data = file.readlines()
|
|
with open(adc_data, 'r') as file :
|
|
adc_data = file.readlines()
|
|
with open(t2_data, 'r') as file :
|
|
t2_data = file.readlines()
|
|
with open(seg_data, 'r') as file :
|
|
seg_data = file.readlines()
|
|
|
|
|
|
indices = [i for i, s in enumerate(high_b_data) if 'Diffusie_b0-50-400-800-2000' in s]
|
|
|
|
b_2000 = [high_b_data[index] for index in indices]
|
|
b_50 = [item.replace("b-2000", "b-50") for item in b_2000]
|
|
b_400 = [item.replace("b-2000", "b-400") for item in b_2000]
|
|
b_800 = [item.replace("b-2000", "b-800") for item in b_2000]
|
|
adc = [adc_data[index] for index in indices]
|
|
t2 = [t2_data[index] for index in indices]
|
|
seg = [seg_data[index] for index in indices]
|
|
|
|
with open('b50.txt', 'w') as f:
|
|
f.writelines(b_50)
|
|
with open('b400.txt', 'w') as f:
|
|
f.writelines(b_400)
|
|
with open('b800.txt', 'w') as f:
|
|
f.writelines(b_800)
|
|
with open('b2000.txt', 'w') as f:
|
|
f.writelines(b_2000)
|
|
with open('adc.txt', 'w') as f:
|
|
f.writelines(adc)
|
|
with open('t2.txt', 'w') as f:
|
|
f.writelines(t2)
|
|
with open('seg.txt', 'w') as f:
|
|
f.writelines(seg)
|
|
|