• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

int-brain-lab / iblrig / 9032957364

10 May 2024 01:25PM UTC coverage: 48.538% (+1.7%) from 46.79%
9032957364

Pull #643

github

74d2ec
web-flow
Merge aebf2c9af into ec2d8e4fe
Pull Request #643: 8.19.0

377 of 1074 new or added lines in 38 files covered. (35.1%)

977 existing lines in 19 files now uncovered.

3253 of 6702 relevant lines covered (48.54%)

0.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.44
/iblrig/ephys.py
1
import argparse
2✔
2
import string
2✔
3

4
import numpy as np
2✔
5

6
from iblatlas import atlas
2✔
7
from iblrig.base_tasks import EmptySession
2✔
8
from iblrig.transfer_experiments import EphysCopier
2✔
9
from iblutil.util import setup_logger
2✔
10

11

12
def prepare_ephys_session_cmd():
2✔
NEW
13
    parser = argparse.ArgumentParser(prog='start_video_session', description='Prepare video PC for video recording session.')
×
14
    parser.add_argument('subject_name', help='name of subject')
×
15
    parser.add_argument('nprobes', help='number of probes', type=int, default=2)
×
16
    parser.add_argument('--debug', action='store_true', help='enable debugging mode')
×
17
    args = parser.parse_args()
×
18
    setup_logger(name='iblrig', level='DEBUG' if args.debug else 'INFO')
×
19
    prepare_ephys_session(args.subject_name, args.nprobes)
×
20

21

22
def prepare_ephys_session(subject_name: str, nprobes: int = 2):
2✔
23
    """
24
    Setup electrophysiology recordings.
25

26
    Parameters
27
    ----------
28
    subject_name : str
29
        A subject name.
30
    nprobes : int
31
        Number of probes to be used
32
    """
33
    # Initialize a session for paths and settings
34
    session = EmptySession(subject=subject_name, interactive=False)
×
35
    session_path = session.paths.SESSION_FOLDER
×
NEW
36
    copier = EphysCopier(session_path=session_path, remote_subjects_folder=session.paths.REMOTE_SUBJECT_FOLDER)
×
37
    copier.initialize_experiment(nprobes=nprobes)
×
38

39

40
def neuropixel24_micromanipulator_coordinates(ref_shank, pname, ba=None, shank_spacings_um=(0, 200, 400, 600)):
2✔
41
    """
42
    Provided the micro-manipulator coordinates of the first shank, this function
43
    returns the relative coordinates of all shanks, labeled as probe01a, probe01b, etc.
44
    :param ref_shank: dictionary with keys x, y, z, phi, theta, depth, roll
45
    example: {'x': 2594.2, 'y': -3123.7, 'z': -711, 'phi': 0 + 15, 'theta': 15, 'depth': 1250.4, 'roll': 0}
46
    :param pname: str
47
    :param ba: brain atlas object
48
    :param shank_spacings_um: list of shank spacings in micrometers
49
    :return:
50
    """
51
    # this only works if the roll is 0, ie. the probe is facing upwards
52
    assert ref_shank['roll'] == 0
2✔
53
    ba = atlas.NeedlesAtlas() if ba is None else ba
2✔
54
    trajectories = {}
2✔
55
    for i, d in enumerate(shank_spacings_um):
2✔
56
        x = ref_shank['x'] + np.sin(ref_shank['phi'] / 180 * np.pi) * d
2✔
57
        y = ref_shank['y'] - np.cos(ref_shank['phi'] / 180 * np.pi) * d
2✔
58
        shank = {
2✔
59
            'x': x,
60
            'y': y,
61
            'z': np.NaN,
62
            'phi': ref_shank['phi'],
63
            'theta': ref_shank['theta'],
64
            'depth': ref_shank['depth'],
65
            'roll': 0,
66
        }
67
        insertion = atlas.Insertion.from_dict(shank, brain_atlas=ba)
2✔
68
        xyz_entry = atlas.Insertion.get_brain_entry(insertion.trajectory, ba)
2✔
69
        if i == 0:
2✔
70
            xyz_ref = xyz_entry
2✔
71
        shank['z'] = xyz_entry[2] * 1e6
2✔
72
        shank['depth'] = ref_shank['depth'] + (xyz_entry[2] - xyz_ref[2]) * 1e6
2✔
73
        trajectories[f'{pname}{string.ascii_lowercase[i]}'] = shank
2✔
74
    return trajectories
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc