Wiki source code of 3 Try it yourself!

Version 6.1 by oschmid on 2022/07/05 15:00

Show last authors
1 == User examples ==
2
3
4 1. How many datasets used human subjects?
5 1. Find datasets with male adult subjects
6 1. Find datasets that contain NIfTI files
7 1. Find the software that can be used to open .smr file formats?
8
9 [[https:~~/~~/lab.ch.ebrains.eu/hub/user-redirect/lab/tree/shared/Practical%20Guide%20to%20Using%20the%20EBRAINS%20Knowledge%20Graph%20in%20(your)%20Research%20-%20User%20Examples/query.ipynb>>https://lab.ch.ebrains.eu/hub/user-redirect/lab/tree/shared/Practical%20Guide%20to%20Using%20the%20EBRAINS%20Knowledge%20Graph%20in%20(your)%20Research%20-%20User%20Examples/query.ipynb]]
10
11 === Example 1 - How many datasets used human subjects? ===
12
13 ==== **Search UI** ====
14
15 In the filter function, select "Homo Sapiens" under species. This filters the available datasets in the Knowledge Graph for human subjects only.
16
17 [[https:~~/~~/search.kg.ebrains.eu/?facet_type[0]=Dataset&facet_Dataset_speciesFilter[0]=Homo%20sapiens>>https://search.kg.ebrains.eu/?facet_type[0]=Dataset&facet_Dataset_speciesFilter[0]=Homo%20sapiens]]
18
19 ==== **Query Builder** ====
20
21 To search for datasets containing human subjects only, you can first declare the id (to get the involved instances) as well as a link to the "studied specimen" (you can add a type filter and restrict it to "Subject" and "Subject group" only since we are not interested in "Tissue samples" and "Tissue sample collections" in this moment). From "studied specimen", we're interested in the "Species" (here you can - again add a type filter to exclude "Strain" since this is irrelevant for human subjects). For the "Species", we want the "label" to contain "homo sapiens" which is why we add a filter "contains" with the value "homo sapiens".  We might want to simplify the deeply nested structure by "flattening" both, the "Studied specimen" as well as the "Species". Once we go to the "execute query" section (the play button on the left) and we run the query, we can see the total number of dataset versions.
22 \\Please note that this number can differ from the one you figured out in the search UI. The reason for this is, that the search UI does only count the newest dataset version whilst the query also returns older dataset versions.
23
24 {{code language="json" layout="LINENUMBERS"}}
25 {
26 "@context": {
27 "@vocab": "https://core.kg.ebrains.eu/vocab/query/",
28 "query": "https://schema.hbp.eu/myQuery/",
29 "propertyName": {
30 "@id": "propertyName",
31 "@type": "@id"
32 },
33 "path": {
34 "@id": "path",
35 "@type": "@id"
36 }
37 },
38 "meta": {
39 "type": "https://openminds.ebrains.eu/core/DatasetVersion",
40 "responseVocab": "https://schema.hbp.eu/myQuery/"
41 },
42 "structure": [
43 {
44 "propertyName": "query:id",
45 "path": "@id"
46 },
47 {
48 "propertyName": "query:studiedSpecimen",
49 "required": true,
50 "filter": {
51 "op": "CONTAINS",
52 "value": "Homo sapiens"
53 },
54 "path": [
55 {
56 "@id": "https://openminds.ebrains.eu/vocab/studiedSpecimen",
57 "typeFilter": [
58 {
59 "@id": "https://openminds.ebrains.eu/core/Subject"
60 },
61 {
62 "@id": "https://openminds.ebrains.eu/core/SubjectGroup"
63 }
64 ]
65 },
66 {
67 "@id": "https://openminds.ebrains.eu/vocab/species",
68 "typeFilter": [
69 {
70 "@id": "https://openminds.ebrains.eu/controlledTerms/Species"
71 }
72 ]
73 },
74 "https://openminds.ebrains.eu/vocab/name"
75 ]
76 }
77 ]
78 }
79 {{/code}}
80
81 === Example 2 - Find datasets with male adult subjects ===
82
83 ==== **Search UI** ====
84
85 All the metadata in the knowledge graph is represented by nodes and their relationships by the edges. Most of the "basic" metadata is visualised in the Search UI to make it easy for the user to find datasets that fit certain criteria without needing to know how to navigate and traverse a graph structure.
86
87 ==== **Query Builder** ====
88
89 For dataset versions that use male adult subjects, we can filter datasets using these 2 properties. The easiest way is to add a required filter to biological sex that is "EQUAL" to "male" and the age category "EQUAL" to "adult". By selecting the filter "EQUAL" instead of "CONTAINS", we ensure that only datasets with adult animals are found. If we want to be more general and include all subjects from the onset of sexual maturity, we can use "CONTAINS" instead as this will include subjects with the age category "prime adult", "young adult" and "late adult" as well.
90
91 {{code language="json" layout="LINENUMBERS"}}
92 {
93 "@context": {
94 "@vocab": "https://core.kg.ebrains.eu/vocab/query/",
95 "query": "https://schema.hbp.eu/myQuery/",
96 "propertyName": {
97 "@id": "propertyName",
98 "@type": "@id"
99 },
100 "path": {
101 "@id": "path",
102 "@type": "@id"
103 }
104 },
105 "meta": {
106 "type": "https://openminds.ebrains.eu/core/DatasetVersion",
107 "responseVocab": "https://schema.hbp.eu/myQuery/"
108 },
109 "structure": [
110 {
111 "propertyName": "query:id",
112 "path": "@id"
113 },
114 {
115 "propertyName": "query:shortName",
116 "path": "https://openminds.ebrains.eu/vocab/shortName"
117 },
118 {
119 "propertyName": "query:studiedSpecimen",
120 "path": "https://openminds.ebrains.eu/vocab/studiedSpecimen",
121 "required": true,
122 "structure": [
123 {
124 "propertyName": "query:id",
125 "path": "@id"
126 },
127 {
128 "propertyName": "query:biologicalSex",
129 "path": "https://openminds.ebrains.eu/vocab/biologicalSex",
130 "required": true,
131 "structure": {
132 "propertyName": "query:name",
133 "path": "https://openminds.ebrains.eu/vocab/name",
134 "required": true,
135 "filter": {
136 "op": "EQUALS",
137 "value": "male"
138 }
139 }
140 },
141 {
142 "propertyName": "query:studiedState",
143 "path": "https://openminds.ebrains.eu/vocab/studiedState",
144 "required": true,
145 "structure": {
146 "propertyName": "query:ageCategory",
147 "path": "https://openminds.ebrains.eu/vocab/ageCategory",
148 "required": true,
149 "structure": {
150 "propertyName": "query:name",
151 "path": "https://openminds.ebrains.eu/vocab/name",
152 "required": true,
153 "filter": {
154 "op": "EQUALS",
155 "value": "adult"
156 }
157 }
158 }
159 }
160 ]
161 }
162 ]
163 }
164 {{/code}}
165
166 === Example 3 - Find datasets that contain NIfTI files ===
167
168 ==== **Search UI** ====
169
170 Files are organised based on their file format (i.e. file extension) and the software that could be used to open these files. In openMINDS this is captured with the content type. In the filter function, select "application/vnd.nifti.1" under content types to select all the dataset with a NIfTI 1 file format.
171
172 [[[[image:ContentTypes.png]]>>https://search.kg.ebrains.eu/?facet_type[0]=Dataset&facet_Dataset_contentTypes[0]=application%2Fvnd.nifti.1]]
173
174 [[https:~~/~~/search.kg.ebrains.eu/?facet_type[0]=Dataset&facet_Dataset_contentTypes[0]=application%2Fvnd.nifti.1>>https://search.kg.ebrains.eu/?facet_type[0]=Dataset&facet_Dataset_contentTypes[0]=application%2Fvnd.nifti.1]]
175
176 ==== **Query Builder** ====
177
178 To find datasets with a particular file format in it, we can either write a query for 1) the file extension or 2) based on the content type. The difference between the two approaches is that the first approach just looks at the file extension without considering the what type of file format it is and what software can be used to open it. For example, both nifti 1 and nifti 2 files have the same extension. The nifti 2 format is an update of nifti 1 and will not be recognised as a valid nifti 1 format. This is important when considering what program to use when opening the files. To be able to differentiate, we describe the files with content types that tell the user what type of file format it is and we have linked a number of software applications to that content type to facilitate reuse of the data.
179
180 **Query datasets based on file extension**
181
182 We can restrict the search results with a filter using a required field. In this particular case a filter that "ENDS_WITH" a value (e.g. .nii.gz) could be used. We can use .nii for normal nifti files or .nii.gz for compressed nifty files.
183
184 {{code language="json" layout="LINENUMBERS"}}
185 {
186 "@context": {
187 "@vocab": "https://core.kg.ebrains.eu/vocab/query/",
188 "query": "https://schema.hbp.eu/myQuery/",
189 "propertyName": {
190 "@id": "propertyName",
191 "@type": "@id"
192 },
193 "path": {
194 "@id": "path",
195 "@type": "@id"
196 }
197 },
198 "meta": {
199 "type": "https://openminds.ebrains.eu/core/DatasetVersion",
200 "responseVocab": "https://schema.hbp.eu/myQuery/"
201 },
202 "structure": [
203 {
204 "propertyName": "query:shortName",
205 "path": "https://openminds.ebrains.eu/vocab/shortName"
206 },
207 {
208 "propertyName": "query:id",
209 "path": "@id"
210 },
211 {
212 "propertyName": "query:repository",
213 "path": "https://openminds.ebrains.eu/vocab/repository",
214 "required": true,
215 "structure": {
216 "propertyName": "query:fileRepository",
217 "path": {
218 "@id": "https://openminds.ebrains.eu/vocab/fileRepository",
219 "reverse": true
220 },
221 "required": true,
222 "structure": {
223 "propertyName": "query:name",
224 "path": "https://openminds.ebrains.eu/vocab/name",
225 "required": true,
226 "filter": {
227 "op": "ENDS_WITH",
228 "value": ".nii.gz"
229 }
230 }
231 }
232 }
233 ]
234 }
235 {{/code}}
236
237 **Query datasets based on content type**
238
239 To find datasets using the content type structure, we can use a filter that "CONTAINS" a value (e.g. nifti). We are now not distinguishing between nifti 1 or nifti 2 files, but select all files that are classified as "nifti". If you want to narrow down the results further, you could replace "nifti" by "nifti.1" or "nifti.2".
240
241 {{code language="json" layout="LINENUMBERS"}}
242 {
243 "@context": {
244 "@vocab": "https://core.kg.ebrains.eu/vocab/query/",
245 "query": "https://schema.hbp.eu/myQuery/",
246 "propertyName": {
247 "@id": "propertyName",
248 "@type": "@id"
249 },
250 "path": {
251 "@id": "path",
252 "@type": "@id"
253 }
254 },
255 "meta": {
256 "type": "https://openminds.ebrains.eu/core/DatasetVersion",
257 "responseVocab": "https://schema.hbp.eu/myQuery/"
258 },
259 "structure": [
260 {
261 "propertyName": "query:shortName",
262 "path": "https://openminds.ebrains.eu/vocab/shortName"
263 },
264 {
265 "propertyName": "query:id",
266 "path": "@id"
267 },
268 {
269 "propertyName": "query:repository",
270 "path": "https://openminds.ebrains.eu/vocab/repository",
271 "required": true,
272 "structure": {
273 "propertyName": "query:contentTypePattern",
274 "path": "https://openminds.ebrains.eu/vocab/contentTypePattern",
275 "required": true,
276 "structure": {
277 "propertyName": "query:contentType",
278 "path": "https://openminds.ebrains.eu/vocab/contentType",
279 "required": true,
280 "structure": {
281 "propertyName": "query:name",
282 "path": "https://openminds.ebrains.eu/vocab/name",
283 "required": true,
284 "filter": {
285 "op": "CONTAINS",
286 "value": "nifti"
287 }
288 }
289 }
290 }
291 }
292 ]
293 }
294 {{/code}}
295
296 === (% id="cke_bm_3314S" style="display:none" %) (%%)Example 4 - Find the software that can be used to open .smr file formats? ===
297
298 ==== **Search UI** ====
299
300
301 [[https:~~/~~/search.kg.ebrains.eu/?category=Software&inputFormats[0]=application%2Fvnd.spike2.sonpy.son>>https://search.kg.ebrains.eu/?category=Software&inputFormats[0]=application%2Fvnd.spike2.sonpy.son]]
302
303
304 ==== **Query Builder** ====
305
306 {{code language="json" layout="LINENUMBERS"}}
307 {
308 "@context": {
309 "@vocab": "https://core.kg.ebrains.eu/vocab/query/",
310 "query": "https://schema.hbp.eu/myQuery/",
311 "propertyName": {
312 "@id": "propertyName",
313 "@type": "@id"
314 },
315 "path": {
316 "@id": "path",
317 "@type": "@id"
318 }
319 },
320 "meta": {
321 "type": "https://openminds.ebrains.eu/core/SoftwareVersion",
322 "responseVocab": "https://schema.hbp.eu/myQuery/"
323 },
324 "structure": [
325 {
326 "propertyName": "query:id",
327 "path": "@id"
328 },
329 {
330 "propertyName": "query:shortName",
331 "path": "https://openminds.ebrains.eu/vocab/shortName"
332 },
333 {
334 "propertyName": "query:versionIdentifier",
335 "path": "https://openminds.ebrains.eu/vocab/versionIdentifier"
336 },
337 {
338 "propertyName": "query:inputFormat",
339 "path": "https://openminds.ebrains.eu/vocab/inputFormat",
340 "required": true,
341 "structure": [
342 {
343 "propertyName": "query:name",
344 "path": "https://openminds.ebrains.eu/vocab/name"
345 },
346 {
347 "propertyName": "query:fileExtension",
348 "path": "https://openminds.ebrains.eu/vocab/fileExtension",
349 "required": true,
350 "filter": {
351 "op": "CONTAINS",
352 "value": ".smr"
353 }
354 }
355 ]
356 }
357 ]
358 }
359 {{/code}}
360
361
362