From 5ac7eefd882319102b6bf9fa562252c141ee8cfe Mon Sep 17 00:00:00 2001 From: codycbakerphd Date: Wed, 17 Jul 2024 15:59:49 -0400 Subject: [PATCH 1/5] debugs --- src/pynwb/ndx_microscopy/testing/_mock.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pynwb/ndx_microscopy/testing/_mock.py b/src/pynwb/ndx_microscopy/testing/_mock.py index ff8bb4d..98b7ad9 100644 --- a/src/pynwb/ndx_microscopy/testing/_mock.py +++ b/src/pynwb/ndx_microscopy/testing/_mock.py @@ -78,7 +78,7 @@ def mock_PlanarImagingSpace( name: Optional[str] = None, description: str = "This is a mock instance of a PlanarImagingSpace type to be used for rapid testing.", origin_coordinates: Tuple[float, float, float] = (-1.2, -0.6, -2), - grid_spacing_in_mm: Tuple[float, float, float] = (0.2, 0.2), + grid_spacing_in_um: Tuple[float, float, float] = (20, 20), location: str = "The location targeted by the mock imaging space.", reference_frame: str = "The reference frame of the mock planar imaging space.", ) -> ndx_microscopy.PlanarImagingSpace: @@ -87,7 +87,7 @@ def mock_PlanarImagingSpace( description=description, microscope=microscope, origin_coordinates=origin_coordinates, - grid_spacing_in_mm=grid_spacing_in_mm, + grid_spacing_in_um=grid_spacing_in_um, location=location, reference_frame=reference_frame, ) @@ -100,7 +100,7 @@ def mock_VolumetricImagingSpace( name: Optional[str] = None, description: str = "This is a mock instance of a VolumetricImagingSpace type to be used for rapid testing.", origin_coordinates: Tuple[float, float, float] = (-1.2, -0.6, -2), - grid_spacing_in_mm: Tuple[float, float, float] = (0.2, 0.2, 0.5), + grid_spacing_in_um: Tuple[float, float, float] = (20, 20, 50), location: str = "The location targeted by the mock imaging space.", reference_frame: str = "The reference frame of the mock volumetric imaging space.", ) -> ndx_microscopy.VolumetricImagingSpace: @@ -109,7 +109,7 @@ def mock_VolumetricImagingSpace( description=description, microscope=microscope, origin_coordinates=origin_coordinates, - grid_spacing_in_mm=grid_spacing_in_mm, + grid_spacing_in_um=grid_spacing_in_um, location=location, reference_frame=reference_frame, ) From 7effd8ea2927858d1c3d38d6645a48178d07160a Mon Sep 17 00:00:00 2001 From: codycbakerphd Date: Wed, 17 Jul 2024 17:30:40 -0400 Subject: [PATCH 2/5] debugs --- src/pynwb/ndx_microscopy/testing/_mock.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pynwb/ndx_microscopy/testing/_mock.py b/src/pynwb/ndx_microscopy/testing/_mock.py index 98b7ad9..0af0239 100644 --- a/src/pynwb/ndx_microscopy/testing/_mock.py +++ b/src/pynwb/ndx_microscopy/testing/_mock.py @@ -122,7 +122,12 @@ def mock_MicroscopySegmentations( microscopy_plane_segmentations: Optional[Iterable[ndx_microscopy.MicroscopyPlaneSegmentation]] = None, ) -> ndx_microscopy.MicroscopySegmentations: name = name or name_generator("MicroscopySegmentations") - microscopy_plane_segmentations = microscopy_plane_segmentations or [mock_MicroscopyPlaneSegmentation()] + + microscope = mock_Microscope() + imaging_space = mock_PlanarImagingSpace(microscope=microscope) + microscopy_plane_segmentations = microscopy_plane_segmentations or [ + mock_MicroscopyPlaneSegmentation(imaging_space=imaging_space) + ] segmentations = ndx_microscopy.MicroscopySegmentations( name=name, microscopy_plane_segmentations=microscopy_plane_segmentations @@ -142,11 +147,15 @@ def mock_MicroscopyPlaneSegmentation( name = name or name_generator("MicroscopyPlaneSegmentation") plane_segmentation = ndx_microscopy.MicroscopyPlaneSegmentation( - name=name, description=description, imaging_space=imaging_space + name=name, + description=description, + imaging_space=imaging_space, ) + image_masks = list() for _ in range(number_of_rois): - plane_segmentation.add_roi(image_mask=np.zeros(image_shape, dtype=bool)) + image_masks.append(np.zeros(image_shape, dtype=bool)) + plane_segmentation.add_column(name="image_mask", description="", data=image_masks) return plane_segmentation From 1d6fede3a6692d1c5a256bc1a6b66faec4e0818a Mon Sep 17 00:00:00 2001 From: codycbakerphd Date: Wed, 17 Jul 2024 17:35:02 -0400 Subject: [PATCH 3/5] debugs --- src/pynwb/ndx_microscopy/testing/_mock.py | 1 + src/pynwb/tests/test_constructors.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pynwb/ndx_microscopy/testing/_mock.py b/src/pynwb/ndx_microscopy/testing/_mock.py index 0af0239..6e34605 100644 --- a/src/pynwb/ndx_microscopy/testing/_mock.py +++ b/src/pynwb/ndx_microscopy/testing/_mock.py @@ -151,6 +151,7 @@ def mock_MicroscopyPlaneSegmentation( description=description, imaging_space=imaging_space, ) + plane_segmentation.add_column(name="id", description="", data=list(range(number_of_rois))) image_masks = list() for _ in range(number_of_rois): diff --git a/src/pynwb/tests/test_constructors.py b/src/pynwb/tests/test_constructors.py index af884f5..bf412f3 100644 --- a/src/pynwb/tests/test_constructors.py +++ b/src/pynwb/tests/test_constructors.py @@ -135,8 +135,8 @@ def test_constructor_variable_depth_multi_channel_microscopy_volume(): mock_VariableDepthMultiChannelMicroscopyVolume( microscope=microscope, - light_source=light_source, imaging_space=imaging_space, + light_sources=[light_source], optical_channels=[optical_channel], ) From 1d68a4a222af82e3aa7780f3999d262b0955bc06 Mon Sep 17 00:00:00 2001 From: codycbakerphd Date: Wed, 17 Jul 2024 17:40:20 -0400 Subject: [PATCH 4/5] debugs --- src/pynwb/tests/test_constructors.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/pynwb/tests/test_constructors.py b/src/pynwb/tests/test_constructors.py index bf412f3..f5c29aa 100644 --- a/src/pynwb/tests/test_constructors.py +++ b/src/pynwb/tests/test_constructors.py @@ -129,15 +129,26 @@ def test_constructor_multi_channel_microscopy_volume(): def test_constructor_variable_depth_multi_channel_microscopy_volume(): microscope = mock_Microscope() - light_source = mock_MicroscopyLightSource() imaging_space = mock_VolumetricImagingSpace(microscope=microscope) - optical_channel = mock_MicroscopyOpticalChannel() + light_sources = [mock_MicroscopyLightSource()] + optical_channels = [mock_MicroscopyOpticalChannel()] + light_sources_used_by_volume = pynwb.base.VectorData( + name="light_sources", description="Light sources used by this MultiChannelVolume.", data=light_sources + ) + optical_channels_used_by_volume = pynwb.base.VectorData( + name="optical_channels", + description=( + "Optical channels ordered to correspond to the third axis (e.g., [0, 0, :, 0]) " + "of the data for this MultiChannelVolume." + ), + data=optical_channels, + ) mock_VariableDepthMultiChannelMicroscopyVolume( microscope=microscope, imaging_space=imaging_space, - light_sources=[light_source], - optical_channels=[optical_channel], + light_sources=light_sources_used_by_volume, + optical_channels=optical_channels_used_by_volume, ) From 5400462f7fac226c13239b8ef9a827fdbc477b7e Mon Sep 17 00:00:00 2001 From: codycbakerphd Date: Thu, 18 Jul 2024 13:20:44 -0400 Subject: [PATCH 5/5] debugs --- src/pynwb/ndx_microscopy/testing/_mock.py | 14 ++++++-------- src/pynwb/tests/test_roundtrip.py | 10 ++++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/pynwb/ndx_microscopy/testing/_mock.py b/src/pynwb/ndx_microscopy/testing/_mock.py index 6e34605..482e308 100644 --- a/src/pynwb/ndx_microscopy/testing/_mock.py +++ b/src/pynwb/ndx_microscopy/testing/_mock.py @@ -147,11 +147,9 @@ def mock_MicroscopyPlaneSegmentation( name = name or name_generator("MicroscopyPlaneSegmentation") plane_segmentation = ndx_microscopy.MicroscopyPlaneSegmentation( - name=name, - description=description, - imaging_space=imaging_space, + name=name, description=description, imaging_space=imaging_space, id=list(range(number_of_rois)) ) - plane_segmentation.add_column(name="id", description="", data=list(range(number_of_rois))) + # plane_segmentation.add_column(name="id", description="", data=list(range(number_of_rois))) image_masks = list() for _ in range(number_of_rois): @@ -367,9 +365,9 @@ def mock_MultiChannelMicroscopyVolume( def mock_VariableDepthMultiChannelMicroscopyVolume( *, microscope: ndx_microscopy.Microscope, - light_sources: List[ndx_microscopy.MicroscopyLightSource], imaging_space: ndx_microscopy.VolumetricImagingSpace, - optical_channels: List[ndx_microscopy.MicroscopyOpticalChannel], + light_sources: pynwb.base.VectorData, + optical_channels: pynwb.base.VectorData, name: Optional[str] = None, description: str = "This is a mock instance of a MultiChannelMicroscopyVolume type to be used for rapid testing.", data: Optional[np.ndarray] = None, @@ -392,9 +390,9 @@ def mock_VariableDepthMultiChannelMicroscopyVolume( name=series_name, description=description, microscope=microscope, - light_sources=light_sources[0], # TODO: figure out how to specify list imaging_space=imaging_space, - optical_channels=optical_channels[0], # TODO: figure out how to specify list + light_sources=light_sources, + optical_channels=optical_channels, data=imaging_data, depth_per_frame_in_mm=volume_depth_per_frame_in_mm, unit=unit, diff --git a/src/pynwb/tests/test_roundtrip.py b/src/pynwb/tests/test_roundtrip.py index ff17ef3..4d9f830 100644 --- a/src/pynwb/tests/test_roundtrip.py +++ b/src/pynwb/tests/test_roundtrip.py @@ -247,10 +247,10 @@ def tearDown(self): def test_roundtrip(self): nwbfile = mock_NWBFile() - microscope = mock_Microscope() + microscope = mock_Microscope(name="Microscope") nwbfile.add_device(devices=microscope) - imaging_space = mock_PlanarImagingSpace(microscope=microscope) + imaging_space = mock_PlanarImagingSpace(name="PlanarImagingSpace", microscope=microscope) nwbfile.add_lab_meta_data(lab_meta_data=imaging_space) # Would prefer .add_imaging_space() plane_segmentation_1 = mock_MicroscopyPlaneSegmentation( @@ -261,8 +261,10 @@ def test_roundtrip(self): ) microscopy_plane_segmentations = [plane_segmentation_1, plane_segmentation_2] - segmentations = mock_MicroscopySegmentations(microscopy_plane_segmentations=microscopy_plane_segmentations) - processing_module = nwbfile.create_processing_module(name="ophys") + segmentations = mock_MicroscopySegmentations( + name="MicroscopySegmentations", microscopy_plane_segmentations=microscopy_plane_segmentations + ) + processing_module = nwbfile.create_processing_module(name="ophys", description="") processing_module.add(segmentations) with pynwb.NWBHDF5IO(path=self.nwbfile_path, mode="w") as io: