-
Notifications
You must be signed in to change notification settings - Fork 6
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
Table to compute/store InROI times AND subject-experiment mapping from Pyrat #451
Merged
jkbhagatio
merged 7 commits into
SainsburyWellcomeCentre:datajoint_pipeline
from
ttngu207:dev_queriable_in_roi_time
Nov 21, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
865c644
feat(analysis): store subject position ethogram to `BlockSubjectPosit…
ttngu207 41da2bb
feat(subject): subject experiment mapping from pyrat
ttngu207 b5be2ed
feat(sciviz): add additional block level meta information
ttngu207 507a0bc
Create fix_anchor_part_fullpose.py
ttngu207 28e344c
Merge remote-tracking branch 'upstream/datajoint_pipeline' into dev_q…
ttngu207 e73c099
fix(subject): bugfix merge conflicts
ttngu207 fa53e23
feat(block_analysis): improve BlockDetection logic to better track ne…
ttngu207 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
""" | ||
Script to fix the anchor part of the fullpose SLEAP entries. | ||
See this commit: https://github.com/SainsburyWellcomeCentre/aeon_mecha/commit/8358ce4b6923918920efb77d09adc769721dbb9b | ||
|
||
Last run: --- | ||
""" | ||
import pandas as pd | ||
from tqdm import tqdm | ||
from aeon.dj_pipeline import acquisition, tracking, streams | ||
|
||
aeon_schemas = acquisition.aeon_schemas | ||
logger = acquisition.logger | ||
io_api = acquisition.io_api | ||
|
||
|
||
def update_anchor_part(key): | ||
chunk_start, chunk_end = (acquisition.Chunk & key).fetch1("chunk_start", "chunk_end") | ||
|
||
data_dirs = acquisition.Experiment.get_data_directories(key) | ||
|
||
device_name = (streams.SpinnakerVideoSource & key).fetch1("spinnaker_video_source_name") | ||
|
||
devices_schema = getattr( | ||
aeon_schemas, | ||
(acquisition.Experiment.DevicesSchema & {"experiment_name": key["experiment_name"]}).fetch1( | ||
"devices_schema_name" | ||
), | ||
) | ||
|
||
stream_reader = getattr(getattr(devices_schema, device_name), "Pose") | ||
|
||
# special ingestion case for social0.2 full-pose data (using Pose reader from social03) | ||
# fullpose for social0.2 has a different "pattern" for non-fullpose, hence the Pose03 reader | ||
if key["experiment_name"].startswith("social0.2"): | ||
from aeon.io import reader as io_reader | ||
stream_reader = getattr(getattr(devices_schema, device_name), "Pose03") | ||
assert isinstance(stream_reader, io_reader.Pose), "Pose03 is not a Pose reader" | ||
data_dirs = [acquisition.Experiment.get_data_directory(key, "processed")] | ||
|
||
pose_data = io_api.load( | ||
root=data_dirs, | ||
reader=stream_reader, | ||
start=pd.Timestamp(chunk_start), | ||
end=pd.Timestamp(chunk_end), | ||
) | ||
|
||
if not len(pose_data): | ||
raise ValueError(f"No SLEAP data found for {key['experiment_name']} - {device_name}") | ||
|
||
# get anchor part | ||
anchor_part = next(v.replace("_x", "") for v in stream_reader.columns if v.endswith("_x")) | ||
|
||
# update anchor part | ||
for entry in tracking.SLEAPTracking.PoseIdentity.fetch("KEY"): | ||
entry["anchor_part"] = anchor_part | ||
tracking.SLEAPTracking.PoseIdentity.update1(entry) | ||
|
||
logger.info(f"Anchor part updated to {anchor_part} for {key}") | ||
|
||
|
||
def main(): | ||
keys = tracking.SLEAPTracking.fetch("KEY") | ||
for key in tqdm(keys): | ||
update_anchor_part(key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ttngu207 sorry I'm missing something obvious, but why is
fix_anchor_part_fullpose
necessary? I thought anchor part for full pose would be fixed the same way was done for identity?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the SLEAP data were ingested before this commit
Thus, those ingested data may have the
anchor_part
incorrectly extracted/stored in the database.There are only a very small number, but I don't know which ones, so this script is to correct for that.
I haven't run it yet, just have it here for the record. We may not need to run this at all if we are to delete and ingest new SLEAP data from the composite camera anyway.