Skip to content

localization.py

Load CCF files.

When imported, checks to see that CCF (nrrd and query.csv) files in the ephys_root_data_dir have been loaded into element_electrode_localization.coordinate_framework. Default voxel resolution is 100. To load other resolutions, please modify this script.

get_electrode_localization_dir(probe_insertion_key)

Return root directory of localization data for a given probe

Parameters:

Name Type Description Default
probe_insertion_key dict

key uniquely identifying one ephys.EphysRecording

required

Returns:

Name Type Description
path str

Full path to localization data for either SpikeGLX or OpenEphys

Source code in workflow_array_ephys/paths.py
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def get_electrode_localization_dir(probe_insertion_key: dict) -> str:
    """Return root directory of localization data for a given probe

    Args:
        probe_insertion_key (dict): key uniquely identifying one ephys.EphysRecording

    Returns:
        path (str): Full path to localization data for either SpikeGLX or OpenEphys
    """
    from .pipeline import ephys

    acq_software = (ephys.EphysRecording & probe_insertion_key).fetch1("acq_software")

    if acq_software == "SpikeGLX":
        spikeglx_meta_filepath = pathlib.Path(
            (
                ephys.EphysRecording.EphysFile
                & probe_insertion_key
                & 'file_path LIKE "%.ap.meta"'
            ).fetch1("file_path")
        )
        probe_dir = element_interface.utils.find_full_path(
            get_ephys_root_data_dir(), spikeglx_meta_filepath.parent
        )
    elif acq_software == "Open Ephys":
        probe_path = (ephys.EphysRecording.EphysFile & probe_insertion_key).fetch1(
            "file_path"
        )
        probe_dir = element_interface.utils.find_full_path(
            get_ephys_root_data_dir(), probe_path
        )

    return probe_dir

get_ephys_root_data_dir()

Return root directory for ephys from 'ephys_root_data_dir' in dj.config

Returns:

Name Type Description
path any

List of path(s) if available or None

Source code in workflow_array_ephys/paths.py
 6
 7
 8
 9
10
11
12
13
14
def get_ephys_root_data_dir():
    """Return root directory for ephys from 'ephys_root_data_dir' in dj.config

    Returns:
        path (any): List of path(s) if available or None
    """

    data_dir = dj.config.get("custom", {}).get("ephys_root_data_dir", None)
    return pathlib.Path(data_dir) if data_dir else None

get_session_directory(session_key)

Return relative path from SessionDirectory table given key

Parameters:

Name Type Description Default
session_key dict

Key uniquely identifying a session

required

Returns:

Name Type Description
path str

Relative path of session directory

Source code in workflow_array_ephys/paths.py
27
28
29
30
31
32
33
34
35
36
37
38
def get_session_directory(session_key: dict) -> str:
    """Return relative path from SessionDirectory table given key

    Args:
        session_key (dict): Key uniquely identifying a session

    Returns:
        path (str): Relative path of session directory
    """
    from .pipeline import session

    return (session.SessionDirectory & session_key).fetch1("session_dir")