Skip to content

Commit 1bfd88b

Browse files
committed
snAPI v 1.1.2.1
- add custom tags (in snAPI) - fix Unfold in UniHarp for less counts - add Demo_Imaging_PTU.py
1 parent eadcefc commit 1bfd88b

File tree

72 files changed

+11398
-138
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+11398
-138
lines changed

demos/Demo_Imaging_PTU.py

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
from snAPI.Main import *
2+
import matplotlib
3+
4+
matplotlib.use("TkAgg", force=True)
5+
from matplotlib import pyplot as plt
6+
7+
if __name__ == "__main__":
8+
9+
sn = snAPI()
10+
sn.getDevice("1000509")
11+
sn.initDevice(MeasMode.T2)
12+
13+
sn.loadIniConfig(r"config\HH500.ini")
14+
15+
history_size = 1
16+
sn.setLogLevel(LogLevel.DataFile, True)
17+
sn.timeTrace.setNumBins(10000)
18+
sn.timeTrace.setHistorySize(history_size)
19+
20+
21+
# set Marker (1..4)
22+
sn.device.setMarkerEdges(1, 0, 0, 0)
23+
sn.device.setMarkerEnable(1, 1, 1, 0)
24+
25+
# set Image Tag
26+
sn.setMeasurementSubMode(subMode=MeasSubMode.Image)
27+
# Marker (1) in TTTR stream defining a line start
28+
sn.addIntTag("ImgHdr_LineStart", 1)
29+
# Marker (2) in TTTR stream defining a line start
30+
sn.addIntTag("ImgHdr_LineStop", 2)
31+
# Marker (3) in TTTR stream defining a frame change
32+
sn.addIntTag("ImgHdr_Frame", 3)
33+
34+
# Dimension of the measurement: 1 = Point; 2 = Line; 3 = Image; 4 = Stack
35+
sn.addIntTag("ImgHdr_Dimensions", 3)
36+
37+
# Identifies the scanner hardware:
38+
# (1 = PI E-710; 3 = LSM; 5 = PI Line WBS; 6 = PI E-725; 7 = PI E-727; 8 = MCL; 9 = FLIMBee; 10 = ScanBox)
39+
#sn.addIntTag("ImgHdr_Ident", 3)
40+
41+
# Scan direction, defining the configuration of fast and slowscan axis
42+
# First Axis = Fast Scan axis, Second Axis = SlowAxis
43+
# PI_SCANMODE_XY(0) = X-Y Scan (default)
44+
# PI_SCANMODE_XZ(1) = X-Z Scan
45+
# PI_SCANMODE_YZ(2) = Y-Z Scan
46+
#sn.addIntTag("ImgHdr_ScanDirection", 0)
47+
48+
# Scan pattern:
49+
# TRUE identifies bidirectional scanning
50+
# 1st line forward scan
51+
# 2nd line backward scan
52+
# 3rd line forward
53+
# 4th line backward; ...)
54+
# FALSE identifies monodirectional scanning (all lines forward - default)
55+
#sn.addBoolTag("ImgHdr_BiDirect", False)
56+
57+
# If > 0, the image was recorded using a sinuidal instead of a linear movement
58+
# Value represents percentage of the sinus wave used for the measurement (0-100%)
59+
# (default: 0)
60+
#sn.addIntTag("ImgHdr_SinCorrection", 0)
61+
62+
# [ms]
63+
# Integration time per pixel for image measurements
64+
sn.addIntTag("ImgHdr_TimePerPixel", 20)
65+
66+
# [µm]
67+
# X, Y, Z Position of measurement (interpretation depends on ImgHdr_Dimensions
68+
# for point measurements: the coordinate of measurement
69+
# for line: the start point
70+
# for images: the offset of the upper left edge of the image)
71+
sn.addFloatTag("ImgHdr_X0", 0.0)
72+
sn.addFloatTag("ImgHdr_Y0", 0.0)
73+
sn.addFloatTag("ImgHdr_Z0", 0.0)
74+
75+
# Number of pixels in the fast scan direction (for image measurements)
76+
sn.addIntTag("ImgHdr_PixX", 256)
77+
# Number of pixels in the slow scan direction (for image measurements)
78+
sn.addIntTag("ImgHdr_PixY", 256)
79+
# [µm]; Resolution of a single pixel (line and image measurements)
80+
sn.addFloatTag("ImgHdr_PixResol", 1.0)
81+
82+
#sn.addIntTag("TestInt", 9223372036854775807, 123)
83+
#sn.addFloatArrayTag("TestFloatArray", [1.1, 2.3, 3.3, 4.4])
84+
#sn.addByteArrayTag("TestIntArray", [0,1,2,3,4,0,0,0])
85+
86+
# set the file name
87+
sn.setPTUFilePath("out.ptu")
88+
89+
sn.timeTrace.measure(int(history_size * 1e3), waitFinished=False, savePTU=True)
90+
ft = 0
91+
while True:
92+
finished = sn.timeTrace.isFinished()
93+
#if finished:
94+
# sn.timeTrace.t0.value = 0
95+
counts, times = sn.timeTrace.getData()
96+
plt.clf()
97+
98+
plt.plot(times, counts[0], linewidth=2.0, label="sync")
99+
for c in range(1, 1 + sn.deviceConfig["NumChans"]):
100+
plt.plot(times, counts[c], linewidth=2.0, label=f"chan{c}")
101+
plt.grid()
102+
plt.xlabel("Time [s]")
103+
plt.ylabel("Counts[Cts/s]")
104+
plt.yscale('log', base=10, nonpositive='clip')
105+
plt.legend()
106+
plt.title("TimeTrace")
107+
plt.pause(0.1)
108+
109+
if finished:
110+
ft+=1
111+
if ft > 10:
112+
break
113+
114+
plt.show(block=True)
115+
plt.close()

