Skip to content

Commit 7be0ce6

Browse files
committed
Add modality raml
1 parent ccd8edd commit 7be0ce6

File tree

12 files changed

+212
-0
lines changed

12 files changed

+212
-0
lines changed

api/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def apply_env_variables(config):
159159
'file.json',
160160
'group-new.json',
161161
'group-update.json',
162+
'modality.json',
162163
'note.json',
163164
'packfile.json',
164165
'permission.json',

raml/api.raml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ resourceTypes:
5050
/jobs: !include resources/jobs.raml
5151
/gears: !include resources/gears.raml
5252
/devices: !include resources/devices.raml
53+
/rules: !include resources/rules.raml
54+
/modalities: !include resources/modalities.raml
5355
/groups: !include resources/groups.raml
5456
/collections: !include resources/collections.raml
5557
/sessions: !include resources/sessions.raml

raml/examples/input/modality-new.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"_id": "MR",
3+
"classifications": {
4+
"Contrast": ["B0", "B1", "T1", "T2", "T2*", "PD", "MT", "ASL", "Perfusion", "Diffusion", "Spectroscopy", "Susceptibility", "Velocity", "Fingerprinting"],
5+
"Intent": ["Structural", "Functional", "Localizer", "Shim", "Calibration"],
6+
"Features": ["Quantitative", "Multi-Shell", "Multi-Echo", "Multi-Flip", "Multi-Band", "Steady-State", "3D", "Compressed-Sensing", "Eddy-Current-Corrected", "Fieldmap-Corrected", "Gradient-Unwarped", "Motion-Corrected", "Physio-Corrected"]
7+
}
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"classifications": {
3+
"Contrast": ["B0", "B1", "T1", "T2", "T2*", "PD", "MT", "ASL", "Perfusion", "Diffusion", "Spectroscopy", "Susceptibility", "Velocity", "Fingerprinting"],
4+
"Intent": ["Structural", "Functional", "Localizer", "Shim", "Calibration"],
5+
"Features": ["Quantitative", "Multi-Shell", "Multi-Echo", "Multi-Flip", "Multi-Band", "Steady-State", "3D", "Compressed-Sensing", "Eddy-Current-Corrected", "Fieldmap-Corrected", "Gradient-Unwarped", "Motion-Corrected", "Physio-Corrected"]
6+
}
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"_id": "MR",
4+
"classifications": {
5+
"Contrast": ["B0", "B1", "T1", "T2", "T2*", "PD", "MT", "ASL", "Perfusion", "Diffusion", "Spectroscopy", "Susceptibility", "Velocity", "Fingerprinting"],
6+
"Intent": ["Structural", "Functional", "Localizer", "Shim", "Calibration"],
7+
"Features": ["Quantitative", "Multi-Shell", "Multi-Echo", "Multi-Flip", "Multi-Band", "Steady-State", "3D", "Compressed-Sensing", "Eddy-Current-Corrected", "Fieldmap-Corrected", "Gradient-Unwarped", "Motion-Corrected", "Physio-Corrected"]
8+
}
9+
}
10+
]

raml/examples/output/modality.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"_id": "MR",
3+
"classifications": {
4+
"Contrast": ["B0", "B1", "T1", "T2", "T2*", "PD", "MT", "ASL", "Perfusion", "Diffusion", "Spectroscopy", "Susceptibility", "Velocity", "Fingerprinting"],
5+
"Intent": ["Structural", "Functional", "Localizer", "Shim", "Calibration"],
6+
"Features": ["Quantitative", "Multi-Shell", "Multi-Echo", "Multi-Flip", "Multi-Band", "Steady-State", "3D", "Compressed-Sensing", "Eddy-Current-Corrected", "Fieldmap-Corrected", "Gradient-Unwarped", "Motion-Corrected", "Physio-Corrected"]
7+
}
8+
}

