lab.activate(db_prefix + "lab")

subject.activate(db_prefix + "subject", linking_module=__name__)

Session = session.Session
Experimenter = lab.User
session.activate(db_prefix + "session", linking_module=__name__)

# Activate "event" and "trial" schema ---------------------------------

trial.activate(db_prefix + "trial",
               db_prefix + "event",
               linking_module=__name__)

# ------------- Declare table Equipment for use in element_calcium_imaging -------------


@lab.schema
class Equipment(dj.Manual):
    definition = """
    scanner: varchar(32)
    """


# ------------- Activate "imaging" schema -------------

imaging.activate(db_prefix + "imaging",
                 db_prefix + "scan",
                 linking_module=__name__)
Beispiel #2
0
from .paths import (get_imaging_root_data_dir, get_scan_image_files,
                    get_scan_box_files)

if 'custom' not in dj.config:
    dj.config['custom'] = {}

db_prefix = dj.config['custom'].get('database.prefix', '')

# ------------- Activate "lab", "subject", "session" schema -------------

lab.activate(db_prefix + 'lab')

subject.activate(db_prefix + 'subject', linking_module=__name__)

session.activate(db_prefix + 'session', linking_module=__name__)

# ------------- Declare table Equipment for use in element_calcium_imaging -------------


@lab.schema
class Equipment(dj.Manual):
    definition = """
    scanner: varchar(32) 
    """


# ------------- Activate "imaging" schema -------------
imaging.activate(db_prefix + 'imaging',
                 db_prefix + 'scan',
                 linking_module=__name__)
    bucket_scan_dir = (imaging.FieldOfView & sess_key & {
        'fov': processing_task_key['scan_id']
    }).fetch1('relative_fov_directory')

    if bucket_scan_dir[0] == '/':
        bucket_scan_dir = bucket_scan_dir[1:]

    data_dir = get_imaging_root_data_dir()
    sess_dir = data_dir / bucket_scan_dir / 'suite2p'
    relative_suite2p_dir = (pathlib.Path(bucket_scan_dir) /
                            'suite2p').as_posix()

    # Check if suite2p dir exists
    if not sess_dir.exists():
        raise FileNotFoundError(f'Session directory not found ({scan_dir})')

    # Check if ops.npy is inside suite2pdir
    suite2p_dirs = set([fp.parent.parent for fp in sess_dir.rglob('*ops.npy')])
    if len(suite2p_dirs) != 1:
        raise FileNotFoundError(
            f'Error searching for Suite2p output directory in {scan_dir} - Found {suite2p_dirs}'
        )

    return relative_suite2p_dir


# ------------- Activate "imaging" schema -------------
imaging_element.activate(imaging_schema_name,
                         scan_schema_name,
                         linking_module=__name__)