demos/config/HH500.ini

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[Device]
2+
HystCode = 0
3+
SyncDiv = 1
4+
SyncEdgeTrig = -50,1
5+
SyncChannelOffset = 0
6+
SyncChannelEnable = 1
7+
SyncDeadTime = 0
8+
StopCount = 0
9+
Binning = 1
10+
Offset = 0
11+
TriggerOutput = 0
12+
13+
[All_Channels]
14+
EdgeTrig = -50,1
15+
ChanOffs = 0
16+
ChanEna = 1
17+
DeadTime = 0

dist/snapi-1.1.0.tar.gz

-2.72 MB
Binary file not shown.
5.04 MB
Binary file not shown.

dist/snapi-1.1.2.tar.gz

4.93 MB
Binary file not shown.

doc_source/PQTag_Dictionary.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
PQ Tag Dictionary
2+
-----------------
3+
4+
.. raw:: html
5+
:file: _static/tables/PQTagDictionary.html

doc_source/PQTag_Types.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
PQ Tag Types
2+
------------
3+
4+
.. note::
5+
6+
- Tag region of files have always lengths divisible by 8
7+
- In files, tags start always on positions divisible by 8.
8+
- Tag_Id is case sensitive.
9+
10+
File Magic
11+
""""""""""
12+
13+
The following table gives the file type identifying "magics" as to be found in preamble 1.
14+
This preamble is filled up to its full length of 8 with '\0'.
15+
16+
.. raw:: html
17+
:file: _static/tables/PQTagFileMagics.html
18+
19+
Tag Format Definition
20+
"""""""""""""""""""""
21+
22+
The following table illustrates the format of valid tags. It is described as a structure with named fields:
23+
24+
.. raw:: html
25+
:file: _static/tables/PQTagFormatDefinition.html
26+
27+
Tag Type Definition
28+
"""""""""""""""""""
29+
30+
The following table defines the types of valid tags with their domain and additional length if enhanced:
31+
32+
.. raw:: html
33+
:file: _static/tables/PQTagTypes.html

doc_source/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ Welcome to snAPI's documentation!
1515
install
1616
snAPI
1717
config
18-
tttr data format
1918
hardware
19+
tttr data format
20+
PQTag_Dictionary
21+
PQTag_Types
2022

2123
Indices and tables
2224
==================

doc_source/tttr data format.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
TTTR Record Format
22
==================
33

4+
This describes the structure of the PTU-Files with its header, tags and time tag data.
5+
6+
Important Documents
7+
-------------------
8+
9+
- `Tag Dictionary <PQTag_Dictionary.html#pq-tag-dictionary>`_
10+
- `Tag Types <PQTag_Types.html#tag-type-definition>`_
11+
- `Tag Format <PQTag_Types.html#tag-format-definition>`_
12+
- `File Magic <PQTag_Types.html#file-magic>`_
13+
414
Basic record format
5-
---------------------
15+
-------------------
616

717
This page describes the format of the TTTR data named as raw data in ptu files.
8-
918
Due to performance reasons the TTTR data are saved exactly as received from TCSPC device, hence the format of the TTTR records depends on the kind of TCSPC device and the type of measurement. The record format used in a particular file is denoted in the mandatory tag TTResultFormat_TTTRRecType.
10-
1119
Even though the record formats differ, the formal algorithms for the calculations on them don't: To get the global arrival time of a photon or a marker in seconds, count the overflows until the current position and multiply with the overflow period, then add the timetag (for T2) or nSync (for T3) and multiply with the MeasDesc_GlobalResolution.
12-
1320
The arrival time since the last sync event in T3 measurements is denoted in dTime. To get the time in seconds multiply dTime with MeasDesc_Resolution.
1421

1522
Images
@@ -121,4 +128,4 @@ The channel code 15 (0xF) marks a special record.
121128
Special records can be overflows or external markers. To differentiate this, dTime must be checked.
122129

123130
If it is zero, the record marks an overflow.
124-
If it is >=1 the individual bits are external markers.
131+
If it is >=1 the individual bits are external markers.

docs/.buildinfo.bak

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Sphinx build info version 1
2+
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
3+
config: f357dabe0031662a7e3ad0888c85f0a0
4+
tags: 645f666f9bcd5a90fca523b33c5a78b7

0 commit comments

Comments
 (0)