@@ -120,48 +120,77 @@ namespace OnixSourcePlugin
120
120
auto json = JSON::parse (file);
121
121
122
122
if (json == var ())
123
+ {
124
+ Onix1::showWarningMessageBoxAsync (" Unable to Parse File" , " The file '" + file.getFileName ().toStdString () + " ' could not be parsed. " +
125
+ " Please ensure that the file exists and is in the correct format." );
123
126
return false ;
127
+ }
124
128
125
129
DynamicObject::Ptr obj = json.getDynamicObject ();
126
130
127
131
if (obj->hasProperty (Identifier (" specification" )))
128
132
{
129
133
std::string specification = obj->getProperty (Identifier (" specification" )).toString ().toStdString ();
130
134
131
- if (specification.compare (" probeinterface" ) != 0 )
135
+ const std::string probeInterfaceSpecification = " probeinterface" ;
136
+
137
+ if (specification.compare (probeInterfaceSpecification) != 0 )
138
+ {
139
+ Onix1::showWarningMessageBoxAsync (" Invalid Specification" , " The specification listed in the Probe Interface file is '" + specification +
140
+ " ', but it is expected to be '" + probeInterfaceSpecification + " '." );
132
141
return false ;
142
+ }
133
143
}
134
144
else
145
+ {
146
+ Onix1::showWarningMessageBoxAsync (" No Specification Found" , " No specification field was found in the JSON file." );
135
147
return false ;
148
+ }
136
149
137
150
if (obj->hasProperty (Identifier (" probes" )))
138
151
{
139
152
Array<var>* probes = obj->getProperty (Identifier (" probes" )).getArray ();
140
153
141
154
if (probes->size () != 1 )
155
+ {
156
+ Onix1::showWarningMessageBoxAsync (" Wrong Number of Probes" , " Expected to find one probe listed in this file, but found " +
157
+ std::to_string (probes->size ()) + " probes in the file." );
142
158
return false ;
159
+ }
143
160
144
161
DynamicObject::Ptr probe = probes->getReference (0 ).getDynamicObject ();
145
162
146
163
if (probe->hasProperty (Identifier (" ndim" )))
147
164
{
148
165
if (!probe->getProperty (Identifier (" ndim" )).equalsWithSameType (2 ))
149
166
{
167
+ Onix1::showWarningMessageBoxAsync (" Invalid Number of Dimensions" , " Expected this file to contain two dimensions, but found `"
168
+ + probe->getProperty (Identifier (" ndim" )).toString ().toStdString () + " ` instead." );
150
169
return false ;
151
170
}
152
171
}
153
172
else
173
+ {
174
+ Onix1::showWarningMessageBoxAsync (" No Dimensions Found" , " Could not find the number of dimensions in the file." );
154
175
return false ;
176
+ }
155
177
156
178
if (probe->hasProperty (Identifier (" si_units" )))
157
179
{
158
- if (!probe->getProperty (Identifier (" si_units" )).equalsWithSameType (" um" ))
180
+ const std::string um = " um" ;
181
+
182
+ if (!probe->getProperty (Identifier (" si_units" )).equalsWithSameType (var (um)))
159
183
{
184
+ Onix1::showWarningMessageBoxAsync (" Unexpected Units Found" , " Expected to see units `" + um + " `, but found `"
185
+ + probe->getProperty (Identifier (" si_units" )).toString ().toStdString () + " ` instead." );
160
186
return false ;
161
187
}
162
188
}
163
189
else
190
+ {
191
+ Onix1::showWarningMessageBoxAsync (" No Units Found" , " Could not find any units in the file." );
164
192
return false ;
193
+ }
165
194
166
195
Array<var>* contact_positions = nullptr ;
167
196
@@ -170,10 +199,17 @@ namespace OnixSourcePlugin
170
199
contact_positions = probe->getProperty (Identifier (" contact_positions" )).getArray ();
171
200
172
201
if (contact_positions->size () != settings->electrodeMetadata .size ())
202
+ {
203
+ Onix1::showWarningMessageBoxAsync (" Different Number of Contacts" , " Expected to find " + std::to_string (settings->electrodeMetadata .size ()) +
204
+ " contacts, but found " + std::to_string (contact_positions->size ()) + " contacts instead." );
173
205
return false ;
206
+ }
174
207
}
175
208
else
209
+ {
210
+ Onix1::showWarningMessageBoxAsync (" No Contacts Found" , " Could not find any contacts in the file." );
176
211
return false ;
212
+ }
177
213
178
214
Array<var>* probe_planar_contour = nullptr ;
179
215
@@ -182,7 +218,9 @@ namespace OnixSourcePlugin
182
218
probe_planar_contour = probe->getProperty (Identifier (" probe_planar_contour" )).getArray ();
183
219
}
184
220
else
185
- return false ;
221
+ {
222
+ LOGD (" No probe planar contour found." );
223
+ }
186
224
187
225
Array<var>* device_channel_indices = nullptr ;
188
226
@@ -191,10 +229,17 @@ namespace OnixSourcePlugin
191
229
device_channel_indices = probe->getProperty (Identifier (" device_channel_indices" )).getArray ();
192
230
193
231
if (device_channel_indices->size () != settings->electrodeMetadata .size ())
232
+ {
233
+ Onix1::showWarningMessageBoxAsync (" Wrong Number of Indices Found" , " Expected to find " + std::to_string (settings->electrodeMetadata .size ()) +
234
+ " device channel indices, but found " + std::to_string (device_channel_indices->size ()) + " instead." );
194
235
return false ;
236
+ }
195
237
}
196
238
else
239
+ {
240
+ Onix1::showWarningMessageBoxAsync (" No Indices Found" , " No device channel indices found in the file." );
197
241
return false ;
242
+ }
198
243
199
244
Array<var>* shank_ids = nullptr ;
200
245
@@ -203,10 +248,17 @@ namespace OnixSourcePlugin
203
248
shank_ids = probe->getProperty (Identifier (" shank_ids" )).getArray ();
204
249
205
250
if (shank_ids->size () != settings->electrodeMetadata .size ())
251
+ {
252
+ Onix1::showWarningMessageBoxAsync (" Wrong Number of Shank IDs Found" , " Expected to find " + std::to_string (settings->electrodeMetadata .size ()) +
253
+ " shank IDs, but found " + std::to_string (shank_ids->size ()) + " instead." );
206
254
return false ;
255
+ }
207
256
}
208
257
else
258
+ {
259
+ Onix1::showWarningMessageBoxAsync (" No Shank IDs Found" , " No shank IDs found in the file." );
209
260
return false ;
261
+ }
210
262
211
263
for (int ch = 0 ; ch < contact_positions->size (); ch++)
212
264
{
@@ -218,11 +270,14 @@ namespace OnixSourcePlugin
218
270
219
271
settings->probeMetadata .probeContour .clear ();
220
272
221
- for ( int i = 0 ; i < probe_planar_contour-> size (); i++ )
273
+ if (probe_planar_contour != nullptr )
222
274
{
223
- Array<var>* point = probe_planar_contour->getReference (i).getArray ();
275
+ for (int i = 0 ; i < probe_planar_contour->size (); i++)
276
+ {
277
+ Array<var>* point = probe_planar_contour->getReference (i).getArray ();
224
278
225
- settings->probeMetadata .probeContour .emplace_back (std::array<float , 2 >{float (point->getReference (0 )), float (point->getReference (1 ))});
279
+ settings->probeMetadata .probeContour .emplace_back (std::array<float , 2 >{float (point->getReference (0 )), float (point->getReference (1 ))});
280
+ }
226
281
}
227
282
228
283
for (int ch = 0 ; ch < shank_ids->size (); ch++)
@@ -244,7 +299,10 @@ namespace OnixSourcePlugin
244
299
settings->selectElectrodes (selectedChannels);
245
300
}
246
301
else
302
+ {
303
+ Onix1::showWarningMessageBoxAsync (" No Probes Found" , " Could not find any probes in the file." );
247
304
return false ;
305
+ }
248
306
249
307
return true ;
250
308
}
0 commit comments