AMS-BP 0.0.25__py3-none-any.whl → 0.0.26__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- AMS_BP/__init__.py +1 -1
- AMS_BP/optics/lasers/laser_profiles.py +11 -176
- AMS_BP/optics/psf/psf_engine.py +7 -3
- AMS_BP/photophysics/photon_physics.py +4 -4
- {ams_bp-0.0.25.dist-info → ams_bp-0.0.26.dist-info}/METADATA +2 -2
- {ams_bp-0.0.25.dist-info → ams_bp-0.0.26.dist-info}/RECORD +9 -9
- {ams_bp-0.0.25.dist-info → ams_bp-0.0.26.dist-info}/WHEEL +0 -0
- {ams_bp-0.0.25.dist-info → ams_bp-0.0.26.dist-info}/entry_points.txt +0 -0
- {ams_bp-0.0.25.dist-info → ams_bp-0.0.26.dist-info}/licenses/LICENSE +0 -0
AMS_BP/__init__.py
CHANGED
@@ -371,15 +371,16 @@ class WidefieldBeam(LaserProfile):
|
|
371
371
|
Returns:
|
372
372
|
Intensity scaling factor between 0 and 1
|
373
373
|
"""
|
374
|
-
# Use error function for smooth transition at DoF boundaries
|
375
|
-
# Scale factor determines how sharp the transition is
|
376
|
-
scale_factor = 2.0 # Adjust this to change transition sharpness
|
377
|
-
|
378
|
-
# Normalize z by DoF and create smooth falloff
|
379
|
-
normalized_z = scale_factor * (np.abs(z)
|
380
|
-
|
381
|
-
# Use sigmoid function for smooth transition
|
382
|
-
return 1 / (1 + np.exp(normalized_z))
|
374
|
+
# # Use error function for smooth transition at DoF boundaries
|
375
|
+
# # Scale factor determines how sharp the transition is
|
376
|
+
# scale_factor = 2.0 # Adjust this to change transition sharpness
|
377
|
+
#
|
378
|
+
# # Normalize z by DoF and create smooth falloff
|
379
|
+
# normalized_z = scale_factor * (np.abs(z)) / self.dof
|
380
|
+
#
|
381
|
+
# # Use sigmoid function for smooth transition
|
382
|
+
# return 1 / (1 + np.exp(normalized_z))
|
383
|
+
return 1.0
|
383
384
|
|
384
385
|
def calculate_intensity(
|
385
386
|
self,
|
@@ -416,7 +417,7 @@ class WidefieldBeam(LaserProfile):
|
|
416
417
|
base_intensity = power / (np.pi * self.max_radius**2)
|
417
418
|
|
418
419
|
# Apply radial intensity profile with smooth falloff at edges
|
419
|
-
edge_width = self.max_radius * 0.
|
420
|
+
edge_width = self.max_radius * 0.00001
|
420
421
|
radial_profile = 0.5 * (1 - np.tanh((r - self.max_radius) / edge_width))
|
421
422
|
# Apply DoF-based axial intensity profile
|
422
423
|
axial_profile = self._calculate_dof_profile(z_shifted)
|
@@ -425,32 +426,6 @@ class WidefieldBeam(LaserProfile):
|
|
425
426
|
return base_intensity * radial_profile * axial_profile
|
426
427
|
|
427
428
|
|
428
|
-
# Example usage
|
429
|
-
if __name__ == "__main__":
|
430
|
-
# Create parameters for a typical microscope objective
|
431
|
-
params = LaserParameters(
|
432
|
-
wavelength=488, # 488 nm
|
433
|
-
power=0.001, # 1 mW
|
434
|
-
beam_width=0.25, # 250 nm
|
435
|
-
numerical_aperture=1.4,
|
436
|
-
refractive_index=1.518, # Oil immersion
|
437
|
-
)
|
438
|
-
|
439
|
-
# Create beam object
|
440
|
-
beam = GaussianBeam(params)
|
441
|
-
|
442
|
-
# Get intensity map
|
443
|
-
result = beam.get_intensity_map(
|
444
|
-
volume_size=(5, 5, 10), # 5x5x10 microns
|
445
|
-
voxel_size=0.1, # 100 nm voxels
|
446
|
-
t=0, # t=0 seconds
|
447
|
-
)
|
448
|
-
|
449
|
-
# print(f"Beam waist: {params.beam_width:.3f} µm")
|
450
|
-
# print(f"Rayleigh range: {params.rayleigh_range:.3f} µm")
|
451
|
-
# print(f"Diffraction limit: {params.diffraction_limited_width:.3f} µm")
|
452
|
-
|
453
|
-
|
454
429
|
class HiLoBeam(LaserProfile):
|
455
430
|
"""
|
456
431
|
Highly Inclined Laminated Optical (HiLo) illumination profile.
|
@@ -552,143 +527,3 @@ class HiLoBeam(LaserProfile):
|
|
552
527
|
lamination_factor = np.exp(-np.abs(z_shifted) / (2 * self.axial_resolution))
|
553
528
|
|
554
529
|
return intensity * lamination_factor
|
555
|
-
|
556
|
-
|
557
|
-
class ConfocalBeam(LaserProfile):
|
558
|
-
"""
|
559
|
-
Confocal microscopy beam profile with point scanning and pinhole characteristics.
|
560
|
-
|
561
|
-
Implements key optical principles of confocal microscopy:
|
562
|
-
- Point scanning illumination
|
563
|
-
- Pinhole-based rejection of out-of-focus light
|
564
|
-
- Depth-resolved imaging capabilities
|
565
|
-
"""
|
566
|
-
|
567
|
-
def __init__(
|
568
|
-
self,
|
569
|
-
params: LaserParameters,
|
570
|
-
pinhole_diameter: float, # Pinhole diameter in microns
|
571
|
-
scanning_mode: str = "point", # 'point' or 'line'
|
572
|
-
line_orientation: str = "horizontal", # 'horizontal' or 'vertical'
|
573
|
-
):
|
574
|
-
"""
|
575
|
-
Initialize Confocal beam profile.
|
576
|
-
|
577
|
-
Args:
|
578
|
-
params: LaserParameters for the beam
|
579
|
-
pinhole_diameter: Diameter of the detection pinhole in microns
|
580
|
-
scanning_mode: Scanning method ('point' or 'line')
|
581
|
-
line_orientation: Orientation for line scanning
|
582
|
-
"""
|
583
|
-
super().__init__(params)
|
584
|
-
|
585
|
-
# Validate numerical aperture
|
586
|
-
if params.numerical_aperture is None:
|
587
|
-
raise ValueError(
|
588
|
-
"Numerical aperture must be specified for confocal microscopy"
|
589
|
-
)
|
590
|
-
|
591
|
-
# Pinhole and optical characteristics
|
592
|
-
self.pinhole_diameter = pinhole_diameter
|
593
|
-
self.scanning_mode = scanning_mode
|
594
|
-
self.line_orientation = line_orientation
|
595
|
-
|
596
|
-
# Calculate optical parameters
|
597
|
-
wavelength_microns = params.wavelength / 1000.0
|
598
|
-
na = params.numerical_aperture
|
599
|
-
|
600
|
-
# Theoretical resolution calculations
|
601
|
-
self.lateral_resolution = 0.61 * wavelength_microns / na
|
602
|
-
self.axial_resolution = 0.5 * wavelength_microns / (na**2)
|
603
|
-
|
604
|
-
# Pinhole transmission calculation
|
605
|
-
# Airy disk radius calculation
|
606
|
-
self.airy_radius = 1.22 * wavelength_microns / (2 * na)
|
607
|
-
|
608
|
-
# Transmission through pinhole
|
609
|
-
def pinhole_transmission(z):
|
610
|
-
"""
|
611
|
-
Calculate pinhole transmission as a function of z-position.
|
612
|
-
Uses an error function to model smooth transition.
|
613
|
-
"""
|
614
|
-
# Normalized z-position relative to focal plane
|
615
|
-
z_norm = z / self.axial_resolution
|
616
|
-
|
617
|
-
# Smooth transition function
|
618
|
-
return 0.5 * (1 + np.tanh(-z_norm))
|
619
|
-
|
620
|
-
self.pinhole_transmission = pinhole_transmission
|
621
|
-
|
622
|
-
# print("Confocal Microscopy Configuration:")
|
623
|
-
# print(f" Scanning Mode: {scanning_mode}")
|
624
|
-
# print(f" Pinhole Diameter: {pinhole_diameter:.2f} µm")
|
625
|
-
# print(f" Lateral Resolution: {self.lateral_resolution:.3f} µm")
|
626
|
-
# print(f" Axial Resolution: {self.axial_resolution:.3f} µm")
|
627
|
-
# print(f" Airy Disk Radius: {self.airy_radius:.3f} µm")
|
628
|
-
|
629
|
-
def calculate_intensity(
|
630
|
-
self,
|
631
|
-
x: np.ndarray | float,
|
632
|
-
y: np.ndarray | float,
|
633
|
-
z: np.ndarray | float,
|
634
|
-
t: float,
|
635
|
-
) -> np.ndarray:
|
636
|
-
"""
|
637
|
-
Calculate the confocal illumination intensity distribution.
|
638
|
-
|
639
|
-
Args:
|
640
|
-
x: X coordinates in microns (3D array)
|
641
|
-
y: Y coordinates in microns (3D array)
|
642
|
-
z: Z coordinates in microns (3D array)
|
643
|
-
t: Time in seconds
|
644
|
-
|
645
|
-
Returns:
|
646
|
-
3D array of intensities in W/µm²
|
647
|
-
"""
|
648
|
-
# Get time-dependent parameters
|
649
|
-
power = self.params.get_power(t)
|
650
|
-
pos = self.params.get_position(t)
|
651
|
-
|
652
|
-
# Shift coordinates based on current beam position
|
653
|
-
x_shifted = x - pos[0]
|
654
|
-
y_shifted = y - pos[1]
|
655
|
-
z_shifted = z - pos[2]
|
656
|
-
|
657
|
-
# Base beam parameters
|
658
|
-
w0 = self.params.beam_width # Beam waist
|
659
|
-
zR = self.params.rayleigh_range # Rayleigh range
|
660
|
-
|
661
|
-
# Calculate beam width at z
|
662
|
-
w_z = w0 * np.sqrt(1 + (z_shifted / zR) ** 2)
|
663
|
-
|
664
|
-
# Peak intensity calculation
|
665
|
-
I0 = 2 * power / (np.pi * w0**2)
|
666
|
-
|
667
|
-
# Scanning mode intensity modification
|
668
|
-
if self.scanning_mode == "point":
|
669
|
-
# Point scanning: standard Gaussian beam
|
670
|
-
radial_intensity = (
|
671
|
-
I0
|
672
|
-
* (w0 / w_z) ** 2
|
673
|
-
* np.exp(-2 * (x_shifted**2 + y_shifted**2) / w_z**2)
|
674
|
-
)
|
675
|
-
elif self.scanning_mode == "line":
|
676
|
-
# Line scanning: different intensity distribution
|
677
|
-
if self.line_orientation == "horizontal":
|
678
|
-
line_intensity = (
|
679
|
-
I0 * (w0 / w_z) ** 2 * np.exp(-2 * y_shifted**2 / w_z**2)
|
680
|
-
)
|
681
|
-
radial_intensity = line_intensity
|
682
|
-
else: # vertical line scanning
|
683
|
-
line_intensity = (
|
684
|
-
I0 * (w0 / w_z) ** 2 * np.exp(-2 * x_shifted**2 / w_z**2)
|
685
|
-
)
|
686
|
-
radial_intensity = line_intensity
|
687
|
-
else:
|
688
|
-
raise ValueError(f"Unknown scanning mode: {self.scanning_mode}")
|
689
|
-
|
690
|
-
# Pinhole transmission effect
|
691
|
-
pinhole_effect = self.pinhole_transmission(z_shifted)
|
692
|
-
|
693
|
-
# Final intensity calculation
|
694
|
-
return radial_intensity * pinhole_effect
|
AMS_BP/optics/psf/psf_engine.py
CHANGED
@@ -116,7 +116,7 @@ class PSFEngine:
|
|
116
116
|
return (r <= self.params.pinhole_radius).astype(np.float64)
|
117
117
|
|
118
118
|
@lru_cache(maxsize=128)
|
119
|
-
def psf_z(self, z_val: float) -> NDArray[np.float64]:
|
119
|
+
def psf_z(self, x_val: float, y_val: float, z_val: float) -> NDArray[np.float64]:
|
120
120
|
"""Calculate the PSF at the detector for a point source at z_val.
|
121
121
|
|
122
122
|
This represents how light from a point source at position z_val
|
@@ -124,6 +124,8 @@ class PSFEngine:
|
|
124
124
|
detector. If a pinhole is present, it spatially filters this pattern.
|
125
125
|
|
126
126
|
Args:
|
127
|
+
x_val: x-position of the point source in micrometers
|
128
|
+
y_val: y-position of the point source in micrometers
|
127
129
|
z_val: Z-position of the point source in micrometers
|
128
130
|
|
129
131
|
Returns:
|
@@ -132,7 +134,9 @@ class PSFEngine:
|
|
132
134
|
x, y = self._grid_xy
|
133
135
|
|
134
136
|
# Calculate how light from the point source diffracts through collection optics
|
135
|
-
r_squared = (
|
137
|
+
r_squared = (
|
138
|
+
(x - x_val % self.params.pixel_size) / self._norm_sigma_xy
|
139
|
+
) ** 2 + ((y - y_val % self.params.pixel_size) / self._norm_sigma_xy) ** 2
|
136
140
|
z_term = (z_val / self._norm_sigma_z) ** 2
|
137
141
|
psf_at_detector = np.exp(-0.5 * (r_squared + z_term))
|
138
142
|
|
@@ -252,7 +256,7 @@ def calculate_psf_size(
|
|
252
256
|
Tuple of dimensions (z,y,x) or (y,x) for the PSF calculation
|
253
257
|
"""
|
254
258
|
# Calculate radius to capture important features (2x Airy radius)
|
255
|
-
r_psf =
|
259
|
+
r_psf = 3 * sigma_xy
|
256
260
|
|
257
261
|
# Convert to pixels and ensure odd number
|
258
262
|
pixels_xy = int(np.ceil(r_psf / pixel_size))
|
@@ -168,11 +168,11 @@ class incident_photons:
|
|
168
168
|
photons_n = self.transmission_photon_rate.values[i] * dt
|
169
169
|
photons += photons_n
|
170
170
|
psf_gen = (
|
171
|
-
self.generator[i].
|
172
|
-
|
173
|
-
|
171
|
+
self.generator[i].psf_z(
|
172
|
+
x_val=self.position[0],
|
173
|
+
y_val=self.position[1],
|
174
|
+
z_val=self.position[2],
|
174
175
|
)
|
175
|
-
* self.generator[i].psf_z_xy0(z_val=self.position[2])
|
176
176
|
* photons_n
|
177
177
|
)
|
178
178
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: AMS_BP
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.26
|
4
4
|
Summary: Advanced Microscopy Simulations developed for the Weber Lab by Baljyot Singh Parmar
|
5
5
|
Project-URL: Documentation, https://joemans3.github.io/AMS_BP/
|
6
6
|
Project-URL: Source code, https://github.com/joemans3/AMS_BP
|
@@ -172,4 +172,4 @@ from AMS_BP.configio.saving import save_config_frames
|
|
172
172
|
save_config_frames(metadata, frames, setup_config["base_config"].OutputParameters)
|
173
173
|
```
|
174
174
|
|
175
|
-
> A more detailed example is provided in the jupyter notebook in the examples. For starters refer to the [VisualizingIndividualModules](examples/VisualizingIndividualModules/modules_explained.ipynb)
|
175
|
+
> A more detailed example is provided in the jupyter notebook in the examples. For starters refer to the [VisualizingIndividualModules](examples/VisualizingIndividualModules/modules_explained.ipynb). Then head over to the [laser modulation module](examples/VisualizingIndividualModules/laser_modulation.ipynb) which will show how to change the laser power over time in the simulations. Then view an example of a complex experiment setup for [FRAP](examples/QuantitativeExperiments/FRAP_methods.ipynb) which is possible by the use of compositions of modules in this simulation library.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
AMS_BP/__init__.py,sha256=
|
1
|
+
AMS_BP/__init__.py,sha256=PRd0eVcZs7H8ezQRMXS-q-AES78dJ-DWPSQZT3j5QP0,327
|
2
2
|
AMS_BP/run_cell_simulation.py,sha256=7InopFikjo0HfaLO2siXskBIbyCIte9avG4YXjjaWCI,7420
|
3
3
|
AMS_BP/sim_config.toml,sha256=3IqOQIJYmP5g4okk15nqQiNZb3ij7Pt63HbpI-5tySw,11672
|
4
4
|
AMS_BP/sim_microscopy.py,sha256=u60ApTA6MTUmqSAd7EsAxweKya_Typput8NumDq9fp8,18697
|
@@ -29,11 +29,11 @@ AMS_BP/optics/filters/filters.py,sha256=-iw7eqmDO77SEqlFTv5jJNVwpA8y93TLsjy5hhsA
|
|
29
29
|
AMS_BP/optics/filters/channels/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
30
30
|
AMS_BP/optics/filters/channels/channelschema.py,sha256=SConyA5yVdfnI_8sgcxVC8SV7S8tGUJYPPC6jn7lglU,906
|
31
31
|
AMS_BP/optics/lasers/__init__.py,sha256=T7dHohhyLf_pBw4TidarYHWmiwxVXGE71-Bf1aeBbuc,564
|
32
|
-
AMS_BP/optics/lasers/laser_profiles.py,sha256=
|
32
|
+
AMS_BP/optics/lasers/laser_profiles.py,sha256=7mqf5VMpb0VN_veqYEdeiakr0kaOilfGzNq5mzFQuRw,17136
|
33
33
|
AMS_BP/optics/psf/__init__.py,sha256=ezrKPgpTeR4gTHOvF0mhF6u2zMMTd8Bgp8PGeOf11fA,121
|
34
|
-
AMS_BP/optics/psf/psf_engine.py,sha256=
|
34
|
+
AMS_BP/optics/psf/psf_engine.py,sha256=CDtnZpUvYexIih6ssBZsd5s1RUSa5fjUxgzEVELo6CE,9684
|
35
35
|
AMS_BP/photophysics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
36
|
-
AMS_BP/photophysics/photon_physics.py,sha256=
|
36
|
+
AMS_BP/photophysics/photon_physics.py,sha256=9FWBXaxuSRaSxW8bY0x1d5R5buooibZbRdYTuQcMXhQ,6624
|
37
37
|
AMS_BP/photophysics/state_kinetics.py,sha256=IdZtlHCLs--iSjLwDu2IQA617qXC4la8VpqosrM-vgQ,5401
|
38
38
|
AMS_BP/probabilityfuncs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
39
39
|
AMS_BP/probabilityfuncs/markov_chain.py,sha256=LV6KGr8Lv4NIvBPJqsR0CEynssa_mPH30qLaK85GObA,4339
|
@@ -48,8 +48,8 @@ AMS_BP/utils/decorators.py,sha256=4qFdvzPJne0dhkhD1znPxRln1Rfr5NX8rdcCDcbATRU,62
|
|
48
48
|
AMS_BP/utils/errors.py,sha256=7BOd-L4_YeKmWn3Q4EOdTnNF3Bj_exDa3eg5X0yCZrc,759
|
49
49
|
AMS_BP/utils/maskMaker.py,sha256=2ca3n2nc8rFtUh1LurKXOJJsUmhrOpWbRnVX7fjRVvs,335
|
50
50
|
AMS_BP/utils/util_functions.py,sha256=jI6WBh09_khdABnEoVK7SK1WRvCLHuw40f5ALyflzlc,9478
|
51
|
-
ams_bp-0.0.
|
52
|
-
ams_bp-0.0.
|
53
|
-
ams_bp-0.0.
|
54
|
-
ams_bp-0.0.
|
55
|
-
ams_bp-0.0.
|
51
|
+
ams_bp-0.0.26.dist-info/METADATA,sha256=aaB17p23_wqvfOqQQfb90g7zFD1MrgpdXwoCsbYx37s,5869
|
52
|
+
ams_bp-0.0.26.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
53
|
+
ams_bp-0.0.26.dist-info/entry_points.txt,sha256=MFUK9bZWW61djfsavqopMqiVPVn4lJtt6v8qzyEFyNM,76
|
54
|
+
ams_bp-0.0.26.dist-info/licenses/LICENSE,sha256=k_-JV1DQKvO0FR8WjvOisqdTl0kp6VJ7RFM3YZhao0c,1071
|
55
|
+
ams_bp-0.0.26.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|