-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoadLsm5D.py
60 lines (42 loc) · 1.81 KB
/
LoadLsm5D.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
58
59
60
"""This function loads .lsm files.
Given the filename of a .lsm files, this function gives as output the matrices
of the red and green channels maximum intensity projected plus the green channel
as it is. Inputs are the file-name and the channel number for nuclei and spots.
"""
import numpy as np
import tifffile
from PyQt5 import QtWidgets
class LoadLsm5D:
def __init__(self, fname, nucs_spts_ch):
file_array = tifffile.imread(fname)
steps, z, c, x_len, y_len = file_array.shape
pbar = ProgressBar(total1=steps)
pbar.show()
red_mtx = np.zeros((steps, x_len, y_len))
green_mtx = np.zeros((steps, x_len, y_len))
for t in range(steps):
pbar.update_progressbar(t)
for x in range(x_len):
red_mtx[t, x, :] = file_array[t, :, nucs_spts_ch[0], x, :].max(0)
green_mtx[t, x, :] = file_array[t, :, nucs_spts_ch[1], x, :].max(0)
pbar.close()
self.red_mtx = red_mtx
self.green_mtx = green_mtx
self.green4D = file_array[:, :, 0, :, :]
class ProgressBar(QtWidgets.QWidget):
"""Simple progressbar widget"""
def __init__(self, parent=None, total1=20):
super().__init__(parent)
self.name_line1 = QtWidgets.QLineEdit()
self.progressbar1 = QtWidgets.QProgressBar()
self.progressbar1.setMinimum(1)
self.progressbar1.setMaximum(total1)
main_layout = QtWidgets.QGridLayout()
main_layout.addWidget(self.progressbar1, 0, 0)
self.setLayout(main_layout)
self.setWindowTitle("Progress")
self.setGeometry(500, 300, 300, 50)
def update_progressbar(self, val1):
"""progress bar updater"""
self.progressbar1.setValue(val1)
QtWidgets.qApp.processEvents()