-
Notifications
You must be signed in to change notification settings - Fork 0
/
correct_z.py
57 lines (45 loc) · 1.49 KB
/
correct_z.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 4 12:35:20 2018
@author: MPawlowska
"""
import os
import readMetadata, listaPozycji, prepFunctions
###### KONFIGURACJA #########
zStepOld=10
zStepNew=10
nazwa_series='imageSeries_corBasic'
z0Old=0
z0New=90
#############################
rawDataDir = prepFunctions.wybierzKatalog()
#read information from metadata file into dic and create lists
dic=readMetadata.makeDic(rawDataDir)
lXY = dic['listaStringow']
#choosing unique values from the list of all X positions
used=[]
lX = [x for x in dic['listaXow'] if x not in used and (used.append(x) or True)]
lX=lX[1:]
lXY=lXY[4:]
#policz Z slices
dataDir=os.path.abspath(os.path.join(rawDataDir,nazwa_series))
dirX0=os.path.abspath(os.path.join(dataDir,lX[0]))
slices=len(os.listdir(os.path.abspath(os.path.join(dirX0,lXY[0]))))
#create Z list
lZOld = listaPozycji.listaPozycji1dim(z0Old, zStepOld, slices)
lZNew = listaPozycji.listaPozycji1dim(z0New, zStepNew, slices)
if(zStepOld>zStepNew):
r=range(0,len(lZOld)-1)
else:
r=range(len(lZOld)-1,-1,-1)
for subdirX in lX:
dirX=os.path.abspath(os.path.join(dataDir,subdirX))
for subdirXY in lXY:
if(subdirXY.startswith(subdirX)):
dirXY=os.path.abspath(os.path.join(dirX, subdirXY))
print(dirXY)
os.chdir(dirXY)
for i in r:
nameOld=subdirXY+'_'+lZOld[i]+'.tif'
nameNew=subdirXY+'_'+lZNew[i]+'.tif'
os.rename(nameOld, nameNew)