diff --git a/spec/ndx-microscopy.extensions.yaml b/spec/ndx-microscopy.extensions.yaml index e7a7825..0204806 100644 --- a/spec/ndx-microscopy.extensions.yaml +++ b/spec/ndx-microscopy.extensions.yaml @@ -58,9 +58,6 @@ groups: neurodata_type_inc: NWBContainer doc: Abstract class to contain metadata about the region of physical space that imaging data was recorded from. Extended by PlanarImagingSpace and VolumetricImagingSpace. datasets: - - name: description - dtype: text - doc: Description of the imaging space. - name: origin_coordinates dtype: float64 dims: @@ -77,6 +74,9 @@ groups: default_value: micrometers doc: Measurement units for origin coordinates. The default value is 'micrometers'. attributes: + - name: description + dtype: text + doc: Description of the imaging space. - name: location dtype: text doc: @@ -220,15 +220,39 @@ groups: doc: Results from image segmentation of a specific imaging space. quantity: "+" - - neurodata_type_def: SummaryImages - neurodata_type_inc: Images + - neurodata_type_def: SummaryImage + neurodata_type_inc: NWBContainer doc: Summary images that are related to the segmentation, e.g., mean, correlation, maximum projection. + datasets: + - name: data + doc: Summary image data. + dtype: numeric + dims: + - - height + - width + - - height + - width + - depth + shape: + - - null + - null + - - null + - null + - null + attributes: + - name: description + dtype: text + doc: Description of the summary image. - neurodata_type_def: Segmentation neurodata_type_inc: DynamicTable doc: Abstract class to contain the results from image segmentation of a specific imaging space. + attributes: + - name: description + dtype: text + doc: Description of the segmentation method used. groups: - - neurodata_type_inc: SummaryImages + - neurodata_type_inc: SummaryImage doc: Summary images that are related to the segmentation, e.g., mean, correlation, maximum projection. quantity: "*" diff --git a/spec/ndx-microscopy.namespace.yaml b/spec/ndx-microscopy.namespace.yaml index 75bf1c6..1e1d5cf 100644 --- a/spec/ndx-microscopy.namespace.yaml +++ b/spec/ndx-microscopy.namespace.yaml @@ -1,14 +1,30 @@ namespaces: -- name: ndx-microscopy - doc: Microscopy extension to NWB standard. - author: - - Cody Baker - - Alessandra Trapani - contact: - - cody.baker@catalystneuro.com - - alessandra.trapani@catalystneuro.com - schema: - - namespace: core - - namespace: ndx-ophys-devices - - source: ndx-microscopy.extensions.yaml - version: 0.1.0 + - name: ndx-microscopy + doc: Microscopy extension to NWB standard. + author: + - Cody Baker + - Alessandra Trapani + contact: + - cody.baker@catalystneuro.com + - alessandra.trapani@catalystneuro.com + schema: + - namespace: core + neurodata_types: + - Device + - LabMetaData + - NWBContainer + - TimeSeries + - NWBDataInterface + - DynamicTable + - VectorData + - VectorIndex + - DynamicTableRegion + - namespace: ndx-ophys-devices + neurodata_types: + - ExcitationSource + - Indicator + - OpticalFilter + - Photodetector + - DichroicMirror + - source: ndx-microscopy.extensions.yaml + version: 0.1.0 diff --git a/src/pynwb/ndx_microscopy/__init__.py b/src/pynwb/ndx_microscopy/__init__.py index e789d54..99850ad 100644 --- a/src/pynwb/ndx_microscopy/__init__.py +++ b/src/pynwb/ndx_microscopy/__init__.py @@ -35,7 +35,7 @@ ) Microscope = get_class("Microscope", extension_name) - +SummaryImage = get_class("SummaryImage", extension_name) PlanarImagingSpace = get_class("PlanarImagingSpace", extension_name) VolumetricImagingSpace = get_class("VolumetricImagingSpace", extension_name) diff --git a/src/pynwb/ndx_microscopy/testing/_mock.py b/src/pynwb/ndx_microscopy/testing/_mock.py index ca58d83..8f54f23 100644 --- a/src/pynwb/ndx_microscopy/testing/_mock.py +++ b/src/pynwb/ndx_microscopy/testing/_mock.py @@ -114,23 +114,32 @@ def mock_VolumetricImagingSpace( return volumetric_imaging_space +def mock_SummaryImage( + *, + name: Optional[str] = None, + description: str = "A mock instance of a SummaryImage type to be used for rapid testing.", + image_shape: Tuple[int, int] = (10, 10), + data: Optional[np.ndarray] = None, +) -> ndx_microscopy.SummaryImage: + name = name or name_generator("SummaryImage") + data = data if data is not None else np.ones(image_shape) + summary_image = ndx_microscopy.SummaryImage(name=name, description=description, data=data) + return summary_image + + def mock_Segmentation( *, name: Optional[str] = None, description: str = "A mock instance of a Segmentation type to be used for rapid testing.", - summary_images: Optional[List[pynwb.base.Images]] = None, + summary_images: Optional[List[ndx_microscopy.SummaryImage]] = None, ) -> ndx_microscopy.Segmentation: """Base abstract class with summary images.""" name = name or name_generator("Segmentation") # Create default summary images if none provided if summary_images is None: - mean_image = pynwb.base.Image( - name="mean", data=np.ones((10, 10)), description="Mean intensity projection" # Example shape - ) - max_image = pynwb.base.Image( - name="max", data=np.ones((10, 10)), description="Maximum intensity projection" # Example shape - ) + mean_image = mock_SummaryImage(name="mean", description="Mean intensity projection") + max_image = mock_SummaryImage(name="max", description="Maximum intensity projection") summary_images = [mean_image, max_image] segmentation = ndx_microscopy.Segmentation(name=name, description=description, summary_images=summary_images) @@ -145,15 +154,15 @@ def mock_Segmentation2D( description: str = "A mock instance of a Segmentation2D type to be used for rapid testing.", number_of_rois: int = 5, image_shape: Tuple[int, int] = (10, 10), - summary_images: Optional[List[pynwb.base.Images]] = None, + summary_images: Optional[List[ndx_microscopy.SummaryImage]] = None, ) -> ndx_microscopy.Segmentation2D: """2D segmentation with image_mask/pixel_mask.""" name = name or name_generator("Segmentation2D") # Create default summary images if none provided if summary_images is None: - mean_image = pynwb.base.Image(name="mean", data=np.ones(image_shape), description="Mean intensity projection") - max_image = pynwb.base.Image(name="max", data=np.ones(image_shape), description="Maximum intensity projection") + mean_image = mock_SummaryImage(name="mean", description="Mean intensity projection", image_shape=image_shape) + max_image = mock_SummaryImage(name="max", description="Maximum intensity projection", image_shape=image_shape) summary_images = [mean_image, max_image] segmentation_2D = ndx_microscopy.Segmentation2D( @@ -181,23 +190,15 @@ def mock_Segmentation3D( description: str = "A mock instance of a Segmentation3D type to be used for rapid testing.", number_of_rois: int = 5, image_shape: Tuple[int, int, int] = (10, 10, 10), - summary_images: Optional[List[pynwb.base.Images]] = None, + summary_images: Optional[List[ndx_microscopy.SummaryImage]] = None, ) -> ndx_microscopy.Segmentation3D: """3D segmentation with image_mask/voxel_mask.""" name = name or name_generator("Segmentation3D") # Create default summary images if none provided if summary_images is None: - mean_image = pynwb.base.Image( - name="mean", - data=np.ones((image_shape[0], image_shape[1])), # Project along Z - description="Mean intensity projection", - ) - max_image = pynwb.base.Image( - name="max", - data=np.ones((image_shape[0], image_shape[1])), # Project along Z - description="Maximum intensity projection", - ) + mean_image = mock_SummaryImage(name="mean", description="Mean intensity projection", image_shape=image_shape) + max_image = mock_SummaryImage(name="max", description="Maximum intensity projection", image_shape=image_shape) summary_images = [mean_image, max_image] volumetric_segmentation = ndx_microscopy.Segmentation3D(