Source code for allensdk.brain_observatory.behavior.data_objects.metadata.ophys_experiment_metadata.field_of_view_shape
from pynwb import NWBFile
from allensdk.core import DataObject
from allensdk.core import \
JsonReadableInterface, LimsReadableInterface, NwbReadableInterface
from allensdk.internal.api import PostgresQueryMixin
[docs]class FieldOfViewShape(DataObject, LimsReadableInterface,
NwbReadableInterface, JsonReadableInterface):
def __init__(self, height: int, width: int):
super().__init__(name='field_of_view_shape', value=None,
is_value_self=True)
self._height = height
self._width = width
@property
def height(self):
return self._height
@property
def width(self):
return self._width
[docs] @classmethod
def from_lims(cls, ophys_experiment_id: int,
lims_db: PostgresQueryMixin) -> "FieldOfViewShape":
query = f"""
SELECT oe.movie_width as width, oe.movie_height as height
FROM ophys_experiments oe
WHERE oe.id = {ophys_experiment_id};
"""
df = lims_db.select(query=query)
height = df.iloc[0]['height']
width = df.iloc[0]['width']
return cls(height=height, width=width)
[docs] @classmethod
def from_nwb(cls, nwbfile: NWBFile) -> "FieldOfViewShape":
metadata = nwbfile.lab_meta_data['metadata']
return cls(height=metadata.field_of_view_height,
width=metadata.field_of_view_width)
[docs] @classmethod
def from_json(cls, dict_repr: dict) -> "FieldOfViewShape":
return cls(height=dict_repr['movie_height'],
width=dict_repr['movie_width'])