BRAVOClient 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- BRAVO/Client/BRAVOPlatformRequest.py +510 -0
- BRAVO/Client/__init__.py +4 -0
- BRAVO/__init__.py +0 -0
- bravoclient-0.1.0.dist-info/METADATA +15 -0
- bravoclient-0.1.0.dist-info/RECORD +8 -0
- bravoclient-0.1.0.dist-info/WHEEL +5 -0
- bravoclient-0.1.0.dist-info/licenses/LICENSE +21 -0
- bravoclient-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
import pickle as pkl
|
|
5
|
+
import datetime
|
|
6
|
+
|
|
7
|
+
DefaultConfigurations = {
|
|
8
|
+
"TimeSeriesRecording": {
|
|
9
|
+
"StandardFilter": {
|
|
10
|
+
"name": "Standard Bandpass Filter",
|
|
11
|
+
"description": "",
|
|
12
|
+
"options": ["No Filter", "Butterworth 1-100Hz"],
|
|
13
|
+
"value": "No Filter"
|
|
14
|
+
},
|
|
15
|
+
"NotchFilter": {
|
|
16
|
+
"name": "Powerline Noise Notch Filter",
|
|
17
|
+
"description": "",
|
|
18
|
+
"options": ["No Filter", "Notch 55-65Hz", "Notch 45-55Hz"],
|
|
19
|
+
"value": "No Filter"
|
|
20
|
+
},
|
|
21
|
+
"WienerFilter": {
|
|
22
|
+
"name": "Wiener Filter for Artifact Removals",
|
|
23
|
+
"description": "",
|
|
24
|
+
"options": ["No Filter", "Use Wiener Filter"],
|
|
25
|
+
"value": "No Filter"
|
|
26
|
+
},
|
|
27
|
+
"CardiacFilter": {
|
|
28
|
+
"name": "Cardiac Filter for EKG Removals",
|
|
29
|
+
"description": "",
|
|
30
|
+
"options": ["No Filter", "Use Adaptive Template Matching"],
|
|
31
|
+
"value": "No Filter"
|
|
32
|
+
},
|
|
33
|
+
"SpectrogramMethod": {
|
|
34
|
+
"name": "Time-Frequency Analysis Algorithm",
|
|
35
|
+
"description": "",
|
|
36
|
+
"options": ["Welch's Periodogram", "Short-time Fourier Transform", "Wavelet",
|
|
37
|
+
"Autoregressive Model (Yule-Walker)"],
|
|
38
|
+
"value": "Welch's Periodogram"
|
|
39
|
+
},
|
|
40
|
+
"BaselineCorrection": {
|
|
41
|
+
"name": "Baseline Correlation for Time-Frequency Analysis",
|
|
42
|
+
"description": "",
|
|
43
|
+
"options": ["No Correction"],
|
|
44
|
+
"value": "No Correction"
|
|
45
|
+
},
|
|
46
|
+
"Normalization": {
|
|
47
|
+
"name": "Normalization for Time-Frequency Analysis",
|
|
48
|
+
"description": "",
|
|
49
|
+
"options": ["No Normalization", "1/f PSD Trend Removal"],
|
|
50
|
+
"value": "No Normalization"
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
"PowerSpectralDensity": {
|
|
54
|
+
"PSDMethod": {
|
|
55
|
+
"name": "Power Spectrum Estimation Algorithm",
|
|
56
|
+
"description": "",
|
|
57
|
+
"options": ["Estimated Medtronic PSD", "Welch's Periodogram", "Autoregressive Model (Yule-Walker)",
|
|
58
|
+
"Short-time Fourier Transform"],
|
|
59
|
+
"value": "Welch's Periodogram"
|
|
60
|
+
},
|
|
61
|
+
"MonopolarEstimation": {
|
|
62
|
+
"name": "Monopolar Estimation Algorithm",
|
|
63
|
+
"description": "",
|
|
64
|
+
"options": ["No Estimation", "DETEC Algorithm (Strelow et. al., 2022)"],
|
|
65
|
+
"value": "No Estimation"
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class BRAVOPlatformRequest:
|
|
72
|
+
def __init__(self, api_key, server="http://localhost:27286"):
|
|
73
|
+
self.__Server = server
|
|
74
|
+
self.__request = requests.Session()
|
|
75
|
+
self.__API_Key = api_key
|
|
76
|
+
|
|
77
|
+
self.User = self.GetUserInfo()
|
|
78
|
+
|
|
79
|
+
def query(self, url, data=None, files=None, content_type="application/json"):
|
|
80
|
+
if not content_type:
|
|
81
|
+
Headers = {"X-Secure-API-Key": self.__API_Key}
|
|
82
|
+
else:
|
|
83
|
+
Headers = {"Content-Type": content_type, "X-Secure-API-Key": self.__API_Key}
|
|
84
|
+
|
|
85
|
+
if data:
|
|
86
|
+
return self.__request.post(self.__Server + url,
|
|
87
|
+
json.dumps(data) if content_type else data,
|
|
88
|
+
headers=Headers)
|
|
89
|
+
elif files:
|
|
90
|
+
return self.__request.post(self.__Server + url,
|
|
91
|
+
files=files,
|
|
92
|
+
headers=Headers)
|
|
93
|
+
else:
|
|
94
|
+
return self.__request.post(self.__Server + url,
|
|
95
|
+
headers=Headers)
|
|
96
|
+
|
|
97
|
+
def GetUserInfo(self):
|
|
98
|
+
response = self.query("/api/queryProfile")
|
|
99
|
+
if response.status_code == 200:
|
|
100
|
+
payload = response.json()
|
|
101
|
+
self.User = payload
|
|
102
|
+
return payload
|
|
103
|
+
else:
|
|
104
|
+
if response.status_code == 400:
|
|
105
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
106
|
+
else:
|
|
107
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
108
|
+
|
|
109
|
+
def QueryParticipants(self):
|
|
110
|
+
response = self.query("/api/queryParticipants")
|
|
111
|
+
if response.status_code == 200:
|
|
112
|
+
payload = response.json()
|
|
113
|
+
return payload
|
|
114
|
+
else:
|
|
115
|
+
if response.status_code == 400:
|
|
116
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
117
|
+
else:
|
|
118
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
119
|
+
|
|
120
|
+
def QueryParticipantInformation(self, participant_uid):
|
|
121
|
+
form = {"ParticipantId": participant_uid}
|
|
122
|
+
response = self.query("/api/queryParticipantInformation", data=form)
|
|
123
|
+
if response.status_code == 200:
|
|
124
|
+
payload = response.json()
|
|
125
|
+
return payload
|
|
126
|
+
else:
|
|
127
|
+
if response.status_code == 400:
|
|
128
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
129
|
+
else:
|
|
130
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
131
|
+
|
|
132
|
+
def UpdateParticipantInformation(self, participant_uid, info):
|
|
133
|
+
form = {"ParticipantId": participant_uid}
|
|
134
|
+
form = {**form, **info}
|
|
135
|
+
|
|
136
|
+
response = self.query("/api/updateParticipantInformation", data=form)
|
|
137
|
+
if response.status_code == 200:
|
|
138
|
+
payload = response.json()
|
|
139
|
+
return payload
|
|
140
|
+
else:
|
|
141
|
+
if response.status_code == 400:
|
|
142
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
143
|
+
else:
|
|
144
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
145
|
+
|
|
146
|
+
def ListAllStudies(self):
|
|
147
|
+
form = {"RequestType": "GetStudies"}
|
|
148
|
+
response = self.query("/api/manageStudyInformation", data=form)
|
|
149
|
+
if response.status_code == 200:
|
|
150
|
+
payload = response.json()
|
|
151
|
+
return payload
|
|
152
|
+
else:
|
|
153
|
+
if response.status_code == 400:
|
|
154
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
155
|
+
else:
|
|
156
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
157
|
+
|
|
158
|
+
def CreateNewStudy(self, study_name):
|
|
159
|
+
form = {"RequestType": "CreateStudy", "StudyName": study_name}
|
|
160
|
+
response = self.query("/api/manageStudyInformation", data=form)
|
|
161
|
+
if response.status_code == 200:
|
|
162
|
+
payload = response.json()
|
|
163
|
+
return payload
|
|
164
|
+
else:
|
|
165
|
+
if response.status_code == 400:
|
|
166
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
167
|
+
else:
|
|
168
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
169
|
+
|
|
170
|
+
def AddParticipantToStudy(self, study_id, participant_uid):
|
|
171
|
+
form = {"RequestType": "AddParticipant", "StudyId": study_id, "ParticipantId": participant_uid}
|
|
172
|
+
response = self.query("/api/manageStudyInformation", data=form)
|
|
173
|
+
if response.status_code == 200:
|
|
174
|
+
return True
|
|
175
|
+
else:
|
|
176
|
+
if response.status_code == 400:
|
|
177
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
178
|
+
else:
|
|
179
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
180
|
+
|
|
181
|
+
def RemoveParticipantFromStudy(self, study_id, participant_uid):
|
|
182
|
+
form = {"RequestType": "RemoveParticipant", "StudyId": study_id, "ParticipantId": participant_uid}
|
|
183
|
+
response = self.query("/api/manageStudyInformation", data=form)
|
|
184
|
+
if response.status_code == 200:
|
|
185
|
+
return True
|
|
186
|
+
else:
|
|
187
|
+
if response.status_code == 400:
|
|
188
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
189
|
+
else:
|
|
190
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
191
|
+
|
|
192
|
+
def QueryTherapyHistory(self, participant_uid):
|
|
193
|
+
form = {"ParticipantId": participant_uid}
|
|
194
|
+
response = self.query("/api/queryTherapyHistory", data=form)
|
|
195
|
+
if response.status_code == 200:
|
|
196
|
+
payload = response.json()
|
|
197
|
+
return payload
|
|
198
|
+
else:
|
|
199
|
+
if response.status_code == 400:
|
|
200
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
201
|
+
else:
|
|
202
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
203
|
+
|
|
204
|
+
def QueryTherapeuticEffectAnalysis(self, participant_uid, analysis_uid=None, config=None):
|
|
205
|
+
form = {"ParticipantId": participant_uid, "RequestType": "Overview"}
|
|
206
|
+
if analysis_uid:
|
|
207
|
+
form["RequestType"] = "RequestData"
|
|
208
|
+
form["AnalysisId"] = analysis_uid
|
|
209
|
+
form["ActiveChannels"] = "RequestAllChannel"
|
|
210
|
+
|
|
211
|
+
if config:
|
|
212
|
+
form["ProcessingConfiguration"] = config
|
|
213
|
+
|
|
214
|
+
response = self.query("/api/queryTherapeuticEffectAnalysis", data=form)
|
|
215
|
+
if response.status_code == 200:
|
|
216
|
+
payload = response.json()
|
|
217
|
+
return payload
|
|
218
|
+
else:
|
|
219
|
+
if response.status_code == 400:
|
|
220
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
221
|
+
else:
|
|
222
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
223
|
+
|
|
224
|
+
def SetRecordingTimeShift(self, participant_uid, analysis_uid, recording_uid, shift=0):
|
|
225
|
+
form = {"RequestType": "RemoveParticipant", "ParticipantId": participant_uid, "AnalysisId": analysis_uid,
|
|
226
|
+
"RecordingId": recording_uid, "Alignment": shift}
|
|
227
|
+
response = self.query("/api/setRecordingTimeShift", data=form)
|
|
228
|
+
if response.status_code == 200:
|
|
229
|
+
return True
|
|
230
|
+
else:
|
|
231
|
+
if response.status_code == 400:
|
|
232
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
233
|
+
else:
|
|
234
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
235
|
+
|
|
236
|
+
def QueryNeuralActivitySnapshot(self, participant_uid, config=None):
|
|
237
|
+
form = {"ParticipantId": participant_uid, "RequestType": "RequestAll"}
|
|
238
|
+
if config:
|
|
239
|
+
form["ProcessingConfiguration"] = config
|
|
240
|
+
|
|
241
|
+
response = self.query("/api/queryNeuralActivitySnapshot", data=form)
|
|
242
|
+
if response.status_code == 200:
|
|
243
|
+
payload = response.json()
|
|
244
|
+
return payload
|
|
245
|
+
else:
|
|
246
|
+
if response.status_code == 400:
|
|
247
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
248
|
+
else:
|
|
249
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
250
|
+
|
|
251
|
+
def QueryTimeSeriesAnalysis(self, participant_uid, recording_uid=None, therapy_uid=None, config=None,
|
|
252
|
+
refresh=False):
|
|
253
|
+
form = {"ParticipantId": participant_uid, "RequestType": "Overview"}
|
|
254
|
+
if recording_uid:
|
|
255
|
+
form["RequestType"] = "RequestData"
|
|
256
|
+
form["AnalysisId"] = recording_uid
|
|
257
|
+
form["TherapyId"] = therapy_uid
|
|
258
|
+
form["ActiveChannels"] = "RequestAllChannel"
|
|
259
|
+
|
|
260
|
+
if refresh:
|
|
261
|
+
form["RequestType"] = "DeleteCache"
|
|
262
|
+
|
|
263
|
+
if config:
|
|
264
|
+
form["ProcessingConfiguration"] = config
|
|
265
|
+
|
|
266
|
+
response = self.query("/api/queryTimeseriesAnalysis", data=form)
|
|
267
|
+
if response.status_code == 200:
|
|
268
|
+
if refresh:
|
|
269
|
+
return self.QueryTimeSeriesAnalysis(participant_uid, recording_uid, therapy_uid, config)
|
|
270
|
+
|
|
271
|
+
payload = response.json()
|
|
272
|
+
return payload
|
|
273
|
+
else:
|
|
274
|
+
if response.status_code == 400:
|
|
275
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
276
|
+
else:
|
|
277
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
278
|
+
|
|
279
|
+
def QueryChronicNeuralActivity(self, participant_uid, refresh=False):
|
|
280
|
+
form = {"ParticipantId": participant_uid, "RequestType": "RequestAll"}
|
|
281
|
+
if refresh:
|
|
282
|
+
form["RequestType"] = "DeleteCache"
|
|
283
|
+
|
|
284
|
+
response = self.query("/api/queryChronicNeuralActivity", data=form)
|
|
285
|
+
if response.status_code == 200:
|
|
286
|
+
if refresh:
|
|
287
|
+
return self.QueryChronicNeuralActivity(participant_uid)
|
|
288
|
+
|
|
289
|
+
payload = response.json()
|
|
290
|
+
return payload
|
|
291
|
+
else:
|
|
292
|
+
if response.status_code == 400:
|
|
293
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
294
|
+
else:
|
|
295
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
296
|
+
|
|
297
|
+
def QueryChronicTimeline(self, participant_uid):
|
|
298
|
+
form = {"ParticipantId": participant_uid, "RequestType": "RequestAll"}
|
|
299
|
+
response = self.query("/api/queryChronicTimeline", data=form)
|
|
300
|
+
if response.status_code == 200:
|
|
301
|
+
payload = response.json()
|
|
302
|
+
return payload
|
|
303
|
+
else:
|
|
304
|
+
if response.status_code == 400:
|
|
305
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
306
|
+
else:
|
|
307
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
308
|
+
|
|
309
|
+
def QueryRawTimeseries(self, participant_uid, recording_uid=None):
|
|
310
|
+
form = {"ParticipantId": participant_uid, "RequestType": "Overview"}
|
|
311
|
+
if recording_uid:
|
|
312
|
+
form["RequestType"] = "RawTimeseries"
|
|
313
|
+
form["RecordingId"] = recording_uid
|
|
314
|
+
|
|
315
|
+
response = self.query("/api/queryRawTimeseries", data=form)
|
|
316
|
+
if response.status_code == 200:
|
|
317
|
+
payload = response.json()
|
|
318
|
+
return payload
|
|
319
|
+
else:
|
|
320
|
+
if response.status_code == 400:
|
|
321
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
322
|
+
else:
|
|
323
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
324
|
+
|
|
325
|
+
def QuerySurveyForms(self, form_link=None, version=None):
|
|
326
|
+
form = {"RequestType": "RequestAll"}
|
|
327
|
+
if form_link:
|
|
328
|
+
form["RequestType"] = "RequestForm"
|
|
329
|
+
form["FormLink"] = form_link
|
|
330
|
+
if version:
|
|
331
|
+
form["VersionRel"] = version
|
|
332
|
+
|
|
333
|
+
response = self.query("/api/querySurveyForms", data=form)
|
|
334
|
+
if response.status_code == 200:
|
|
335
|
+
payload = response.json()
|
|
336
|
+
return payload
|
|
337
|
+
else:
|
|
338
|
+
if response.status_code == 400:
|
|
339
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
340
|
+
else:
|
|
341
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
342
|
+
|
|
343
|
+
def CreateSurveyForm(self, institute, form_name):
|
|
344
|
+
form = {"RequestType": "Create", "Institute": institute, "FormName": form_name,
|
|
345
|
+
"FormType": "API-Generated Form", "FormContent": []}
|
|
346
|
+
response = self.query("/api/setSurveyForms", data=form)
|
|
347
|
+
if response.status_code == 200:
|
|
348
|
+
payload = response.json()
|
|
349
|
+
return payload
|
|
350
|
+
else:
|
|
351
|
+
if response.status_code == 400:
|
|
352
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
353
|
+
else:
|
|
354
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
355
|
+
|
|
356
|
+
def DeleteSurveyForm(self, form_uid):
|
|
357
|
+
form = {"FormId": form_uid}
|
|
358
|
+
|
|
359
|
+
response = self.query("/api/deleteSurveyForms", data=form)
|
|
360
|
+
if response.status_code == 200:
|
|
361
|
+
return True
|
|
362
|
+
else:
|
|
363
|
+
if response.status_code == 400:
|
|
364
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
365
|
+
else:
|
|
366
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
367
|
+
|
|
368
|
+
def UpdateSurveyForm(self, form_link, content):
|
|
369
|
+
form = {"RequestType": "Create", "FormLink": form_link, "FormContent": content}
|
|
370
|
+
response = self.query("/api/setSurveyForms", data=form)
|
|
371
|
+
if response.status_code == 200:
|
|
372
|
+
payload = response.json()
|
|
373
|
+
return payload
|
|
374
|
+
else:
|
|
375
|
+
if response.status_code == 400:
|
|
376
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
377
|
+
else:
|
|
378
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
379
|
+
|
|
380
|
+
def SubmitSurveyResponse(self, form_uid, version, responder_code, result={}, date=None):
|
|
381
|
+
form = {"RequestType": "SubmitForm", "FormId": form_uid, "Version": version, "Passcode": responder_code,
|
|
382
|
+
"FormResults": result}
|
|
383
|
+
if not date:
|
|
384
|
+
form["Date"] = datetime.datetime.now(datetime.timezone.utc).timestamp()
|
|
385
|
+
else:
|
|
386
|
+
form["Date"] = date
|
|
387
|
+
|
|
388
|
+
response = self.query("/api/querySurveyForms", data=form)
|
|
389
|
+
if response.status_code == 200:
|
|
390
|
+
payload = response.json()
|
|
391
|
+
return payload
|
|
392
|
+
else:
|
|
393
|
+
if response.status_code == 400:
|
|
394
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
395
|
+
else:
|
|
396
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
397
|
+
|
|
398
|
+
def QuerySurveyResponse(self, participant_uid, form_uid=None):
|
|
399
|
+
form = {"ParticipantId": participant_uid, "RequestType": "RequestAll"}
|
|
400
|
+
if form_uid:
|
|
401
|
+
form["RequestType"] = "RequestRecords"
|
|
402
|
+
form["FormId"] = form_uid
|
|
403
|
+
response = self.query("/api/queryParticipantSurveyRecords", data=form)
|
|
404
|
+
|
|
405
|
+
if response.status_code == 200:
|
|
406
|
+
payload = response.json()
|
|
407
|
+
return payload
|
|
408
|
+
else:
|
|
409
|
+
if response.status_code == 400:
|
|
410
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
411
|
+
else:
|
|
412
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
413
|
+
|
|
414
|
+
def QueryEvents(self, participant_uid, data=False):
|
|
415
|
+
form = {"ParticipantId": participant_uid, "RequestType": "RequestAll"}
|
|
416
|
+
if data:
|
|
417
|
+
form["RequestType"] = "RequestData"
|
|
418
|
+
response = self.query("/api/queryParticipantEvents", data=form)
|
|
419
|
+
|
|
420
|
+
if response.status_code == 200:
|
|
421
|
+
payload = response.json()
|
|
422
|
+
return payload
|
|
423
|
+
else:
|
|
424
|
+
if response.status_code == 400:
|
|
425
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
426
|
+
else:
|
|
427
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
428
|
+
|
|
429
|
+
def DeleteData(self, recording_uid, participant=None):
|
|
430
|
+
participantObj = participant if participant else self.__ActiveParticipant
|
|
431
|
+
data = {"participant": participantObj["uid"], "study": participantObj["study"], "recording_uid": recording_uid}
|
|
432
|
+
response = self.query("/api/deleteData", data)
|
|
433
|
+
if response.status_code == 200:
|
|
434
|
+
return True
|
|
435
|
+
elif response.status_code == 301:
|
|
436
|
+
return True
|
|
437
|
+
else:
|
|
438
|
+
if response.status_code == 400:
|
|
439
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
440
|
+
else:
|
|
441
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
442
|
+
|
|
443
|
+
def RequestAnalysisPipeline(self, request_type, participant_uid):
|
|
444
|
+
data = {"RequestType": request_type, "AnalysisName": request_type, "ParticipantId": participant_uid}
|
|
445
|
+
response = self.query("/api/queryAnalysisPipeline", data)
|
|
446
|
+
if response.status_code == 200:
|
|
447
|
+
return response.json()
|
|
448
|
+
elif response.status_code == 301:
|
|
449
|
+
return True
|
|
450
|
+
else:
|
|
451
|
+
if response.status_code == 400:
|
|
452
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
453
|
+
else:
|
|
454
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
455
|
+
|
|
456
|
+
def RequestAIPrediction(self, request_type, data):
|
|
457
|
+
data = {"RequestType": request_type, "AnalysisName": request_type, "Data": data}
|
|
458
|
+
response = self.query("/api/requestAIPrediction", data)
|
|
459
|
+
if response.status_code == 200:
|
|
460
|
+
return response.json()
|
|
461
|
+
elif response.status_code == 301:
|
|
462
|
+
return True
|
|
463
|
+
else:
|
|
464
|
+
if response.status_code == 400:
|
|
465
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
466
|
+
else:
|
|
467
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
468
|
+
|
|
469
|
+
def UploadMedtronicJSON(self, participant, file, metadata={"device_location": "", "infer_from_device": True}):
|
|
470
|
+
form = {
|
|
471
|
+
"File": file,
|
|
472
|
+
"DataType": (None, "MedtronicJSON"),
|
|
473
|
+
"ParticipantId": (None, participant),
|
|
474
|
+
"Institute": (None, self.User["Institute"]),
|
|
475
|
+
"Metadata": (None, json.dumps(metadata))
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
response = self.query("/api/uploadData", files=form, content_type=None)
|
|
479
|
+
if response.status_code == 200:
|
|
480
|
+
return True
|
|
481
|
+
elif response.status_code == 301:
|
|
482
|
+
return True
|
|
483
|
+
else:
|
|
484
|
+
if response.status_code == 400:
|
|
485
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
486
|
+
else:
|
|
487
|
+
raise Exception(f"Network Error: {response.status_code}")
|
|
488
|
+
|
|
489
|
+
def UploadMATFile(self, participant, file, metadata=dict()):
|
|
490
|
+
if not "StartTime" in metadata:
|
|
491
|
+
metadata["StartTime"] = datetime.datetime.now(datetime.timezone.utc).timestamp()
|
|
492
|
+
|
|
493
|
+
form = {
|
|
494
|
+
"File": file,
|
|
495
|
+
"DataType": (None, "MATFile"),
|
|
496
|
+
"ParticipantId": (None, participant),
|
|
497
|
+
"Institute": (None, self.User["Institute"]),
|
|
498
|
+
"Metadata": (None, json.dumps(metadata))
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
response = self.query("/api/uploadData", files=form, content_type=None)
|
|
502
|
+
if response.status_code == 200:
|
|
503
|
+
return True
|
|
504
|
+
elif response.status_code == 301:
|
|
505
|
+
return True
|
|
506
|
+
else:
|
|
507
|
+
if response.status_code == 400:
|
|
508
|
+
raise Exception(f"Network Error: {response.json()}")
|
|
509
|
+
else:
|
|
510
|
+
raise Exception(f"Network Error: {response.status_code}")
|
BRAVO/Client/__init__.py
ADDED
BRAVO/__init__.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: BRAVOClient
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The Python API Toolkit for interacting with the Brain Recording Analysis and Visualization Online (BRAVO) Platform
|
|
5
|
+
Author-email: Jackson Cagle <jackson.cagle@neurology.ufl.edu>
|
|
6
|
+
Project-URL: Homepage, https://github.com/Fixel-Institute/BRAVO
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/Fixel-Institute/BRAVO/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: requests>=2.28.0
|
|
15
|
+
Dynamic: license-file
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
BRAVO/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
BRAVO/Client/BRAVOPlatformRequest.py,sha256=pdyxSYOhvwsa15K1PbdWKIXxQT51ez2TGInxqoa-1ZU,20880
|
|
3
|
+
BRAVO/Client/__init__.py,sha256=0z4qULkbzdimB2Sy9rqLcUGEPKDMCtDD_NgQJo5RjR0,223
|
|
4
|
+
bravoclient-0.1.0.dist-info/licenses/LICENSE,sha256=CegUxkBgaatOPTm9aj6yov0uYpZMqiiqZLR6idSsQh0,1098
|
|
5
|
+
bravoclient-0.1.0.dist-info/METADATA,sha256=7CPld6r0bKVQIDz_TMGwAoYVmkgcPETOIXljABc3tVM,664
|
|
6
|
+
bravoclient-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
7
|
+
bravoclient-0.1.0.dist-info/top_level.txt,sha256=ilHBuIU7VotcolVw70Ydb1qIlvZKlSNk7WG-Gh6Z6wA,6
|
|
8
|
+
bravoclient-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fixel Institute for Neurological Diseases
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
BRAVO
|