Skip to content

Commit bec96c7

Browse files
authored
Burying task related behaviour test forms (CoBrALab#88)
* initial set up of form * adding tags * update packages * create form specifically for burying tasks * add item buried question * create function for item buried specific questions * add marble burying questions in measures * add food burying related questions * fix description * update vite dependency
1 parent 4596adb commit bec96c7

File tree

3 files changed

+237
-26
lines changed

3 files changed

+237
-26
lines changed

package.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{
2-
"name": "mouse-form-viewer",
3-
"homepage": "https://CoBrALab.github.io/ODC-Mouse-Forms/",
4-
"private": true,
5-
"version": "0.0.0",
6-
"type": "module",
7-
"scripts": {
8-
"dev": "vite",
9-
"build": "tsc && vite build",
10-
"preview": "vite preview",
11-
"setup-pages": "pnpm build && gh-pages -d dist"
12-
},
13-
"devDependencies": {
14-
"typescript": "~5.7.2",
15-
"vite": ">=6.2.3"
16-
},
17-
"dependencies": {
18-
"gh-pages": "^6.3.0",
19-
"lz-string": "^1.5.0"
20-
},
21-
"packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0"
22-
}
2+
"name": "mouse-form-viewer",
3+
"homepage": "https://CoBrALab.github.io/ODC-Mouse-Forms/",
4+
"private": true,
5+
"version": "0.0.0",
6+
"type": "module",
7+
"scripts": {
8+
"dev": "vite",
9+
"build": "tsc && vite build",
10+
"preview": "vite preview",
11+
"setup-pages": "pnpm build && gh-pages -d dist"
12+
},
13+
"devDependencies": {
14+
"typescript": "~5.7.2",
15+
"vite": ">=6.2.4"
16+
},
17+
"dependencies": {
18+
"gh-pages": "^6.3.0",
19+
"lz-string": "^1.5.0"
20+
},
21+
"packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0"
22+
}

