Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions concert/devices/cameras/pco.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
class Camera(UcaCamera):
async def __ainit__(self, name="pco", params=None):
self._timestamp_enabled = False
await super().__ainit__(name=name, params=params)
await UcaCamera.__ainit__(self, name=name, params=params)

async def _record_real(self):
self._timestamp_enabled = await self.get_timestamp() in ['both', 'binary']
await super()._record_real()
self._timestamp_enabled = (await self.get_timestamp_mode()).value_name in ['UCA_PCO_CAMERA_TIMESTAMP_BINARY', 'UCA_PCO_CAMERA_TIMESTAMP_BOTH']
await UcaCamera._record_real(self)

@background
async def start_readout(self):
self._timestamp_enabled = await self.get_timestamp() in ['both', 'binary']
await super().start_readout()
self._timestamp_enabled = (await self.get_timestamp_mode()).value_name in ['UCA_PCO_CAMERA_TIMESTAMP_BINARY', 'UCA_PCO_CAMERA_TIMESTAMP_BOTH']
await UcaCamera.start_readout(self)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why move away from super()?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still, why did you change this?


@background
async def grab(self) -> ImageWithMetadata:
Expand Down
6 changes: 4 additions & 2 deletions concert/experiments/addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ async def _check_timestamp(self, producer):
self.timestamp_missing = False
i = 0
last_acquisition = await self._experiment.acquisitions[-1].get_state() == "running"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this isn't new but it's really a hack, we should improve this in the future.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean what if we raise an exception even if this is the first acquisition? If you want the timestamp and it's not there than it makes sense, doesn't it?

first_frame = 1
async for img in producer:
if i == 0:
if not isinstance(img, ImageWithMetadata) or (
Expand All @@ -398,9 +399,10 @@ async def _check_timestamp(self, producer):
"Works only with pco cameras.")
self.timestamp_missing = True
return
if img.metadata['frame_number'] != i + 1:
first_frame = img.metadata['frame_number']
if img.metadata['frame_number'] != i + first_frame:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it safe to rely on the first frame index being 1? All PCO's behave the same way for sure?

self._experiment.log.error(
f"Frame {i + 1} had wrong frame number {img.metadata['frame_number']}.")
f"Frame {i} had wrong frame number {img.metadata['frame_number']} (first_frame: {first_frame}).")
self.timestamp_incorrect = True
i += 1
if last_acquisition and self.timestamp_incorrect:
Expand Down