@@ -15,6 +15,7 @@ Complete example of two-photon calcium imaging with full optical path configurat
1515
1616 from datetime import datetime
1717 from uuid import uuid4
18+ import matplotlib.pyplot as plt
1819 import numpy as np
1920 from pynwb import NWBFile, NWBHDF5IO
2021 from ndx_microscopy import (
@@ -55,67 +56,71 @@ Complete example of two-photon calcium imaging with full optical path configurat
5556 )
5657 nwbfile.add_device(microscope)
5758
58- # Set up optical components
5959 laser = PulsedExcitationSource(
60- name = ' chameleon' ,
61- illumination_type = ' Laser' ,
62- manufacturer = ' Coherent' ,
63- model = ' Chameleon Ultra II' ,
64- excitation_wavelength_in_nm = 920.0 ,
65- power_in_W = 1.2 ,
66- peak_power_in_W = 100e3 ,
67- peak_pulse_energy_in_J = 1.25e-9 ,
68- pulse_rate_in_Hz = 80e6
60+ name = " chameleon" ,
61+ illumination_type = " Laser" ,
62+ manufacturer = " Coherent" ,
63+ model = " Chameleon Ultra II" ,
64+ excitation_mode = " two-photon" ,
65+ excitation_wavelength_in_nm = 920.0 , # Common for GCaMP6f imaging
66+ power_in_W = 2.5 , # Average power at sample, typically 1-3W for deep imaging
67+ peak_power_in_W = 100000.0 , # 100kW peak power
68+ peak_pulse_energy_in_J = 1.25e-9 , # 1.25 nJ
69+ pulse_rate_in_Hz = 80.0e6 , # 80MHz typical for Chameleon Ultra II
6970 )
7071 nwbfile.add_device(laser)
7172
7273 excitation_filter = BandOpticalFilter(
73- name = ' excitation_filter' ,
74- filter_type = ' Bandpass' ,
75- manufacturer = ' Semrock' ,
76- model = ' FF01-920/80' ,
74+ name = " excitation_filter" ,
75+ filter_type = " Bandpass" ,
76+ manufacturer = " Semrock" ,
77+ model = " FF01-920/80" ,
7778 center_wavelength_in_nm = 920.0 ,
78- bandwidth_in_nm = 80.0
79+ bandwidth_in_nm = 80.0 ,
7980 )
8081 nwbfile.add_device(excitation_filter)
8182
8283 dichroic = DichroicMirror(
83- name = ' primary_dichroic' ,
84- manufacturer = ' Semrock' ,
85- model = ' FF695-Di02' ,
86- cut_wavelength_in_nm = 695.0
84+ name = " primary_dichroic" ,
85+ manufacturer = " Semrock" ,
86+ model = " FF757-Di01" , # Common dichroic for GCaMP imaging
87+ cut_on_wavelength_in_nm = 757.0 , # Transmits >757nm
88+ cut_off_wavelength_in_nm = 750.0 , # Reflects <750nm
89+ transmission_band_in_nm = [757.0 , 1100.0 ], # Transmits NIR excitation light
90+ reflection_band_in_nm = (400.0 , 750.0 ), # Reflects emission light (including 510nm GCaMP6f emission)
91+ angle_of_incidence_in_degrees = 45.0 , # Standard angle for dichroic mirrors in microscopes
8792 )
8893 nwbfile.add_device(dichroic)
8994
9095 emission_filter = BandOpticalFilter(
91- name = ' emission_filter' ,
92- filter_type = ' Bandpass' ,
93- manufacturer = ' Semrock' ,
94- model = ' FF01-510/84' ,
96+ name = " emission_filter" ,
97+ filter_type = " Bandpass" ,
98+ manufacturer = " Semrock" ,
99+ model = " FF01-510/84" ,
95100 center_wavelength_in_nm = 510.0 ,
96- bandwidth_in_nm = 84.0
101+ bandwidth_in_nm = 84.0 ,
97102 )
98103 nwbfile.add_device(emission_filter)
99104
100105 detector = Photodetector(
101- name = ' pmt' ,
102- detector_type = ' PMT' ,
103- manufacturer = ' Hamamatsu' ,
104- model = ' R6357' ,
106+ name = " pmt" ,
107+ detector_type = " PMT" ,
108+ manufacturer = " Hamamatsu" ,
109+ model = " R6357" ,
105110 detected_wavelength_in_nm = 510.0 ,
106- gain = 70 .0 ,
107- gain_unit = ' dB '
111+ gain = 1000000 .0 , # 10^6 typical PMT gain
112+ gain_unit = " V/A " , # Voltage/Current
108113 )
109114 nwbfile.add_device(detector)
110115
111116 # Create indicator
112117 indicator = Indicator(
113- name = ' gcamp6f' ,
114- label = ' GCaMP6f' ,
115- description = ' Calcium indicator for two-photon imaging' ,
116- manufacturer = ' Addgene' ,
117- injection_brain_region = ' Visual cortex' ,
118- injection_coordinates_in_mm = [- 2.5 , 3.2 , 0.5 ]
118+ name = " gcamp6f" ,
119+ label = " GCaMP6f" ,
120+ description = " Calcium indicator for two-photon imaging" ,
121+ manufacturer = " Addgene" ,
122+ injection_brain_region = " Visual cortex" ,
123+ injection_coordinates_in_mm = [- 2.5 , 3.2 , 0.5 ],
119124 )
120125
121126 # Configure light paths
@@ -162,7 +167,7 @@ Complete example of two-photon calcium imaging with full optical path configurat
162167 microscope = microscope,
163168 excitation_light_path = excitation,
164169 emission_light_path = emission,
165- imaging_space = imaging_space,
170+ planar_imaging_space = imaging_space,
166171 data = data,
167172 unit = ' a.u.' ,
168173 rate = 30.0 ,
@@ -202,13 +207,13 @@ Complete example of two-photon calcium imaging with full optical path configurat
202207 roi_mask[256 :266 , 256 :266 ] = True # 10x10 ROI
203208 segmentation.add_roi(image_mask = roi_mask)
204209
205- # Add ROIs using pixel masks
206- pixel_mask = [
207- [100 , 100 , 1.0 ], # x, y, weight
208- [101 , 100 , 1.0 ],
209- [102 , 100 , 1.0 ]
210- ]
211- segmentation.add_roi(pixel_mask = pixel_mask)
210+ # OR Add ROIs using pixel masks
211+ # pixel_mask = [
212+ # [100, 100, 1.0], # x, y, weight
213+ # [101, 100, 1.0],
214+ # [102, 100, 1.0]
215+ # ]
216+ # segmentation.add_roi(pixel_mask=pixel_mask)
212217
213218 # Create ROI responses
214219 roi_region = segmentation.create_roi_table_region(
@@ -219,7 +224,7 @@ Complete example of two-photon calcium imaging with full optical path configurat
219224 # Extract responses (example calculation)
220225 num_rois = len (segmentation.id)
221226 responses = np.zeros((frames, num_rois))
222-
227+
223228 for i, roi_mask in enumerate (segmentation.image_mask[:]):
224229 roi_data = data[:, roi_mask]
225230 responses[:, i] = np.mean(roi_data, axis = 1 )
@@ -252,16 +257,16 @@ Complete example of two-photon calcium imaging with full optical path configurat
252257 # Read file and access data
253258 with NWBHDF5IO(' calcium_imaging.nwb' , ' r' ) as io:
254259 nwbfile = io.read()
255-
260+
256261 # Access imaging data
257262 imaging = nwbfile.acquisition[' imaging_data' ]
258263 raw_data = imaging.data[:]
259-
264+
260265 # Access ROI data
261266 ophys = nwbfile.processing[' ophys' ]
262267 rois = ophys[' rois' ]
263268 roi_masks = rois.image_mask[:]
264-
269+
265270 # Access responses
266271 responses = ophys[' responses' ]
267272 roi_data = responses[' roi_responses' ].data[:]
@@ -321,6 +326,7 @@ Example of volumetric imaging with 3D ROI segmentation:
321326 illumination_type = ' Laser' ,
322327 manufacturer = ' Coherent' ,
323328 model = ' Chameleon' ,
329+ excitation_mode = " two-photon" ,
324330 excitation_wavelength_in_nm = 920.0 ,
325331 power_in_W = 2.0 ,
326332 intensity_in_W_per_m2 = 1000.0 ,
0 commit comments