Skip to content

Commit 12c8924

Browse files
author
Stepp Willi Leopold
committed
Added changes and files from lebpc34
1 parent fc719e2 commit 12c8924

4 files changed

+9153
-5
lines changed

20201014_Mito2Drp1.ipynb

+9,033
Large diffs are not rendered by default.

binOutput.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,11 @@
1313
from datetime import datetime
1414

1515

16-
17-
18-
19-
2016
if __name__ == "__main__":
2117
path = "//lebnas1.epfl.ch/microsc125/Watchdog/"
2218
filename = 'binary_output.dat'
2319
fullFileDir = path + filename
24-
20+
2521
x = False
2622
x = bool(x)
2723
i = 0

readBinNetwork.m

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
%% Matlab script to try reading in a binary file that was output from the
2+
% python program that will be used to run the neural network
3+
function start_monitoring_NAS()
4+
%% Small GUI
5+
DlgH = figure('Position',[500 500 250 100],'Name','Matlab',...
6+
'NumberTitle','off');
7+
H = uicontrol('Style', 'PushButton', 'String', 'Break',...
8+
'Callback', 'delete(gcf)');
9+
Text = uicontrol('Style','text','Position',[100 0 200 100],...
10+
'Background',[0.9 0.9 0.9],'FontSize',25);
11+
drawnow
12+
13+
%% While loop pulling the data from the network location
14+
x_old = 0;
15+
while (ishandle(H))
16+
fileID = fopen('//lebnas1.epfl.ch/microsc125/Watchdog/binary_output.dat','r');
17+
x = fread(fileID);
18+
fclose(fileID);
19+
x = size(x,1);
20+
Text.String = num2str(x);
21+
set(Text,'Background', [0.5 0.5 0.5] + (x/512));
22+
if x ~= x_old
23+
disp(x)
24+
disp(datetime('now','TimeZone','local','Format','HH:mm:ss.SSS'))
25+
end
26+
x_old = x;
27+
pause(0.01)
28+
end
29+
30+
end
31+
32+

test_tif_saver.py

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Created on 201102
4+
5+
@author: stepp
6+
7+
Application to read a h5 file and save a tif from it at 2Hz to test the
8+
watchdog on lebpc20
9+
"""
10+
11+
import time
12+
import numpy as np
13+
import matplotlib.pyplot as plt
14+
import h5py
15+
from skimage import io
16+
import os
17+
18+
data_path = 'C:/Users/stepp/Documents/data_raw/SmartMito/' # nb: begin with /
19+
print('data_path : ', data_path)
20+
print()
21+
input_data_filename1 = data_path + 'Mito.h5' # Mito
22+
input_data_filename2 = data_path + 'Drp1.h5' # Drp1
23+
24+
input_data_filename1 = data_path + 'cell_8_Pos1_mito_741.tif' # Mito
25+
input_data_filename2 = data_path + 'cell_8_Pos1_drp1_741.tif' # Drp1
26+
27+
# input_data_filename1 = data_path + 'cell_8_mito_1024.tif' # Mito
28+
# input_data_filename2 = data_path + 'cell_8_drp1_1024.tif' # Drp1
29+
30+
# input_data_filename1 = data_path + 'cell_8_mito.tif' # Mito
31+
# input_data_filename2 = data_path + 'cell_8_drp1.tif' # Drp1
32+
33+
# input_data_filename1 = data_path + 's3_c6_mito.tif' # Mito
34+
# input_data_filename2 = data_path + 's3_c6_drp1.tif' # Drp1
35+
36+
mito = []
37+
drp = []
38+
39+
if input_data_filename1[-3:] == '.h5':
40+
hf = h5py.File(input_data_filename1, 'r')
41+
mito = hf.get('Mito') # Mito
42+
else:
43+
mito = io.imread(input_data_filename1)
44+
45+
print(mito.dtype)
46+
print('Input : ', mito.shape)
47+
print('Input : ', np.shape(mito)[0])
48+
49+
if input_data_filename2[-3:] == '.h5':
50+
hf = h5py.File(input_data_filename2, 'r')
51+
drp = hf.get('Drp1')
52+
else:
53+
drp = io.imread(input_data_filename2)
54+
55+
print(drp.dtype)
56+
print('Input : ', drp.shape)
57+
print('Input : ', np.shape(drp)[0])
58+
59+
nas_path = '//lebnas1.epfl.ch/microsc125/Watchdog/python_saver/'
60+
61+
i = 0
62+
for item in range(200, 213):
63+
# for item in range(1, 2002, 1000): # [1, 208]: # range(150, 210):
64+
t1 = time.perf_counter()
65+
print(item)
66+
mito_path = nas_path + 'img_channel000_position000_time' + \
67+
str((i*2)).zfill(9) + '_z000.tiff'
68+
drp_path = nas_path + 'img_channel000_position000_time' + \
69+
str((i*2 + 1)).zfill(9) + '_z000.tiff'
70+
71+
# First write mito then drp as watchdog waits for drp image
72+
io.imsave(mito_path, mito[item, :, :].astype(np.uint16),
73+
check_contrast=False)
74+
time.sleep(0.05)
75+
io.imsave(drp_path, drp[item, :, :].astype(np.uint16),
76+
check_contrast=False)
77+
t2 = time.perf_counter()
78+
time.sleep(np.max([0, .45 - (t2 - t1)]))
79+
i = i + 1
80+
81+
time.sleep(3)
82+
83+
# Clear the folder completely to have the same situation always
84+
for f in os.listdir(nas_path):
85+
if not f.endswith(".tiff"):
86+
continue
87+
os.remove(os.path.join(nas_path, f))

0 commit comments

Comments
 (0)