initial commit

This commit is contained in:
2024-10-25 11:12:10 +02:00
commit 12f926de28
2 changed files with 110 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
import numpy as np
def load_nanotom(path, pcrSizeX = 0, pcrSizeY = 0, pcrSizeZ = 0):
if pcrSizeX == 0 or pcrSizeY == 0 or pcrSizeZ == 0:
print('searching pcr file for image dimensions')
pcrpath = path.split('.')[0]+'.pcr'
if not os.path.exists(pcrpath):
print('pcr-file not found, please provide image dimensions manually')
else:
with open(pcrpath) as file:
lines = file.readlines()
for line in lines:
splitline = line.split('=')
if splitline[0] == 'Volume_SizeX':
pcrSizeX = int(splitline[1])
if splitline[0] == 'Volume_SizeY':
pcrSizeY = int(splitline[1])
if splitline[0] == 'Volume_SizeZ':
pcrSizeZ = int(splitline[1])
else:
print('dimension manually provided as '+str(pcrSizeX)+'x'+str(pcrSizeY)+'x'+str(pcrSizeY))
print('dimensions considered as '+str(pcrSizeX)+'x'+str(pcrSizeY)+'x'+str(pcrSizeY))
print('load the file')
with open(path,'r') as file:
file.seek(0)
im = np.fromfile(file, dtype='<f4').reshape(pcrSizeX,pcrSizeY,pcrSizeZ, order ='F')
return im