From 2779e752b09e0358c79d7e63f4c302c49ba4f715 Mon Sep 17 00:00:00 2001 From: Mike Huang Date: Mon, 14 Nov 2022 01:05:05 -0800 Subject: [PATCH] rename target_imaging_depth to average_container_depth --- .../behavior/behavior_ophys_experiment.py | 4 ++-- .../metadata/behavior_ophys_metadata.py | 2 +- ...ng_depth.py => average_container_depth.py} | 20 ++++++++--------- .../multi_plane_metadata.py | 12 +++++----- .../ophys_experiment_metadata.py | 22 +++++++++---------- .../brain_observatory/behavior/schemas.py | 2 +- .../ndx-aibs-behavior-ophys.extension.yaml | 2 +- .../metadata/test_behavior_ophys_metadata.py | 10 ++++----- .../test_behavior_ophys_experiment.py | 2 +- 9 files changed, 38 insertions(+), 38 deletions(-) rename allensdk/brain_observatory/behavior/data_objects/metadata/ophys_experiment_metadata/{target_imaging_depth.py => average_container_depth.py} (68%) diff --git a/allensdk/brain_observatory/behavior/behavior_ophys_experiment.py b/allensdk/brain_observatory/behavior/behavior_ophys_experiment.py index 42e0a109fd..ca0acbae8d 100644 --- a/allensdk/brain_observatory/behavior/behavior_ophys_experiment.py +++ b/allensdk/brain_observatory/behavior/behavior_ophys_experiment.py @@ -404,8 +404,8 @@ def metadata(self): 'field_of_view_width': self._metadata.ophys_metadata.field_of_view_shape.width, 'imaging_depth': self._metadata.ophys_metadata.imaging_depth, - 'target_imaging_depth': - self._metadata.ophys_metadata.target_imaging_depth, + 'average_container_depth': + self._metadata.ophys_metadata.average_container_depth, 'imaging_plane_group': self._metadata.ophys_metadata.imaging_plane_group if isinstance(self._metadata.ophys_metadata, diff --git a/allensdk/brain_observatory/behavior/data_objects/metadata/behavior_ophys_metadata.py b/allensdk/brain_observatory/behavior/data_objects/metadata/behavior_ophys_metadata.py index c20aa2bc62..1ebc0d38e8 100644 --- a/allensdk/brain_observatory/behavior/data_objects/metadata/behavior_ophys_metadata.py +++ b/allensdk/brain_observatory/behavior/data_objects/metadata/behavior_ophys_metadata.py @@ -145,7 +145,7 @@ def to_nwb(self, nwbfile: NWBFile) -> NWBFile: session_type=behavior_meta.session_type, equipment_name=behavior_meta.equipment.value, imaging_depth=ophys_meta.imaging_depth, - target_imaging_depth=ophys_meta.target_imaging_depth, + average_container_depth=ophys_meta.average_container_depth, behavior_session_uuid=str(behavior_meta.behavior_session_uuid), behavior_session_id=behavior_meta.behavior_session_id ) diff --git a/allensdk/brain_observatory/behavior/data_objects/metadata/ophys_experiment_metadata/target_imaging_depth.py b/allensdk/brain_observatory/behavior/data_objects/metadata/ophys_experiment_metadata/average_container_depth.py similarity index 68% rename from allensdk/brain_observatory/behavior/data_objects/metadata/ophys_experiment_metadata/target_imaging_depth.py rename to allensdk/brain_observatory/behavior/data_objects/metadata/ophys_experiment_metadata/average_container_depth.py index 9bff679c44..1e57eed996 100644 --- a/allensdk/brain_observatory/behavior/data_objects/metadata/ophys_experiment_metadata/target_imaging_depth.py +++ b/allensdk/brain_observatory/behavior/data_objects/metadata/ophys_experiment_metadata/average_container_depth.py @@ -4,21 +4,21 @@ from allensdk.internal.api import PostgresQueryMixin -class TargetImagingDepth( +class AverageContainerDepth( DataObject, LimsReadableInterface, NwbReadableInterface, JsonReadableInterface, ): - def __init__(self, target_imaging_depth: int): + def __init__(self, average_container_depth: int): super().__init__( - name="target_imaging_depth", value=target_imaging_depth + name="average_container_depth", value=average_container_depth ) @classmethod def from_lims( cls, ophys_experiment_id: int, lims_db: PostgresQueryMixin - ) -> "TargetImagingDepth": + ) -> "AverageContainerDepth": query_container_id = """ SELECT visual_behavior_experiment_container_id FROM ophys_experiments_visual_behavior_experiment_containers @@ -41,14 +41,14 @@ def from_lims( ) imaging_depths = lims_db.fetchall(query_depths) - target_imaging_depth = round(sum(imaging_depths) / len(imaging_depths)) - return cls(target_imaging_depth=target_imaging_depth) + average_container_depth = round(sum(imaging_depths) / len(imaging_depths)) + return cls(average_container_depth=average_container_depth) @classmethod - def from_json(cls, dict_repr: dict) -> "TargetImagingDepth": - return cls(target_imaging_depth=dict_repr["targeted_imaging_depth"]) + def from_json(cls, dict_repr: dict) -> "AverageContainerDepth": + return cls(average_container_depth=dict_repr["targeted_imaging_depth"]) @classmethod - def from_nwb(cls, nwbfile: NWBFile) -> "TargetImagingDepth": + def from_nwb(cls, nwbfile: NWBFile) -> "AverageContainerDepth": metadata = nwbfile.lab_meta_data["metadata"] - return cls(target_imaging_depth=metadata.target_imaging_depth) + return cls(average_container_depth=metadata.average_container_depth) diff --git a/allensdk/brain_observatory/behavior/data_objects/metadata/ophys_experiment_metadata/multi_plane_metadata/multi_plane_metadata.py b/allensdk/brain_observatory/behavior/data_objects/metadata/ophys_experiment_metadata/multi_plane_metadata/multi_plane_metadata.py index 738fd3f86a..b8a88c0f62 100644 --- a/allensdk/brain_observatory/behavior/data_objects/metadata/ophys_experiment_metadata/multi_plane_metadata/multi_plane_metadata.py +++ b/allensdk/brain_observatory/behavior/data_objects/metadata/ophys_experiment_metadata/multi_plane_metadata/multi_plane_metadata.py @@ -7,7 +7,7 @@ from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.ophys_experiment_metadata import OphysExperimentMetadata # NOQA from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.ophys_session_id import OphysSessionId # NOQA from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.project_code import ProjectCode # NOQA -from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.target_imaging_depth import TargetImagingDepth # NOQA +from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.average_container_depth import AverageContainerDepth # NOQA from allensdk.internal.api import PostgresQueryMixin @@ -18,7 +18,7 @@ def __init__(self, ophys_container_id: OphysContainerId, field_of_view_shape: FieldOfViewShape, imaging_depth: ImagingDepth, - target_imaging_depth: TargetImagingDepth, + average_container_depth: AverageContainerDepth, imaging_plane_group: ImagingPlaneGroup, project_code: ProjectCode): super().__init__( @@ -27,7 +27,7 @@ def __init__(self, ophys_container_id=ophys_container_id, field_of_view_shape=field_of_view_shape, imaging_depth=imaging_depth, - target_imaging_depth=target_imaging_depth, + average_container_depth=average_container_depth, project_code=project_code ) self._imaging_plane_group = imaging_plane_group @@ -46,7 +46,7 @@ def from_lims( ophys_container_id=ophys_experiment_metadata._ophys_container_id, field_of_view_shape=ophys_experiment_metadata._field_of_view_shape, imaging_depth=ophys_experiment_metadata._imaging_depth, - target_imaging_depth=ophys_experiment_metadata._target_imaging_depth, # noqa E501 + average_container_depth=ophys_experiment_metadata._average_container_depth, # noqa E501 project_code=ophys_experiment_metadata._project_code, imaging_plane_group=imaging_plane_group ) @@ -61,7 +61,7 @@ def from_json(cls, dict_repr: dict) -> "MultiplaneMetadata": ophys_container_id=ophys_experiment_metadata._ophys_container_id, field_of_view_shape=ophys_experiment_metadata._field_of_view_shape, imaging_depth=ophys_experiment_metadata._imaging_depth, - target_imaging_depth=ophys_experiment_metadata._target_imaging_depth, # noqa E501 + average_container_depth=ophys_experiment_metadata._average_container_depth, # noqa E501 project_code=ophys_experiment_metadata._project_code, imaging_plane_group=imaging_plane_group ) @@ -76,7 +76,7 @@ def from_nwb(cls, nwbfile: NWBFile) -> "MultiplaneMetadata": ophys_container_id=ophys_experiment_metadata._ophys_container_id, field_of_view_shape=ophys_experiment_metadata._field_of_view_shape, imaging_depth=ophys_experiment_metadata._imaging_depth, - target_imaging_depth=ophys_experiment_metadata._target_imaging_depth, # noqa E501 + average_container_depth=ophys_experiment_metadata._average_container_depth, # noqa E501 project_code=ophys_experiment_metadata._project_code, imaging_plane_group=imaging_plane_group ) diff --git a/allensdk/brain_observatory/behavior/data_objects/metadata/ophys_experiment_metadata/ophys_experiment_metadata.py b/allensdk/brain_observatory/behavior/data_objects/metadata/ophys_experiment_metadata/ophys_experiment_metadata.py index 928b6b264c..fed2677c1b 100644 --- a/allensdk/brain_observatory/behavior/data_objects/metadata/ophys_experiment_metadata/ophys_experiment_metadata.py +++ b/allensdk/brain_observatory/behavior/data_objects/metadata/ophys_experiment_metadata/ophys_experiment_metadata.py @@ -7,7 +7,7 @@ from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.ophys_container_id import OphysContainerId # NOQA from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.ophys_session_id import OphysSessionId # NOQA from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.project_code import ProjectCode # NOQA -from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.target_imaging_depth import TargetImagingDepth # NOQA +from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.average_container_depth import AverageContainerDepth # NOQA from allensdk.core import DataObject, JsonReadableInterface, LimsReadableInterface, NwbReadableInterface # NOQA from allensdk.internal.api import PostgresQueryMixin @@ -21,7 +21,7 @@ def __init__(self, ophys_container_id: OphysContainerId, field_of_view_shape: FieldOfViewShape, imaging_depth: ImagingDepth, - target_imaging_depth: TargetImagingDepth, + average_container_depth: AverageContainerDepth, project_code: Optional[ProjectCode] = None): super().__init__(name='ophys_experiment_metadata', value=None, is_value_self=True) @@ -30,7 +30,7 @@ def __init__(self, self._ophys_container_id = ophys_container_id self._field_of_view_shape = field_of_view_shape self._imaging_depth = imaging_depth - self._target_imaging_depth = target_imaging_depth + self._average_container_depth = average_container_depth self._project_code = project_code # project_code needs to be excluded from comparison @@ -49,7 +49,7 @@ def from_lims( ophys_experiment_id=ophys_experiment_id, lims_db=lims_db) imaging_depth = ImagingDepth.from_lims( ophys_experiment_id=ophys_experiment_id, lims_db=lims_db) - target_imaging_depth = TargetImagingDepth.from_lims( + average_container_depth = AverageContainerDepth.from_lims( ophys_experiment_id=ophys_experiment_id, lims_db=lims_db) project_code = ProjectCode.from_lims( ophys_experiment_id=ophys_experiment_id, lims_db=lims_db) @@ -60,7 +60,7 @@ def from_lims( ophys_container_id=ophys_container_id, field_of_view_shape=field_of_view_shape, imaging_depth=imaging_depth, - target_imaging_depth=target_imaging_depth, + average_container_depth=average_container_depth, project_code=project_code ) @@ -72,7 +72,7 @@ def from_json(cls, dict_repr: dict) -> "OphysExperimentMetadata": ophys_experiment_id = dict_repr['ophys_experiment_id'] field_of_view_shape = FieldOfViewShape.from_json(dict_repr=dict_repr) imaging_depth = ImagingDepth.from_json(dict_repr=dict_repr) - target_imaging_depth = TargetImagingDepth.from_json( + average_container_depth = AverageContainerDepth.from_json( dict_repr=dict_repr ) @@ -82,7 +82,7 @@ def from_json(cls, dict_repr: dict) -> "OphysExperimentMetadata": ophys_container_id=ophys_container_id, field_of_view_shape=field_of_view_shape, imaging_depth=imaging_depth, - target_imaging_depth=target_imaging_depth + average_container_depth=average_container_depth ) @classmethod @@ -93,7 +93,7 @@ def from_nwb(cls, nwbfile: NWBFile) -> "OphysExperimentMetadata": nwbfile=nwbfile) field_of_view_shape = FieldOfViewShape.from_nwb(nwbfile=nwbfile) imaging_depth = ImagingDepth.from_nwb(nwbfile=nwbfile) - target_imaging_depth = TargetImagingDepth.from_nwb(nwbfile=nwbfile) + average_container_depth = AverageContainerDepth.from_nwb(nwbfile=nwbfile) return OphysExperimentMetadata( ophys_experiment_id=ophys_experiment_id, @@ -101,7 +101,7 @@ def from_nwb(cls, nwbfile: NWBFile) -> "OphysExperimentMetadata": ophys_container_id=ophys_container_id, field_of_view_shape=field_of_view_shape, imaging_depth=imaging_depth, - target_imaging_depth=target_imaging_depth + average_container_depth=average_container_depth ) @property @@ -117,8 +117,8 @@ def imaging_depth(self) -> int: return self._imaging_depth.value @property - def target_imaging_depth(self) -> int: - return self._target_imaging_depth.value + def average_container_depth(self) -> int: + return self._average_container_depth.value @property def ophys_experiment_id(self) -> int: diff --git a/allensdk/brain_observatory/behavior/schemas.py b/allensdk/brain_observatory/behavior/schemas.py index 8334e8c211..10aaf8d6dd 100644 --- a/allensdk/brain_observatory/behavior/schemas.py +++ b/allensdk/brain_observatory/behavior/schemas.py @@ -148,7 +148,7 @@ class OphysMetadataSchema(NwbOphysMetadataSchema): 'targeted for two-photon acquisition'), required=True, ) - target_imaging_depth = fields.Int( + average_container_depth = fields.Int( doc=( "Average Depth (microns) below the cortical surface " "across experiments of a container." diff --git a/allensdk/brain_observatory/nwb/ndx-aibs-behavior-ophys.extension.yaml b/allensdk/brain_observatory/nwb/ndx-aibs-behavior-ophys.extension.yaml index 0a35e256cf..a9cec3c786 100644 --- a/allensdk/brain_observatory/nwb/ndx-aibs-behavior-ophys.extension.yaml +++ b/allensdk/brain_observatory/nwb/ndx-aibs-behavior-ophys.extension.yaml @@ -119,7 +119,7 @@ groups: - name: imaging_depth dtype: int doc: Depth (microns) below the cortical surface targeted for two-photon acquisition - - name: target_imaging_depth + - name: average_container_depth dtype: int doc: Average imaging_depth (microns) across experiments in a container - neurodata_type_def: OphysEyeTrackingRigMetadata diff --git a/allensdk/test/brain_observatory/behavior/data_objects/metadata/test_behavior_ophys_metadata.py b/allensdk/test/brain_observatory/behavior/data_objects/metadata/test_behavior_ophys_metadata.py index 8350cd05c2..3d971c5f81 100644 --- a/allensdk/test/brain_observatory/behavior/data_objects/metadata/test_behavior_ophys_metadata.py +++ b/allensdk/test/brain_observatory/behavior/data_objects/metadata/test_behavior_ophys_metadata.py @@ -15,7 +15,7 @@ from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.ophys_container_id import OphysContainerId # NOQA from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.ophys_experiment_metadata import OphysExperimentMetadata # NOQA from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.ophys_session_id import OphysSessionId # NOQA -from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.target_imaging_depth import TargetImagingDepth # NOQA +from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.average_container_depth import AverageContainerDepth # NOQA from allensdk.core.auth_config import LIMS_DB_CREDENTIAL_MAP from allensdk.internal.api import db_connection_creator from allensdk.test.brain_observatory.behavior.data_objects.metadata.behavior_metadata.test_behavior_metadata import TestBehaviorMetadata # NOQA @@ -38,7 +38,7 @@ def _get_meta(): ophys_container_id=5678), field_of_view_shape=FieldOfViewShape(width=4, height=4), imaging_depth=ImagingDepth(imaging_depth=375), - target_imaging_depth=TargetImagingDepth(target_imaging_depth=375) + average_container_depth=AverageContainerDepth(average_container_depth=375) ) behavior_metadata = TestBehaviorMetadata() @@ -62,7 +62,7 @@ def _get_multiplane_meta(self): ophys_container_id=ophys_experiment_metadata._ophys_container_id, field_of_view_shape=ophys_experiment_metadata._field_of_view_shape, imaging_depth=ophys_experiment_metadata._imaging_depth, - target_imaging_depth=ophys_experiment_metadata._target_imaging_depth, # noqa E501 + average_container_depth=ophys_experiment_metadata._average_container_depth, # noqa E501 project_code=ophys_experiment_metadata._project_code, imaging_plane_group=imaging_plane_group ) @@ -99,7 +99,7 @@ def test_from_lims(self, meso): assert isinstance(bom.ophys_metadata, MultiplaneMetadata) assert bom.ophys_metadata.imaging_depth == 150 - assert bom.ophys_metadata.target_imaging_depth == 150 + assert bom.ophys_metadata.average_container_depth == 150 assert bom.behavior_metadata.session_type == 'OPHYS_1_images_A' assert bom.behavior_metadata.subject_metadata.reporter_line == \ 'Ai148(TIT2L-GC6f-ICL-tTA2)' @@ -113,7 +113,7 @@ def test_from_lims(self, meso): else: assert isinstance(bom.ophys_metadata, OphysExperimentMetadata) assert bom.ophys_metadata.imaging_depth == 175 - assert bom.ophys_metadata.target_imaging_depth == 175 + assert bom.ophys_metadata.average_container_depth == 175 assert bom.behavior_metadata.session_type == 'OPHYS_4_images_A' assert bom.behavior_metadata.subject_metadata.reporter_line == \ 'Ai93(TITL-GCaMP6f)' diff --git a/allensdk/test/brain_observatory/behavior/test_behavior_ophys_experiment.py b/allensdk/test/brain_observatory/behavior/test_behavior_ophys_experiment.py index c764e25427..da182af94c 100644 --- a/allensdk/test/brain_observatory/behavior/test_behavior_ophys_experiment.py +++ b/allensdk/test/brain_observatory/behavior/test_behavior_ophys_experiment.py @@ -103,7 +103,7 @@ def test_visbeh_ophys_data_set(): datetime.datetime(2018, 11, 30, 23, 28, 37)), 'ophys_frame_rate': 31.0, 'imaging_depth': 375, - 'target_imaging_depth': 375, + 'average_container_depth': 375, 'mouse_id': 416369, 'ophys_container_id': 814796558, 'targeted_structure': 'VISp',