Skip to content

Commit

Permalink
rename target_imaging_depth to average_container_depth
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejhuang committed Nov 14, 2022
1 parent 3ff5c5a commit 2779e75
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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__(
Expand All @@ -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
Expand All @@ -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
)
Expand All @@ -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
)
Expand All @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
)

Expand All @@ -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
)

Expand All @@ -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
Expand All @@ -93,15 +93,15 @@ 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,
ophys_session_id=ophys_session_id,
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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion allensdk/brain_observatory/behavior/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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
)
Expand Down Expand Up @@ -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)'
Expand All @@ -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)'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 2779e75

Please sign in to comment.