Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
k1o0 authored Nov 15, 2024
2 parents 4b619ee + 11f617b commit 535b032
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
9 changes: 9 additions & 0 deletions alyx/actions/fixtures/actions.proceduretype.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,5 +286,14 @@
"json": null,
"description": "This term covers:\r\n- Induction and maintenance of general/local/regional anaesthesia by use of agents and by routes suitable for the species, nature and duration of the procedure - Inhalation.\r\n- Subcutaneous injection under anesthesia\r\n- Intramuscular injection under anesthesia\r\n- Administration of substances topically to the skin or conjunctiva with anaesthesia.\r\n- Placement of head in atraumatic headholder (via atraumatic ear and eye bars) OR Head bolt clamp to a fixation bar (head bolt already in place and fully healed)\r\n- Craniotomy\r\n- Implantation of cannula"
}
},
{
"model": "actions.proceduretype",
"pk": "a00737fa-7ec1-48c1-ad7c-08529712adcb",
"fields": {
"name": "Fiber photometry",
"json": null,
"description": ""
}
}
]
17 changes: 14 additions & 3 deletions alyx/data/fixtures/data.datasettype.json
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,7 @@
"json": null,
"name": "photometry.ROIs",
"created_by": null,
"description": "ROI integer for associateing with trajectory.",
"description": "ROI integer for associating with trajectory.",
"filename_pattern": "*photometry.ROIs*"
}
},
Expand All @@ -1678,7 +1678,7 @@
"json": null,
"name": "fpData.raw",
"created_by": null,
"description": "Raw FP data dataframe containing fluorescence data for every active channel (max: isosbestic, red and green) as well as information of coactive components with each frame (E.g TTL syncing pulse).",
"description": "Raw fiber photometry dataframe containing fluorescence data for every active channel (max: isosbestic, red and green) as well as information of coactive components with each frame (E.g TTL syncing pulse).",
"filename_pattern": "_*_fpData.raw*"
}
},
Expand All @@ -1689,7 +1689,7 @@
"json": null,
"name": "fpData.channels",
"created_by": null,
"description": "Frame flag value for each LED channel [OFF, L415, L470, L560]. Each row corresponds to a different labelled condition. See user manual at https://neurophotometrics.com/documentation",
"description": "Frame flag value for each LED fiber photometry channel [OFF, L415, L470, L560]. Each row corresponds to a different labelled condition. See user manual at https://neurophotometrics.com/documentation",
"filename_pattern": "*fpData.channels.*"
}
},
Expand Down Expand Up @@ -2319,5 +2319,16 @@
"description": "The raw frame exposure times.",
"filename_pattern": ""
}
},
{
"model": "data.datasettype",
"pk": "4c86d4e1-9365-41d2-97cf-cf88c8817bc3",
"fields": {
"json": null,
"name": "fpData.digitalInputs",
"created_by": null,
"description": "",
"filename_pattern": "*digitalInputs.raw*"
}
}
]
39 changes: 37 additions & 2 deletions alyx/misc/management/commands/homeoffice.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,29 @@ def genotyped(start_date, end_date):
return Q(genotype_date__gte=start_date, genotype_date__lte=end_date)


# Filters

# Do not have surgery
def not_used(query):
return query.filter(Q(actions_surgerys__isnull=True)).distinct()


# Have surgery
def used(query):
return query.filter(actions_surgerys__isnull=False).distinct()


# Protocol 2 or 3
def used_2_3(query):
return Q(protocol_number__in=['2', '3'])


# Have water restriction
def restricted(query):
return query.filter(actions_waterrestrictions__isnull=False).distinct()


# Transgenic
def transgenic(query):
return query.exclude(line__nickname='C57')

Expand All @@ -65,14 +80,23 @@ def display(title, query, start_date=None, end_date=None):
if start_date:
title = title % (start_date, end_date)
path = 'homeoffice/%s.txt' % title

# Compute sex ratio.
males = sum(subj.sex == 'M' for subj in query)
total = sum(subj.sex in ('M', 'F') for subj in query)
sexratio = males / total

with open(path, 'w') as f:
with redirect_stdout(f):
print("%s: %d subjects." % (title, len(query)))
print("%s: %d subjects (%.1f%% males)." % (title, len(query), sexratio * 100))
print('\t'.join(('# ', 'user ', 'prot.',
'born ',
'genotyped',
'died ',
'EM', 'nickname')))
'EM',
'nickname',
'sex',
)))
for i, subj in enumerate(query):
print('\t'.join(('%04d' % (i + 1),
'{0: <12}'.format(subj.responsible_user.username),
Expand All @@ -82,6 +106,7 @@ def display(title, query, start_date=None, end_date=None):
str(subj.death_date or ' ' * 10),
subj.ear_mark,
subj.nickname,
subj.sex,
)))
print('\n\n')
os.system('expand -t 4 "%s" | sponge "%s"' % (path, path))
Expand Down Expand Up @@ -125,3 +150,13 @@ def handle(self, *args, **options):

tkng = transgenic(k).exclude(genotyped('2000-01-01', '2100-01-01'))
display("Transgenic killed and not genotyped %s - %s", tkng, start_date, end_date)

# Sex bias (cf email from Charu to Cyrille on 2024-07-23)
# Birth date.
sexbias = s.filter(born(start_date, '2100-01-01'))
sexbias = sexbias.filter(
Q(protocol_number__in=['2', '3']) | # 1. protocol 2 or 3
Q(actions_surgerys__isnull=False) | # 2. have a surgery
Q(actions_waterrestrictions__isnull=False) # 3. have a water restriction
)
display("Sex bias %s - %s", sexbias, start_date, end_date)

0 comments on commit 535b032

Please sign in to comment.