-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_intensity_shape.py
More file actions
76 lines (58 loc) · 2.46 KB
/
test_intensity_shape.py
File metadata and controls
76 lines (58 loc) · 2.46 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""
Test script to verify CLSMImage intensity shape behavior.
This script demonstrates that:
1. When split_by_channel=False or n_channels==1: intensity.shape = (n_frames, n_lines, n_pixel)
2. When split_by_channel=True and n_channels>1: intensity.shape = (n_channels, frames_per_channel, n_lines, n_pixel)
"""
def test_intensity_shape():
"""
Test the intensity property shape for different channel configurations.
Note: This is a demonstration of the expected behavior.
Actual testing requires real TTTR data with multi-channel information.
"""
print("=" * 80)
print("CLSMImage Intensity Shape Test")
print("=" * 80)
print("\nExpected behavior:")
print("-" * 80)
print("\n1. Single channel or split_by_channel=False:")
print(" intensity.shape = (n_frames, n_lines, n_pixel)")
print(" Example: (100, 256, 256) for 100 frames of 256x256 pixels")
print("\n2. Multi-channel with split_by_channel=True:")
print(" intensity.shape = (n_channels, frames_per_channel, n_lines, n_pixel)")
print(" Example: (2, 50, 256, 256) for 2 channels, 50 frames each, 256x256 pixels")
print("\n" + "=" * 80)
print("Implementation Details:")
print("=" * 80)
print("\nThe intensity property in CLSMImage.py now:")
print("1. Calls get_intensity() to get raw data from C++")
print("2. Checks n_channels:")
print(" - If n_channels == 1: returns raw data as-is")
print(" - If n_channels > 1: reshapes by extracting each channel's frames")
print("3. Returns numpy array with appropriate shape")
print("\n" + "=" * 80)
print("Usage Example:")
print("=" * 80)
example_code = """
import tttrlib
# Load TTTR data
data = tttrlib.TTTR('path/to/file.ptu')
# Create CLSMImage with split_by_channel=True
img = tttrlib.CLSMImage(data, split_by_channel=True)
# Access intensity
intensity = img.intensity
print(f"Intensity shape: {intensity.shape}")
# If multi-channel:
if img.n_channels > 1:
# Access specific channel
ch0_intensity = img[0].intensity # Channel 0
ch1_intensity = img[1].intensity # Channel 1
print(f"Channel 0 shape: {ch0_intensity.shape}")
print(f"Channel 1 shape: {ch1_intensity.shape}")
"""
print(example_code)
print("\n" + "=" * 80)
print("Test Complete")
print("=" * 80)
if __name__ == "__main__":
test_intensity_shape()