raml/resources/modalities.raml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
description: Utility functions for modalities and their acceptable classifications.
2+
get:
3+
description: |
4+
List all modalities and their classifications.
5+
Requires login.
6+
responses:
7+
200:
8+
body:
9+
application/json:
10+
example: !include ../examples/output/modality-list.json
11+
schema: !include ../schemas/output/modality-list.json
12+
post:
13+
description: |
14+
Insert a modality type and its classifications map.
15+
Requires admin.
16+
body:
17+
application/json:
18+
example: !include ../examples/input/modality-new.json
19+
schema: !include ../schemas/input/modality.json
20+
responses:
21+
200:
22+
body:
23+
application/json:
24+
example: |
25+
{
26+
"inserted": "1"
27+
}
28+
29+
/{ModalityName}:
30+
description: Perform actions with a specific modality
31+
uriParameters:
32+
ModalityName:
33+
type: string
34+
get:
35+
description: |
36+
Get modality details.
37+
Requires login.
38+
responses:
39+
200:
40+
body:
41+
application/json:
42+
example: !include ../examples/output/modality.json
43+
schema: !include ../schemas/output/modality.json
44+
404:
45+
description: Modality not found
46+
put:
47+
description: |
48+
Replace a modality's classifications map.
49+
Requires admin.
50+
body:
51+
application/json:
52+
example: !include ../examples/input/modality-update.json
53+
schema: !include ../schemas/input/modality.json
54+
responses:
55+
200:
56+
body:
57+
application/json:
58+
example: |
59+
{
60+
"modified": "1"
61+
}
62+
404:
63+
description: Modality not found
64+
delete:
65+
description: |
66+
Remove a modality.
67+
Requires admin.
68+
responses:
69+
200:
70+
body:
71+
application/json:
72+
example: |
73+
{
74+
"modified": "1"
75+
}
76+
404:
77+
description: Modality not found
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"type": "object",
4+
"definitions": {
5+
"_id": {
6+
"maxLength": 64,
7+
"minLength": 2,
8+
"pattern": "^[0-9a-zA-Z_-]*$"
9+
},
10+
"classifications": {
11+
"type": "object",
12+
"patternProperties": {
13+
"^[0-9a-zA-Z_-]*$":{
14+
"type": "array",
15+
"items": {
16+
"type": "string"
17+
}
18+
},
19+
},
20+
},
21+
"modality":{
22+
"type": "object",
23+
"properties": {
24+
"_id": {"$ref":"#/definitions/_id"},
25+
"classifications": {"$ref":"#/definitions/classifications"}
26+
},
27+
"additionalProperties": false
28+
}
29+
}
30+
}

raml/schemas/input/modality.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"allOf":[{"$ref":"../definitions/modality.json#/definitions/modality"}],
4+
"required": ["classifications"]
5+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"type":"array",
4+
"items":{
5+
"allOf":[{"$ref":"../definitions/modality.json#/definitions/modality"}],
6+
"required":["_id", "classifications"]
7+
}
8+
}

raml/schemas/output/modality.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"allOf":[{"$ref":"../definitions/modality.json#/definitions/modality"}],
4+
"required": ["_id", "classifications"]
5+
}

test/integration_tests/abao/abao_test_hooks.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var test_project_tag = 'test-project-tag';
2424
var delete_project_id = '';
2525
var device_id = 'bootstrapper_Bootstrapper'
2626
var injected_api_key = 'XZpXI40Uk85eozjQkU1zHJ6yZHpix+j0mo1TMeGZ4dPzIqVPVGPmyfeK'
27+
var modality_name = 'MR'
2728

2829
// Tests we're skipping, fix these
2930

@@ -1478,3 +1479,53 @@ hooks.before("GET /devices/{DeviceId} -> 404", function(test, done) {
14781479
test.request.params.DeviceId = 'bad_device_id';
14791480
done();
14801481
});
1482+
1483+
hooks.before("GET /modalities/{ModalityName} -> 200", function(test, done) {
1484+
test.request.params.ModalityName = modality_name;
1485+
done();
1486+
});
1487+
1488+
hooks.before("GET /modalities/{ModalityName} -> 404", function(test, done) {
1489+
test.request.params.ModalityName = 'bad_modality_name';
1490+
done();
1491+
});
1492+
1493+
hooks.before("POST /modalities/ -> 200", function(test, done) {
1494+
test.request.body = {
1495+
"_id":"MR",
1496+
"classifications": {
1497+
"intent": ["functional"]
1498+
}
1499+
}
1500+
done();
1501+
});
1502+
1503+
hooks.before("PUT /modalities/{ModalityName} -> 200", function(test, done) {
1504+
test.request.params.ModalityName = modality_name;
1505+
test.request.body = {
1506+
"classifications": {
1507+
"intent": ["localizer"]
1508+
}
1509+
}
1510+
done();
1511+
});
1512+
1513+
hooks.before("PUT /modalities/{ModalityName} -> 404", function(test, done) {
1514+
test.request.params.ModalityName = 'bad_modality_name';
1515+
test.request.body = {
1516+
"classifications": {
1517+
"intent": ["localizer"]
1518+
}
1519+
}
1520+
done();
1521+
});
1522+
1523+
hooks.before("DELETE /modalities/{ModalityName} -> 200", function(test, done) {
1524+
test.request.params.ModalityName = modality_name;
1525+
done();
1526+
});
1527+
1528+
hooks.before("DELETE /modalities/{ModalityName} -> 404", function(test, done) {
1529+
test.request.params.ModalityName = 'bad_modality_name';
1530+
done();
1531+
});

0 commit comments

Comments
 (0)