def test_05_not_latest_alignments_agree(self): alignments = copy.deepcopy(self.alignments) trajectory = copy.deepcopy(self.trajectory) trajectory.update({'json': alignments}) traj = one.alyx.rest('trajectories', 'update', id=self.prev_traj_id, data=trajectory) assert (self.prev_traj_id == traj['id']) align_qc = AlignmentQC(self.probe_id, one=one, brain_atlas=brain_atlas, channels=False) align_qc.load_data(prev_alignments=traj['json'], xyz_picks=np.array(self.xyz_picks) / 1e6, cluster_chns=self.cluster_chns) align_qc.resolved = 0 align_qc.run(update=True, upload_alyx=True, upload_flatiron=False) insertion = one.alyx.rest('insertions', 'read', id=self.probe_id) assert (insertion['json']['qc'] == 'NOT_SET') assert (insertion['json']['extended_qc']['alignment_count'] == 4) assert (insertion['json']['extended_qc']['alignment_stored'] == '2020-06-19T10:52:36_noam.roth') assert (insertion['json']['extended_qc']['alignment_resolved'] == 1) assert ( insertion['json']['extended_qc']['alignment_resolved_by'] == 'qc') assert (insertion['json']['extended_qc']['alignment_qc'] > 0.8) assert (np.isclose(insertion['json']['extended_qc']['alignment_qc'], 0.952319)) traj = one.alyx.rest('trajectories', 'list', probe_id=self.probe_id, provenance='Ephys aligned histology track') assert (self.prev_traj_id != traj[0]['id'])
def test_04_alignments_agree(self): alignments = { '2020-06-19T10:52:36_noam.roth': self.alignments['2020-06-19T10:52:36_noam.roth'], '2020-06-12T00:39:15_nate': self.alignments['2020-06-12T00:39:15_nate'] } trajectory = copy.deepcopy(self.trajectory) trajectory.update({'json': alignments}) traj = one.alyx.rest('trajectories', 'update', id=self.prev_traj_id, data=trajectory) assert (self.prev_traj_id == traj['id']) align_qc = AlignmentQC(self.probe_id, one=one, brain_atlas=brain_atlas, channels=False) align_qc.load_data(cluster_chns=self.cluster_chns) align_qc.run(update=True, upload_alyx=True, upload_flatiron=False) insertion = one.alyx.rest('insertions', 'read', id=self.probe_id) assert (insertion['json']['qc'] == 'NOT_SET') assert (insertion['json']['extended_qc']['alignment_count'] == 2) assert (insertion['json']['extended_qc']['alignment_stored'] == '2020-06-19T10:52:36_noam.roth') assert (insertion['json']['extended_qc']['alignment_resolved'] == 1) assert ( insertion['json']['extended_qc']['alignment_resolved_by'] == 'qc') assert (insertion['json']['extended_qc']['alignment_qc'] > 0.8) traj = one.alyx.rest('trajectories', 'list', probe_id=self.probe_id, provenance='Ephys aligned histology track') assert (self.prev_traj_id == traj[0]['id'])
def _05_not_latest_alignments_agree(self): alignments = copy.deepcopy(self.alignments) trajectory = copy.deepcopy(self.trajectory) trajectory.update({'json': alignments}) traj = one.alyx.rest('trajectories', 'update', id=self.prev_traj_id, data=trajectory) self.assertEqual(self.prev_traj_id, traj['id']) align_qc = AlignmentQC(self.probe_id, one=one, brain_atlas=brain_atlas, channels=False) align_qc.load_data(prev_alignments=traj['json'], xyz_picks=np.array(self.xyz_picks) / 1e6, cluster_chns=self.cluster_chns, depths=SITES_COORDINATES[:, 1], chn_coords=SITES_COORDINATES) align_qc.resolved = 0 align_qc.run(update=True, upload_alyx=True, upload_flatiron=False) _verify(self, alignment_resolved='qc', alignment_qc=0.952319, alignment_count=4, alignment_stored='2020-06-19T10:52:36_noam.roth', trajectory_created=True)
def test_03_alignments_disagree(self): alignments = { '2020-06-26T16:40:14_Karolina_Socha': self.alignments['2020-06-26T16:40:14_Karolina_Socha'], '2020-06-12T00:39:15_nate': self.alignments['2020-06-12T00:39:15_nate'] } trajectory = copy.deepcopy(self.trajectory) trajectory.update({'json': alignments}) traj = one.alyx.rest('trajectories', 'update', id=self.prev_traj_id, data=trajectory) traj_id = traj['id'] align_qc = AlignmentQC(self.probe_id, one=one, brain_atlas=brain_atlas, channels=False) insertion = one.alyx.rest('insertions', 'read', id=self.probe_id) align_qc.load_data(prev_alignments=traj['json'], xyz_picks=np.array(self.xyz_picks) / 1e6, cluster_chns=self.cluster_chns) align_qc.run(update=True, upload_alyx=True, upload_flatiron=False) insertion = one.alyx.rest('insertions', 'read', id=self.probe_id) assert (insertion['json']['qc'] == 'NOT_SET') assert (insertion['json']['extended_qc']['alignment_count'] == 2) assert (insertion['json']['extended_qc']['alignment_stored'] == '2020-06-26T16:40:14_Karolina_Socha') assert (insertion['json']['extended_qc']['alignment_resolved'] == 0) assert (insertion['json']['extended_qc']['alignment_qc'] < 0.8) traj = one.alyx.rest('trajectories', 'list', probe_id=self.probe_id, provenance='Ephys aligned histology track') assert (traj_id == traj[0]['id'])
def _04_alignments_agree(self): alignments = { '2020-06-19T10:52:36_noam.roth': self.alignments['2020-06-19T10:52:36_noam.roth'], '2020-06-12T00:39:15_nate': self.alignments['2020-06-12T00:39:15_nate'] } trajectory = copy.deepcopy(self.trajectory) trajectory.update({'json': alignments}) traj = one.alyx.rest('trajectories', 'update', id=self.prev_traj_id, data=trajectory) assert (self.prev_traj_id == traj['id']) align_qc = AlignmentQC(self.probe_id, one=one, brain_atlas=brain_atlas, channels=False) align_qc.load_data(cluster_chns=self.cluster_chns, depths=SITES_COORDINATES[:, 1], chn_coords=SITES_COORDINATES) align_qc.run(update=True, upload_alyx=True, upload_flatiron=False) _verify(self, alignment_resolved='qc', alignment_qc=0.952319, trajectory_created=False, alignment_count=2, alignment_stored='2020-06-19T10:52:36_noam.roth')
def _03_alignments_disagree(self): alignments = { '2020-06-26T16:40:14_Karolina_Socha': self.alignments['2020-06-26T16:40:14_Karolina_Socha'], '2020-06-12T00:39:15_nate': self.alignments['2020-06-12T00:39:15_nate'] } trajectory = copy.deepcopy(self.trajectory) trajectory.update({'json': alignments}) traj = one.alyx.rest('trajectories', 'update', id=self.prev_traj_id, data=trajectory) align_qc = AlignmentQC(self.probe_id, one=one, brain_atlas=brain_atlas, channels=False) align_qc.load_data(prev_alignments=traj['json'], xyz_picks=np.array(self.xyz_picks) / 1e6, cluster_chns=self.cluster_chns, depths=SITES_COORDINATES[:, 1], chn_coords=SITES_COORDINATES) align_qc.run(update=True, upload_alyx=True, upload_flatiron=False) _verify(self, alignment_qc=0.782216, alignment_resolved=False, alignment_count=2, alignment_stored='2020-06-26T16:40:14_Karolina_Socha', trajectory_created=False)
def test_01_no_alignments(self): align_qc = AlignmentQC(self.probe_id, one=one, brain_atlas=brain_atlas, channels=False) align_qc.run(update=True, upload_alyx=True, upload_flatiron=False) insertion = one.alyx.rest('insertions', 'read', id=self.probe_id) assert (insertion['json']['qc'] == 'NOT_SET') assert (len(insertion['json']['extended_qc']) == 0)
def _01_no_alignments(self): align_qc = AlignmentQC(self.probe_id, one=one, brain_atlas=brain_atlas, channels=False) align_qc.run(update=True, upload_alyx=True, upload_flatiron=False) insertion = one.alyx.get(f'/insertions/{self.probe_id}', clobber=True) self.assertEqual('NOT_SET', insertion['json']['qc']) self.assertTrue(len(insertion['json']['extended_qc']) == 0)
def test_02_one_alignment(self): alignments = {'2020-06-26T16:40:14_Karolina_Socha': self.alignments['2020-06-26T16:40:14_Karolina_Socha']} trajectory = copy.deepcopy(self.trajectory) trajectory.update({'json': alignments}) _ = one.alyx.rest('trajectories', 'create', data=trajectory) align_qc = AlignmentQC(self.probe_id, one=one, brain_atlas=brain_atlas, channels=False) align_qc.run(update=True, upload_alyx=True, upload_flatiron=False) insertion = one.alyx.rest('insertions', 'read', id=self.probe_id) assert (insertion['json']['qc'] == 'NOT_SET') assert (insertion['json']['extended_qc']['alignment_count'] == 1) assert (insertion['json']['extended_qc']['alignment_stored'] == '2020-06-26T16:40:14_Karolina_Socha') assert (insertion['json']['extended_qc']['alignment_resolved'] == 0)
def test_01_normal_computation(self): align_qc = AlignmentQC(self.probe_id, one=one, brain_atlas=brain_atlas, channels=False) align_qc.load_data(prev_alignments=self.traj['json'], xyz_picks=np.array(self.xyz_picks) / 1e6, cluster_chns=self.cluster_chns) align_qc.run(update=True, upload_alyx=True, upload_flatiron=False) insertion = one.alyx.rest('insertions', 'read', id=self.probe_id) assert (insertion['json']['qc'] == 'NOT_SET') assert (insertion['json']['extended_qc']['alignment_count'] == 3) assert (insertion['json']['extended_qc']['alignment_stored'] == '2020-09-28T15:57:25_mayo') assert (insertion['json']['extended_qc']['alignment_resolved'] == 0) assert (insertion['json']['extended_qc']['alignment_qc'] < 0.8) traj = one.alyx.rest('trajectories', 'list', probe_id=self.probe_id, provenance='Ephys aligned histology track') assert(self.prev_traj_id == traj[0]['id'])
def _01_normal_computation(self): align_qc = AlignmentQC(self.probe_id, one=one, brain_atlas=brain_atlas, channels=False) align_qc.load_data(prev_alignments=self.traj['json'], xyz_picks=np.array(self.xyz_picks) / 1e6, cluster_chns=self.cluster_chns, depths=SITES_COORDINATES[:, 1], chn_coords=SITES_COORDINATES) align_qc.run(update=True, upload_alyx=True, upload_flatiron=False) _verify(self, alignment_resolved=False, alignment_stored='2020-09-28T15:57:25_mayo', alignment_count=3, trajectory_created=False, alignment_qc=0.604081)
def _02_one_alignment(self): alignments = { '2020-06-26T16:40:14_Karolina_Socha': self.alignments['2020-06-26T16:40:14_Karolina_Socha'] } trajectory = copy.deepcopy(self.trajectory) trajectory.update({'json': alignments}) _ = one.alyx.rest('trajectories', 'create', data=trajectory) align_qc = AlignmentQC(self.probe_id, one=one, brain_atlas=brain_atlas, channels=False) align_qc.run(update=True, upload_alyx=True, upload_flatiron=False) _verify(self, alignment_count=1, alignment_stored='2020-06-26T16:40:14_Karolina_Socha', alignment_resolved=False)
def update_qc(self, upload_alyx=True, upload_flatiron=True): # if resolved just update the alignment_number align_qc = AlignmentQC(self.probe_id, one=self.one, brain_atlas=self.brain_atlas) align_qc.load_data(prev_alignments=self.alignments, xyz_picks=self.xyz_picks, depths=self.chn_depths, cluster_chns=self.cluster_chns) results = align_qc.run(update=True, upload_alyx=upload_alyx, upload_flatiron=upload_flatiron) align_qc.update_experimenter_evaluation(prev_alignments=self.alignments) self.resolved = results['alignment_resolved'] return self.resolved