-
Notifications
You must be signed in to change notification settings - Fork 153
Ticket/2545/dev #2604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ticket/2545/dev #2604
Changes from all commits
2bab3b5
cfbd2db
3ff5c5a
b6d9d21
6800f2a
1df9a32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from pynwb import NWBFile | ||
|
||
from allensdk.core import DataObject, JsonReadableInterface, LimsReadableInterface, NwbReadableInterface # NOQA | ||
from allensdk.internal.api import PostgresQueryMixin | ||
|
||
|
||
class AverageContainerDepth( | ||
DataObject, | ||
LimsReadableInterface, | ||
NwbReadableInterface, | ||
JsonReadableInterface, | ||
): | ||
"""Data object loads and stores the average `imaging_depth`s | ||
(microns) across experiments in the container that an experiment is | ||
associated with. | ||
""" | ||
def __init__(self, average_container_depth: int): | ||
super().__init__( | ||
name="average_container_depth", value=average_container_depth | ||
) | ||
|
||
@classmethod | ||
def from_lims( | ||
cls, ophys_experiment_id: int, lims_db: PostgresQueryMixin | ||
) -> "AverageContainerDepth": | ||
query_container_id = """ | ||
SELECT visual_behavior_experiment_container_id | ||
FROM ophys_experiments_visual_behavior_experiment_containers | ||
WHERE ophys_experiment_id = {} | ||
""".format( | ||
ophys_experiment_id | ||
) | ||
|
||
container_id = lims_db.fetchone(query_container_id, strict=True) | ||
|
||
query_depths = """ | ||
SELECT AVG(imd.depth) | ||
FROM ophys_experiments_visual_behavior_experiment_containers ec | ||
JOIN ophys_experiments oe ON oe.id = ec.ophys_experiment_id | ||
LEFT JOIN imaging_depths imd ON imd.id = oe.imaging_depth_id | ||
WHERE ec.visual_behavior_experiment_container_id = {}; | ||
""".format( | ||
container_id | ||
) | ||
|
||
average_container_depth = int(lims_db.fetchone(query_depths)) | ||
return cls(average_container_depth=average_container_depth) | ||
|
||
@classmethod | ||
def from_json(cls, dict_repr: dict) -> "AverageContainerDepth": | ||
# TODO remove all of the from_json loading and validation step | ||
# ticket 2607 | ||
return cls(average_container_depth=dict_repr["targeted_depth"]) | ||
|
||
@classmethod | ||
def from_nwb(cls, nwbfile: NWBFile) -> "AverageContainerDepth": | ||
metadata = nwbfile.lab_meta_data["metadata"] | ||
return cls(average_container_depth=metadata.average_container_depth) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,13 @@ | ||
from pynwb import NWBFile | ||
|
||
from allensdk.brain_observatory.behavior.data_objects.metadata \ | ||
.ophys_experiment_metadata.ophys_container_id import \ | ||
OphysContainerId | ||
from allensdk.brain_observatory.behavior.data_objects.metadata \ | ||
.ophys_experiment_metadata.field_of_view_shape import \ | ||
FieldOfViewShape | ||
from allensdk.brain_observatory.behavior.data_objects.metadata \ | ||
.ophys_experiment_metadata.imaging_depth import \ | ||
ImagingDepth | ||
from allensdk.brain_observatory.behavior.data_objects.metadata \ | ||
.ophys_experiment_metadata.multi_plane_metadata \ | ||
.imaging_plane_group import \ | ||
ImagingPlaneGroup | ||
from allensdk.brain_observatory.behavior.data_objects.metadata \ | ||
.ophys_experiment_metadata.ophys_experiment_metadata import \ | ||
OphysExperimentMetadata | ||
from allensdk.brain_observatory.behavior.data_objects.metadata \ | ||
.ophys_experiment_metadata.ophys_session_id import \ | ||
OphysSessionId | ||
from allensdk.brain_observatory.behavior.data_objects.metadata \ | ||
.ophys_experiment_metadata.project_code import \ | ||
ProjectCode | ||
from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.field_of_view_shape import FieldOfViewShape # NOQA | ||
from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.imaging_depth import ImagingDepth # NOQA | ||
from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.multi_plane_metadata.imaging_plane_group import ImagingPlaneGroup # NOQA | ||
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.project_code import ProjectCode # NOQA | ||
from allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.average_container_depth import AverageContainerDepth # NOQA | ||
from allensdk.internal.api import PostgresQueryMixin | ||
|
||
|
||
|
@@ -32,6 +18,7 @@ def __init__(self, | |
ophys_container_id: OphysContainerId, | ||
field_of_view_shape: FieldOfViewShape, | ||
imaging_depth: ImagingDepth, | ||
average_container_depth: AverageContainerDepth, | ||
imaging_plane_group: ImagingPlaneGroup, | ||
project_code: ProjectCode): | ||
super().__init__( | ||
|
@@ -40,6 +27,7 @@ def __init__(self, | |
ophys_container_id=ophys_container_id, | ||
field_of_view_shape=field_of_view_shape, | ||
imaging_depth=imaging_depth, | ||
average_container_depth=average_container_depth, | ||
project_code=project_code | ||
) | ||
self._imaging_plane_group = imaging_plane_group | ||
|
@@ -55,9 +43,10 @@ def from_lims( | |
return cls( | ||
ophys_experiment_id=ophys_experiment_metadata.ophys_experiment_id, | ||
ophys_session_id=ophys_experiment_metadata._ophys_session_id, | ||
ophys_container_id=ophys_experiment_metadata._ophys_container_id, # noqa E501 | ||
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, | ||
average_container_depth=ophys_experiment_metadata._average_container_depth, # noqa E501 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does black really not split this line and the others like it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's been a ticket open for this on the black repository since 2018 and it hasn't been resolved yet. A black collaborator acknowledged the issue needs to be fixed in 2020 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. huh, if you fix it by hand, does black just revert it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it gets reverted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay, guess we'll live with it. |
||
project_code=ophys_experiment_metadata._project_code, | ||
imaging_plane_group=imaging_plane_group | ||
) | ||
|
@@ -69,9 +58,10 @@ def from_json(cls, dict_repr: dict) -> "MultiplaneMetadata": | |
return cls( | ||
ophys_experiment_id=ophys_experiment_metadata.ophys_experiment_id, | ||
ophys_session_id=ophys_experiment_metadata._ophys_session_id, | ||
ophys_container_id=ophys_experiment_metadata._ophys_container_id, # noqa E501 | ||
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, | ||
average_container_depth=ophys_experiment_metadata._average_container_depth, # noqa E501 | ||
project_code=ophys_experiment_metadata._project_code, | ||
imaging_plane_group=imaging_plane_group | ||
) | ||
|
@@ -83,9 +73,10 @@ def from_nwb(cls, nwbfile: NWBFile) -> "MultiplaneMetadata": | |
return cls( | ||
ophys_experiment_id=ophys_experiment_metadata.ophys_experiment_id, | ||
ophys_session_id=ophys_experiment_metadata._ophys_session_id, | ||
ophys_container_id=ophys_experiment_metadata._ophys_container_id, # noqa E501 | ||
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, | ||
average_container_depth=ophys_experiment_metadata._average_container_depth, # noqa E501 | ||
project_code=ophys_experiment_metadata._project_code, | ||
imaging_plane_group=imaging_plane_group | ||
) | ||
|
Uh oh!
There was an error while loading. Please reload this page.