pnpm-lock.yaml

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
/* eslint-disable perfectionist/sort-objects */
2+
3+
const { defineInstrument } = await import('/runtime/v1/@opendatacapture/runtime-core/index.js');
4+
const { z } = await import('/runtime/v1/zod@3.23.x/index.js');
5+
6+
type BuryingItemType = "Food" | "Marbles"
7+
8+
9+
function createDependentField<const T>(field: T, fn: (buryingItemType?: BuryingItemType) => boolean) {
10+
return {
11+
kind: 'dynamic' as const,
12+
deps: ['itemBuried'] as const,
13+
render: (data: { itemBuried?: BuryingItemType }) => {
14+
if (fn(data.itemBuried)) {
15+
return field;
16+
}
17+
return null;
18+
}
19+
};
20+
}
21+
22+
23+
export default defineInstrument({
24+
kind: 'FORM',
25+
language: 'en',
26+
tags: ['Mouse', 'Marble burying', 'Food Burying'],
27+
internal: {
28+
edition: 1,
29+
name: 'MOUSE_BURYING_TASK_FORM'
30+
},
31+
content: {
32+
roomNumber: {
33+
kind: 'string',
34+
variant: "input",
35+
label: "Room number"
36+
},
37+
itemBuried: {
38+
kind: 'string',
39+
variant: "radio",
40+
label: "Item buried",
41+
options: {
42+
"Marbles": "Marbles",
43+
"Food": "Food"
44+
}
45+
},
46+
cageNumber: createDependentField({
47+
kind: 'string',
48+
variant: "input",
49+
label: "Cage number"
50+
}, (type) => type === "Marbles"),
51+
percentageMarblesBuried: createDependentField({
52+
kind: 'string',
53+
variant: "radio",
54+
label: "Percentage range of marbles buried",
55+
options: {
56+
"100 %": "100 %",
57+
"100 - 75%": "100 - 75%",
58+
"75% - 0%":"75% - 0%"
59+
}
60+
},(type) => type === "Marbles"),
61+
foodBuryingTimeCutOff: createDependentField({
62+
kind: "boolean",
63+
variant: "radio",
64+
label: "Did the task have a time cut off"
65+
}, (type) => type === "Food"),
66+
67+
foodBuryingTimeCutOffDuration: {
68+
kind: "dynamic",
69+
deps: ["foodBuryingTimeCutOff"],
70+
render(data) {
71+
if (data.foodBuryingTimeCutOff){
72+
return {
73+
kind: "number",
74+
variant: "input",
75+
label: "Duration of food burying task (seconds)"
76+
}
77+
}
78+
return null
79+
}
80+
},
81+
foodPosition: createDependentField({
82+
kind: "string",
83+
variant: "input",
84+
label: "Food position"
85+
}, (type) => type === "Food"),
86+
87+
ethoVisionUsed: createDependentField({
88+
kind: "boolean",
89+
variant: "radio",
90+
label: "Was Ethovision used for the task?"
91+
}, (type) => type === "Food"),
92+
93+
ethoVisionDistanceTravelled: {
94+
kind: "dynamic",
95+
deps: ["ethoVisionUsed"],
96+
render(data) {
97+
if(data.ethoVisionUsed){
98+
return {
99+
kind: "number",
100+
variant: "input",
101+
label: "Distance travelled (cm)"
102+
}
103+
}
104+
return null
105+
}
106+
},
107+
ethoVisionLatency: {
108+
kind: "dynamic",
109+
deps: ["ethoVisionUsed"],
110+
render(data) {
111+
if(data.ethoVisionUsed){
112+
return {
113+
kind: "number",
114+
variant: "input",
115+
label: "Ethovision latency (ms)"
116+
}
117+
}
118+
return null
119+
}
120+
},
121+
122+
additionalComments: {
123+
kind: "string",
124+
variant: "textarea",
125+
label: "Additional Comments"
126+
}
127+
},
128+
clientDetails: {
129+
estimatedDuration: 2,
130+
instructions: ['To be filled in whenever the animal completes a burying task. Before the form is used the user must know what item the animal has buried as well as the location the task took place in']
131+
},
132+
details: {
133+
description: 'A form to track data from a burying related behavior task given to an animal',
134+
license: 'Apache-2.0',
135+
title: 'Mouse Behavioral Experiment Form'
136+
},
137+
measures: {
138+
roomNumber: {
139+
kind: 'const',
140+
visibility: 'visible',
141+
ref: "roomNumber"
142+
},
143+
itemBuried: {
144+
kind: 'const',
145+
visibility: 'visible',
146+
ref: "itemBuried"
147+
},
148+
cageNumber: {
149+
kind: 'const',
150+
visibility: 'visible',
151+
ref: "cageNumber"
152+
},
153+
percentageMarblesBuried: {
154+
kind: 'const',
155+
visibility: 'visible',
156+
ref: "percentageMarblesBuried"
157+
},
158+
foodBuryingTimeCutOff: {
159+
kind: 'const',
160+
visibility: 'visible',
161+
ref: "foodBuryingTimeCutOff"
162+
},
163+
foodBuryingTimeCutOffDuration: {
164+
kind: 'const',
165+
visibility: 'visible',
166+
ref: "foodBuryingTimeCutOffDuration"
167+
},
168+
foodPosition: {
169+
kind: 'const',
170+
visibility: 'visible',
171+
ref: "foodPosition"
172+
},
173+
ethoVisionUsed: {
174+
kind: 'const',
175+
visibility: 'visible',
176+
ref: "ethoVisionUsed"
177+
},
178+
ethoVisionDistanceTravelled: {
179+
kind: 'const',
180+
visibility: 'visible',
181+
ref: "ethoVisionDistanceTravelled"
182+
},
183+
ethoVisionLatency: {
184+
kind: 'const',
185+
visibility: 'visible',
186+
ref: "ethoVisionLatency"
187+
},
188+
additionalComments: {
189+
kind: 'const',
190+
visibility: 'visible',
191+
ref: 'additionalComments'
192+
}
193+
194+
},
195+
validationSchema: z.object({
196+
roomNumber: z.string(),
197+
itemBuried: z.enum(["Marbles","Food"]),
198+
cageNumber: z.string().optional(),
199+
percentageMarblesBuried: z.enum(["100 %","100 - 75%","75% - 0%"]).optional(),
200+
foodBuryingTimeCutOff: z.boolean(),
201+
foodBuryingTimeCutOffDuration: z.number().min(0).int().optional(),
202+
foodPosition: z.string().optional(),
203+
ethoVisionUsed: z.boolean().optional(),
204+
ethoVisionDistanceTravelled: z.number().min(0).optional(),
205+
ethoVisionLatency: z.number().min(0).optional(),
206+
additionalComments: z.string().optional()
207+
})
208+
});

0 commit comments

Comments
 (0)