Skip to content

Commit ee4cfdd

Browse files
Add false positive skip for ImageSeries check on TwoPhotonSeries (#301)
* added false positive skip and test * fix int * fix magnitude * fix magnitude to safer level
1 parent bfd4183 commit ee4cfdd

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/nwbinspector/checks/image_series.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pathlib import Path
44

55
from pynwb.image import ImageSeries
6+
from pynwb.ophys import TwoPhotonSeries
67

78
from ..register_checks import register_check, Importance, InspectorMessage
89
from ..tools import get_nwbfile_path_from_internal_object
@@ -56,6 +57,11 @@ def check_image_series_data_size(image_series: ImageSeries, gb_lower_bound: floa
5657
5758
Best Practice: :ref:`best_practice_use_external_mode`
5859
"""
60+
# False positive case; TwoPhotonSeries are a subclass of ImageSeries, but it is very common and perfectly fine
61+
# to write lots of data using one without an external file
62+
if isinstance(image_series, TwoPhotonSeries):
63+
return
64+
5965
data = image_series.data
6066

6167
if getattr(data, "compression", None) is not None:

tests/unit_tests/test_ophys.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
check_excitation_lambda_in_nm,
2424
check_emission_lambda_in_nm,
2525
check_plane_segmentation_image_mask_shape_against_ref_images,
26+
check_image_series_data_size, # Technically an ImageSeries check, but test is more convenient here
2627
)
2728

2829

@@ -327,3 +328,37 @@ def test_fail_check_plane_segmentation_image_mask_dims_against_imageseries():
327328
location="/",
328329
)
329330
]
331+
332+
333+
def test_false_positive_skip_check_image_series_data_size():
334+
335+
device = Device(
336+
name="Microscope", description="My two-photon microscope", manufacturer="The best microscope manufacturer"
337+
)
338+
optical_channel = OpticalChannel(name="OpticalChannel", description="an optical channel", emission_lambda=500.0)
339+
imaging_plane = ImagingPlane(
340+
name="ImagingPlane",
341+
optical_channel=optical_channel,
342+
imaging_rate=30.0,
343+
description="a very interesting part of the brain",
344+
device=device,
345+
excitation_lambda=300.0,
346+
indicator="GFP",
347+
location="V1",
348+
grid_spacing=[0.01, 0.01],
349+
grid_spacing_unit="meters",
350+
origin_coords=[1.0, 2.0, 3.0],
351+
origin_coords_unit="meters",
352+
)
353+
354+
two_photon_series = TwoPhotonSeries(
355+
name="TwoPhotonSeries",
356+
imaging_plane=imaging_plane,
357+
data=np.empty(
358+
shape=(110 * 10**6, 1, 1), dtype="uint8"
359+
), # Empty data, but of shape+dtype that would be more than default GB threshold
360+
unit="n.a.",
361+
rate=30.0,
362+
)
363+
364+
assert check_image_series_data_size(image_series=two_photon_series, gb_lower_bound=0.1) is None

0 commit comments

Comments
 (0)