Skip to content

Commit dd0a87e

Browse files
committed
Update docs for classification
1 parent 5806208 commit dd0a87e

File tree

13 files changed

+43
-93
lines changed

13 files changed

+43
-93
lines changed

api/config.py

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
import copy
3-
import glob
43
import json
54
import logging
65
import pymongo
@@ -132,80 +131,6 @@ def apply_env_variables(config):
132131
# validate the lists of json schemas
133132
schema_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../raml/schemas')
134133

135-
expected_mongo_schemas = set([
136-
'acquisition.json',
137-
'analysis.json',
138-
'collection.json',
139-
'container.json',
140-
'file.json',
141-
'group.json',
142-
'note.json',
143-
'permission.json',
144-
'project.json',
145-
'session.json',
146-
'subject.json',
147-
'user.json',
148-
'avatars.json',
149-
'tag.json'
150-
])
151-
expected_input_schemas = set([
152-
'acquisition.json',
153-
'acquisition-update.json',
154-
'analysis.json',
155-
'analysis-job.json',
156-
'analysis-update.json',
157-
'avatars.json',
158-
'classification_update.json',
159-
'collection.json',
160-
'collection-update.json',
161-
'container.json',
162-
'device.json',
163-
'file.json',
164-
'file-update.json',
165-
'group-new.json',
166-
'group-update.json',
167-
'info_update.json',
168-
'modality.json',
169-
'note.json',
170-
'packfile.json',
171-
'permission.json',
172-
'project.json',
173-
'project-template.json',
174-
'project-update.json',
175-
'rule-new.json',
176-
'rule-update.json',
177-
'session.json',
178-
'session-update.json',
179-
'subject.json',
180-
'user-new.json',
181-
'user-update.json',
182-
'download.json',
183-
'tag.json',
184-
'enginemetadata.json',
185-
'labelupload.json',
186-
'uidupload.json',
187-
'uidmatchupload.json',
188-
'search.json'
189-
])
190-
mongo_schemas = set()
191-
input_schemas = set()
192-
193-
# check that the lists of schemas are correct
194-
for schema_filepath in glob.glob(schema_path + '/mongo/*.json'):
195-
schema_file = os.path.basename(schema_filepath)
196-
mongo_schemas.add(schema_file)
197-
with open(schema_filepath, 'rU') as f:
198-
pass
199-
200-
assert mongo_schemas == expected_mongo_schemas, '{} is different from {}'.format(mongo_schemas, expected_mongo_schemas)
201-
202-
for schema_filepath in glob.glob(schema_path + '/input/*.json'):
203-
schema_file = os.path.basename(schema_filepath)
204-
input_schemas.add(schema_file)
205-
with open(schema_filepath, 'rU') as f:
206-
pass
207-
208-
assert input_schemas == expected_input_schemas, '{} is different from {}'.format(input_schemas, expected_input_schemas)
209134

210135
def create_or_recreate_ttl_index(coll_name, index_name, ttl):
211136
if coll_name in db.collection_names():

api/handlers/listhandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ def modify_classification(self, cont_name, list_name, **kwargs):
528528

529529
payload = self.request.json_body
530530

531-
validators.validate_data(payload, 'classification_update.json', 'input', 'POST')
531+
validators.validate_data(payload, 'classification-update.json', 'input', 'POST')
532532

533533
permchecker(noop)('PUT', _id=_id, query_params=kwargs, payload=payload)
534534
storage.modify_classification(_id, kwargs, payload)

