Example #1
0
 def test_registration_session(self):
     behavior_path = self.session_path.joinpath('raw_behavior_data')
     behavior_path.mkdir()
     settings_file = behavior_path.joinpath('_iblrig_taskSettings.raw.json')
     with open(settings_file, 'w') as fid:
         json.dump(MOCK_SESSION_SETTINGS, fid)
     rc = registration.RegistrationClient(one=one)
     rc.register_session(self.session_path)
     eid = one.search(subjects=SUBJECT, date_range=['2018-04-01', '2018-04-01'])[0]
     datasets = one.alyx.rest('datasets', 'list', session=eid)
     for ds in datasets:
         self.assertTrue(ds['hash'] is not None)
         self.assertTrue(ds['file_size'] is not None)
         self.assertTrue(ds['version'] == version.ibllib())
     # checks the procedure of the session
     ses_info = one.alyx.rest('sessions', 'read', id=eid)
     self.assertTrue(ses_info['procedures'] == ['Ephys recording with acute probe(s)'])
     one.alyx.rest('sessions', 'delete', id=eid)
     # re-register the session as behaviour this time
     MOCK_SESSION_SETTINGS['PYBPOD_PROTOCOL'] = '_iblrig_tasks_trainingChoiceWorld6.3.1'
     with open(settings_file, 'w') as fid:
         json.dump(MOCK_SESSION_SETTINGS, fid)
     rc.register_session(self.session_path)
     eid = one.search(subjects=SUBJECT, date_range=['2018-04-01', '2018-04-01'])[0]
     ses_info = one.alyx.rest('sessions', 'read', id=eid)
     self.assertTrue(ses_info['procedures'] == ['Behavior training/tasks'])
Example #2
0
 def setUp(self) -> None:
     # makes sure tests start without session created
     eid = one.search(subjects=SUBJECT, date_range='2018-04-01')
     for ei in eid:
         one.alyx.rest('sessions', 'delete', id=ei)
     self.td = tempfile.TemporaryDirectory()
     self.session_path = Path(self.td.name).joinpath(SUBJECT, '2018-04-01', '002')
     self.alf_path = self.session_path.joinpath('alf')
     self.alf_path.mkdir(parents=True)
     np.save(self.alf_path.joinpath('spikes.times.npy'), np.random.random(500))
     np.save(self.alf_path.joinpath('spikes.amps.npy'), np.random.random(500))
 def test_registration_session(self):
     settings = {
         'SESSION_DATE':
         '2018-04-01',
         'SESSION_DATETIME':
         '2018-04-01T12:48:26.795526',
         'PYBPOD_CREATOR':
         ['test_user', 'f092c2d5-c98a-45a1-be7c-df05f129a93c', 'local'],
         'SESSION_NUMBER':
         '002',
         'SUBJECT_NAME':
         'clns0730',
         'PYBPOD_BOARD':
         '_iblrig_mainenlab_behavior_1',
         'PYBPOD_PROTOCOL':
         '_iblrig_tasks_ephysChoiceWorld',
         'IBLRIG_VERSION_TAG':
         '5.4.1',
         'SUBJECT_WEIGHT':
         22,
     }
     with tempfile.TemporaryDirectory() as td:
         # creates the local session
         session_path = Path(td).joinpath('clns0730', '2018-04-01', '002')
         alf_path = session_path.joinpath('alf')
         alf_path.mkdir(parents=True)
         alf_path.joinpath('spikes.times.npy').touch()
         alf_path.joinpath('spikes.amps.npy').touch()
         behavior_path = session_path.joinpath('raw_behavior_data')
         behavior_path.mkdir()
         settings_file = behavior_path.joinpath(
             '_iblrig_taskSettings.raw.json')
         with open(settings_file, 'w') as fid:
             json.dump(settings, fid)
         rc = registration.RegistrationClient(one=one)
         rc.register_session(session_path)
         eid = one.search(subjects='clns0730',
                          date_range=['2018-04-01', '2018-04-01'])[0]
         datasets = one.alyx.get(
             '/datasets?subject=clns0730&date=2018-04-01')
         for ds in datasets:
             self.assertTrue(ds['hash'] is not None)
             self.assertTrue(ds['file_size'] is not None)
             self.assertTrue(ds['version'] == version.ibllib())
         one.alyx.rest('sessions', 'delete', id=eid)