Skip to content

Commit

Permalink
Add false positive skip for ImageSeries check on TwoPhotonSeries (#301)
Browse files Browse the repository at this point in the history
* added false positive skip and test

* fix int

* fix magnitude

* fix magnitude to safer level
  • Loading branch information
CodyCBakerPhD authored Nov 24, 2022
1 parent bfd4183 commit ee4cfdd
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/nwbinspector/checks/image_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path

from pynwb.image import ImageSeries
from pynwb.ophys import TwoPhotonSeries

from ..register_checks import register_check, Importance, InspectorMessage
from ..tools import get_nwbfile_path_from_internal_object
Expand Down Expand Up @@ -56,6 +57,11 @@ def check_image_series_data_size(image_series: ImageSeries, gb_lower_bound: floa
Best Practice: :ref:`best_practice_use_external_mode`
"""
# False positive case; TwoPhotonSeries are a subclass of ImageSeries, but it is very common and perfectly fine
# to write lots of data using one without an external file
if isinstance(image_series, TwoPhotonSeries):
return

data = image_series.data

if getattr(data, "compression", None) is not None:
Expand Down
35 changes: 35 additions & 0 deletions tests/unit_tests/test_ophys.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
check_excitation_lambda_in_nm,
check_emission_lambda_in_nm,
check_plane_segmentation_image_mask_shape_against_ref_images,
check_image_series_data_size, # Technically an ImageSeries check, but test is more convenient here
)


Expand Down Expand Up @@ -327,3 +328,37 @@ def test_fail_check_plane_segmentation_image_mask_dims_against_imageseries():
location="/",
)
]


def test_false_positive_skip_check_image_series_data_size():

device = Device(
name="Microscope", description="My two-photon microscope", manufacturer="The best microscope manufacturer"
)
optical_channel = OpticalChannel(name="OpticalChannel", description="an optical channel", emission_lambda=500.0)
imaging_plane = ImagingPlane(
name="ImagingPlane",
optical_channel=optical_channel,
imaging_rate=30.0,
description="a very interesting part of the brain",
device=device,
excitation_lambda=300.0,
indicator="GFP",
location="V1",
grid_spacing=[0.01, 0.01],
grid_spacing_unit="meters",
origin_coords=[1.0, 2.0, 3.0],
origin_coords_unit="meters",
)

two_photon_series = TwoPhotonSeries(
name="TwoPhotonSeries",
imaging_plane=imaging_plane,
data=np.empty(
shape=(110 * 10**6, 1, 1), dtype="uint8"
), # Empty data, but of shape+dtype that would be more than default GB threshold
unit="n.a.",
rate=30.0,
)

assert check_image_series_data_size(image_series=two_photon_series, gb_lower_bound=0.1) is None

0 comments on commit ee4cfdd

Please sign in to comment.