Skip to content

Commit a9c1666

Browse files
authored
Merge pull request #738 from int-brain-lab/alignment_uploads
Alignment uploads
2 parents 297c736 + b77ebec commit a9c1666

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

ibllib/oneibl/patcher.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def __init__(self, one=None):
101101
assert one
102102
self.one = one
103103

104-
def _patch_dataset(self, path, dset_id=None, dry=False, ftp=False):
104+
def _patch_dataset(self, path, dset_id=None, revision=None, dry=False, ftp=False):
105105
"""
106106
This private methods gets the dataset information from alyx, computes the local
107107
and remote paths and initiates the file copy
@@ -113,6 +113,10 @@ def _patch_dataset(self, path, dset_id=None, dry=False, ftp=False):
113113
dset_id = None
114114
assert dset_id
115115
assert is_uuid_string(dset_id)
116+
# If the revision is not None then we need to add the revision into the path. Note the moving of the file
117+
# is handled by one registration client
118+
if revision is not None:
119+
path = path.parent.joinpath(f'#{revision}#', path.name)
116120
assert path.exists()
117121
dset = self.one.alyx.rest('datasets', 'read', id=dset_id)
118122
fr = next(fr for fr in dset['file_records'] if 'flatiron' in fr['data_repository'])
@@ -185,7 +189,7 @@ def patch_dataset(self, file_list, dry=False, ftp=False, **kwargs):
185189
return
186190
# from the dataset info, set flatIron flag to exists=True
187191
for p, d in zip(file_list, response):
188-
self._patch_dataset(p, dset_id=d['id'], dry=dry, ftp=ftp)
192+
self._patch_dataset(p, dset_id=d['id'], revision=d['revision'], dry=dry, ftp=ftp)
189193
return response
190194

191195
def patch_datasets(self, file_list, **kwargs):

ibllib/qc/alignment_qc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import numpy as np
44
from pathlib import Path
5+
from datetime import date
56

67
from neuropixel import trace_header
78
import spikeglx
@@ -166,7 +167,7 @@ def run(self, update=True, upload_alyx=True, upload_flatiron=True):
166167

167168
return results
168169

169-
def resolve_manual(self, align_key, update=True, upload_alyx=True, upload_flatiron=True,
170+
def resolve_manual(self, align_key, update=True, upload_alyx=True, upload_flatiron=False,
170171
force=False):
171172
"""
172173
Method to manually resolve the alignment of a probe insertion with a given alignment
@@ -193,6 +194,7 @@ def resolve_manual(self, align_key, update=True, upload_alyx=True, upload_flatir
193194
results['alignment_resolved'] = True
194195
results['alignment_stored'] = align_key
195196
results['alignment_resolved_by'] = 'experimenter'
197+
results['alignment_resolved_date'] = date.today().isoformat()
196198

197199
if update:
198200
self.update_extended_qc(results)

ibllib/tests/qc/test_alignment_qc.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import copy
88
import random
99
import string
10+
from datetime import date
1011

1112
from one.api import ONE
1213
from neuropixel import trace_header
@@ -322,7 +323,8 @@ def _02_manual_resolution_latest(self):
322323
alignment_stored='2020-09-28T15:57:25_mayo',
323324
alignment_count=3,
324325
trajectory_created=False,
325-
alignment_qc=0.604081)
326+
alignment_qc=0.604081,
327+
alignment_date=date.today().isoformat())
326328

327329
def _03_manual_resolution_not_latest(self):
328330
align_qc = AlignmentQC(self.probe_id, one=one, brain_atlas=brain_atlas, channels=False)
@@ -338,7 +340,8 @@ def _03_manual_resolution_not_latest(self):
338340
alignment_stored='2020-09-28T10:03:06_alejandro',
339341
alignment_count=3,
340342
trajectory_created=True,
341-
alignment_qc=0.604081)
343+
alignment_qc=0.604081,
344+
alignment_date=date.today().isoformat())
342345

343346
@classmethod
344347
def tearDownClass(cls) -> None:
@@ -347,7 +350,7 @@ def tearDownClass(cls) -> None:
347350

348351

349352
def _verify(tc, alignment_resolved=None, alignment_count=None,
350-
alignment_stored=None, trajectory_created=False, alignment_qc=None):
353+
alignment_stored=None, trajectory_created=False, alignment_qc=None, alignment_date=None):
351354
"""
352355
For a given test case with a `probe_id` attribute, check that Alyx returns insertion records
353356
that match the provided parameters.
@@ -382,6 +385,8 @@ def _verify(tc, alignment_resolved=None, alignment_count=None,
382385
f'&probe_id={tc.probe_id}'
383386
'&provenance=Ephys aligned histology track', clobber=True)
384387
tc.assertNotEqual(tc.prev_traj_id == traj[0]['id'], trajectory_created)
388+
if alignment_date:
389+
tc.assertEqual(insertion['json']['extended_qc']['alignment_resolved_date'], alignment_date)
385390

386391

387392
class TestUploadToFlatIron(unittest.TestCase):

0 commit comments

Comments
 (0)