api/handlers/modalityhandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def check_and_format_classification(modality_name, classification_map):
127127
"""
128128
try:
129129
modality = containerstorage.ContainerStorage('modalities', use_object_id=False).get_container(modality_name)
130-
except APINotFoundException as e:
130+
except APINotFoundException:
131131
keys = classification_map.keys()
132132
if len(keys) == 1 and keys[0].lower() == 'custom':
133133
# for unknown modalities allow only list of custom values

api/jobs/queue.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,17 @@ def enqueue_job(job_map, origin, perm_check_uid=None):
234234
whitelisted_keys = ['info', 'tags', 'classification', 'mimetype', 'type', 'modality', 'size']
235235
obj_projection = { key: obj.get(key) for key in whitelisted_keys }
236236

237+
###
238+
# recreate `measurements` list on object
239+
# Can be removed when `classification` key has been adopted everywhere
240+
241+
obj_projection['measurements'] = []
242+
if obj_projection.get('classification'):
243+
for v in obj_projection['classification'].itervalues():
244+
obj_projection.extend(v)
245+
#
246+
###
247+
237248
config_['inputs'][x] = {
238249
'base': 'file',
239250
'hierarchy': cr.__dict__,

raml/examples/input/analysis.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"hash": "v0-sha384-12188e00a26650b2baa3f0195337dcf504f4362bb2136eef0cdbefb57159356b1355a0402fca0ab5ab081f21c305e5c2",
99
"name": "cortical_surface_right_hemisphere.obj",
1010
"tags": [],
11-
"measurements": [],
11+
"classification": {},
1212
"modified": "2016-10-18T15:26:35.701000+00:00",
1313
"instrument": null,
1414
"input": true,
@@ -25,7 +25,7 @@
2525
"hash": "v0-sha384-12188e00a26650b2baa3f0195337dcf504f4362bb2136eef0cdbefb57159356b1355a0402fca0ab5ab081f21c305e5c2",
2626
"name": "cortical_surface_right_hemisphere.obj",
2727
"tags": [],
28-
"measurements": [],
28+
"classification": {},
2929
"modified": "2016-10-18T17:45:17.776000+00:00",
3030
"instrument": null,
3131
"output": true,
@@ -44,4 +44,4 @@
4444
"job": "54759eb3c090d83494e2d804",
4545
"label": "Analysis label",
4646
"user": "user_1"
47-
}
47+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"replace": {
3+
"Contrast": ["B0", "Diffusion"],
4+
"Intent": ["Structural"]
5+
}
6+
}

raml/examples/input/file.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "4784_1_1_localizer_dicom.zip",
33
"type": "dicom",
44
"mimetype": "application/zip",
5-
"measurements": [],
5+
"classification": {},
66
"tags": [],
77
"info": {}
88
}

raml/examples/input/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/examples/input/project-template.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
"$schema": "http://json-schema.org/draft-04/schema#",
1616
"type": "object",
1717
"properties": {
18-
"measurement": {
18+
"classification": {
1919
"type": "string",
2020
"pattern": "^[aA]natomical$" }
2121
},
22-
"required": ["measurement"]
22+
"required": ["classification"]
2323
},
2424
"minimum": 2
2525
},
@@ -28,11 +28,11 @@
2828
"$schema": "http://json-schema.org/draft-04/schema#",
2929
"type": "object",
3030
"properties": {
31-
"measurement": {
31+
"classification": {
3232
"type": "string",
3333
"pattern": "^functional$" }
3434
},
35-
"required": ["measurement"]
35+
"required": ["classification"]
3636
},
3737
"minimum": 1
3838
},
@@ -41,13 +41,13 @@
4141
"$schema": "http://json-schema.org/draft-04/schema#",
4242
"type": "object",
4343
"properties": {
44-
"measurement": { "enum": ["Localizer"] },
44+
"classification": { "enum": ["Localizer"] },
4545
"label": {
4646
"type": "string",
4747
"pattern": "t1"
4848
}
4949
},
50-
"required": ["label", "measurement"]
50+
"required": ["label", "classification"]
5151
},
5252
"minimum": 1
5353
}

raml/examples/input/rule-new.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"all": [
77
{
88
"regex": true,
9-
"type": "file.measurements",
9+
"type": "file.classification",
1010
"value": "^(?!non-image).+$"
1111
},
1212
{

raml/examples/output/rule-list.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"all": [
55
{
66
"regex": true,
7-
"type": "file.measurements",
7+
"type": "file.classification",
88
"value": "^(?!non-image).+$"
99
},
1010
{
@@ -25,7 +25,7 @@
2525
},
2626
{
2727
"regex": true,
28-
"type": "file.measurements",
28+
"type": "file.classification",
2929
"value": "^(?!non-image).+$"
3030
}
3131
],
@@ -42,7 +42,7 @@
4242
},
4343
{
4444
"regex": true,
45-
"type": "file.measurements",
45+
"type": "file.classification",
4646
"value": "(functional|anatomy_t1w|anatomy_t2w)"
4747
}
4848
],

raml/schemas/definitions/modality.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"items": {
1616
"type": "string"
1717
}
18-
},
19-
},
18+
}
19+
}
2020
},
2121
"modality":{
2222
"type": "object",

0 commit comments

Comments
 (0)