Skip to content

Commit

Permalink
Merge pull request #329 from ttngu207/datajoint_pipeline
Browse files Browse the repository at this point in the history
update: more robust check for subjects in a given block
  • Loading branch information
JaerongA authored Feb 7, 2024
2 parents e9c4eab + d2a51e7 commit a6725ad
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
17 changes: 14 additions & 3 deletions aeon/dj_pipeline/analysis/block_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,20 @@ def make(self, key):
)

# Subject data
subject_names = set(
(tracking.SLEAPTracking.PoseIdentity & key & chunk_restriction).fetch("identity_name")
)
# Get all unique subjects that visited the environment over the entire exp;
# For each subject, see 'type' of visit most recent to start of block
# If "Exit", this animal was not in the block.
subject_visits_df = fetch_stream(
acquisition.Environment.SubjectVisits
& key
& f'chunk_start <= "{chunk_keys[-1]["chunk_start"]}"'
)[:block_start]
subject_visits_df = subject_visits_df[subject_visits_df.region == "Environment"]
subject_names = []
for subject_name in set(subject_visits_df.id):
_df = subject_visits_df[subject_visits_df.id == subject_name]
if _df.type[-1] != "Exit":
subject_names.append(subject_name)
for subject_name in subject_names:
# positions - query for CameraTop, identity_name matches subject_name,
pos_query = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
{
"cell_type": "markdown",
"source": [
"## Create VirtualModule to access `aeon_test_analysis` schema\n",
"Currently, the analysis is on `aeon_test_`, will move to `aeon_` soon (once ready for production)"
"## Create VirtualModule to access `aeon_block_analysis` schema"
],
"metadata": {
"collapsed": false,
Expand All @@ -29,7 +28,7 @@
"execution_count": null,
"outputs": [],
"source": [
"analysis_vm = dj.create_virtual_module('aeon_test_analysis', 'aeon_test_analysis')"
"analysis_vm = dj.create_virtual_module('aeon_block_analysis', 'aeon_block_analysis')"
],
"metadata": {
"collapsed": false,
Expand Down
2 changes: 1 addition & 1 deletion aeon/dj_pipeline/webapps/sciviz/specsheet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ SciViz:
dj_query: >
def dj_query(aeon_archived_exp02_acquisition):
acquisition = aeon_archived_exp02_acquisition
return {'query': aeon_acquisition.Experiment(), 'fetch_args': ['experiment_name']}
return {'query': acquisition.Experiment(), 'fetch_args': ['experiment_name']}
camera_dropdown:
x: 0
y: 1
Expand Down
2 changes: 1 addition & 1 deletion aeon/schema/social.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

# SubjectVisits
subject_visits_b = lambda pattern: {
"SubjectVisits": reader.Csv(f"{pattern}_SubjectVisit_*", ["id", "type", "region"])
"SubjectVisits": reader.Csv(f"{pattern}_SubjectVisits_*", ["id", "type", "region"])
}

# SubjectWeight
Expand Down

0 comments on commit a6725ad

Please sign in to comment.