Skip to content

Commit b83d745

Browse files
committed
Merge branch 'Nature' of https://github.com/neurosynth/ACE into Nature
2 parents f4f39d2 + 700885a commit b83d745

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

ace/database.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,12 @@ class Activation(Base):
210210
p_value = Column(String(100))
211211

212212
missing_source = Column(Boolean, default=False)
213+
is_valid = Column(Boolean, default=True) # Added to track validation status
213214

214215
def __init__(self):
215216
self.problems = []
216217
self.columns = {}
218+
self.is_valid = True
217219

218220
def set_coords(self, x, y, z):
219221
new_xyz = []
@@ -238,29 +240,30 @@ def add_col(self, key, val):
238240
# Depending on config, either excludes peak, or allows it through
239241
# but flags potential problems for later inspection.
240242
def validate(self):
243+
valid = True
241244

242245
for c in [self.x, self.y, self.z]:
243246
if c == '' or c is None:
244-
logger.debug('Missing x, y, or z coordinate information: [%s, %s, %s]' % tuple(
245-
[str(e) for e in [self.x, self.y, self.z]]))
246-
return False
247+
msg = 'Missing x, y, or z coordinate information: [%s, %s, %s]'
248+
logger.debug(msg % tuple([str(e) for e in [self.x, self.y, self.z]]))
249+
valid = False
250+
break
247251
try:
248252
if abs(c) >= 100:
249-
logger.debug(
250-
'Invalid coordinates: at least one dimension (x,y,z) >= 100.')
251-
return False
252-
except:
253-
print(c)
254-
print(sys.exc_info()[0])
253+
logger.debug('Invalid coordinates: at least one dimension (x,y,z) >= 100.')
254+
valid = False
255+
break
256+
except Exception as ex:
257+
logger.error("Error validating coordinate: %s" % str(ex))
255258
raise
256259

257-
sorted_xyz = sorted([abs(self.x), abs(self.y), abs(self.z)])
258-
if sorted_xyz[0] == 0 and sorted_xyz[1] == 0:
259-
logger.debug(
260-
"At least two dimensions have value == 0; coordinate is probably not real.")
261-
return False
260+
if valid:
261+
sorted_xyz = sorted([abs(self.x), abs(self.y), abs(self.z)])
262+
if sorted_xyz[0] == 0 and sorted_xyz[1] == 0:
263+
logger.debug("At least two dimensions have value 0; coordinate is probably not real.")
264+
valid = False
262265

263-
return True
266+
self.is_valid = valid
264267

265268
class NeurovaultLink(Base):
266269

0 commit comments

Comments
 (0)