|
4 | 4 |
|
5 | 5 | import numpy as np |
6 | 6 | from pynwb import NWBFile |
7 | | -from pynwb.ophys import OpticalChannel, ImageSegmentation, RoiResponseSeries |
| 7 | +from pynwb.device import Device |
| 8 | +from pynwb.ophys import OpticalChannel, ImageSegmentation, RoiResponseSeries, ImagingPlane |
8 | 9 | from hdmf.common.table import DynamicTableRegion, DynamicTable |
9 | 10 |
|
10 | 11 | from nwbinspector.checks.ophys import ( |
11 | 12 | check_roi_response_series_dims, |
12 | 13 | check_roi_response_series_link_to_plane_segmentation, |
| 14 | + check_excitation_lambda_in_nm, |
| 15 | + check_emission_lambda_in_nm, |
13 | 16 | ) |
14 | 17 | from nwbinspector.register_checks import InspectorMessage, Importance |
15 | 18 |
|
@@ -167,3 +170,60 @@ def test_pass_check_roi_response_series_link_to_plane_segmentation(self): |
167 | 170 | ) |
168 | 171 |
|
169 | 172 | assert check_roi_response_series_link_to_plane_segmentation(roi_resp_series) is None |
| 173 | + |
| 174 | + |
| 175 | +def test_check_excitation_lambda_in_nm(): |
| 176 | + |
| 177 | + device = Device( |
| 178 | + name="Microscope", description="My two-photon microscope", manufacturer="The best microscope manufacturer" |
| 179 | + ) |
| 180 | + optical_channel = OpticalChannel(name="OpticalChannel", description="an optical channel", emission_lambda=500.0) |
| 181 | + imaging_plane = ImagingPlane( |
| 182 | + name="ImagingPlane", |
| 183 | + optical_channel=optical_channel, |
| 184 | + imaging_rate=30.0, |
| 185 | + description="a very interesting part of the brain", |
| 186 | + device=device, |
| 187 | + excitation_lambda=1.0, |
| 188 | + indicator="GFP", |
| 189 | + location="V1", |
| 190 | + grid_spacing=[0.01, 0.01], |
| 191 | + grid_spacing_unit="meters", |
| 192 | + origin_coords=[1.0, 2.0, 3.0], |
| 193 | + origin_coords_unit="meters", |
| 194 | + ) |
| 195 | + |
| 196 | + assert check_excitation_lambda_in_nm(imaging_plane).message == "excitation lambda of 1.0 should be in units of nm." |
| 197 | + |
| 198 | + |
| 199 | +def test_pass_check_excitation_lambda_in_nm(): |
| 200 | + device = Device( |
| 201 | + name="Microscope", description="My two-photon microscope", manufacturer="The best microscope manufacturer" |
| 202 | + ) |
| 203 | + optical_channel = OpticalChannel(name="OpticalChannel", description="an optical channel", emission_lambda=500.0) |
| 204 | + imaging_plane = ImagingPlane( |
| 205 | + name="ImagingPlane", |
| 206 | + optical_channel=optical_channel, |
| 207 | + imaging_rate=30.0, |
| 208 | + description="a very interesting part of the brain", |
| 209 | + device=device, |
| 210 | + excitation_lambda=300.0, |
| 211 | + indicator="GFP", |
| 212 | + location="V1", |
| 213 | + grid_spacing=[0.01, 0.01], |
| 214 | + grid_spacing_unit="meters", |
| 215 | + origin_coords=[1.0, 2.0, 3.0], |
| 216 | + origin_coords_unit="meters", |
| 217 | + ) |
| 218 | + |
| 219 | + assert check_excitation_lambda_in_nm(imaging_plane) is None |
| 220 | + |
| 221 | + |
| 222 | +def test_check_emission_lambda_in_nm(): |
| 223 | + optical_channel = OpticalChannel(name="OpticalChannel", description="an optical channel", emission_lambda=5.0) |
| 224 | + assert check_emission_lambda_in_nm(optical_channel).message == "emission lambda of 5.0 should be in units of nm." |
| 225 | + |
| 226 | + |
| 227 | +def test_pass_check_emission_lambda_in_nm(): |
| 228 | + optical_channel = OpticalChannel(name="OpticalChannel", description="an optical channel", emission_lambda=500.0) |
| 229 | + assert check_emission_lambda_in_nm(optical_channel) is None |
0 commit comments