Skip to content

pipeline.py

Device

Bases: dj.Lookup

Table for managing lab equipment.

Attributes:

Name Type Description
device varchar(32)

Device short name.

modality varchar(64)

Modality for which this device is used.

description varchar(256)

Optional. Description of device.

Source code in workflow_zstack/reference.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
@schema
class Device(dj.Lookup):
    """Table for managing lab equipment.

    Attributes:
        device ( varchar(32) ): Device short name.
        modality ( varchar(64) ): Modality for which this device is used.
        description ( varchar(256) ): Optional. Description of device.
    """

    definition = """
    device             : varchar(32)
    ---
    modality           : varchar(64)
    description=null   : varchar(256)
    """
    contents = [
        ["scanner1", "fluorescence microscope", ""],
    ]

get_volume_root_data_dir()

Return root directory for volumetric data in dj.config

Returns:

Name Type Description
path any

List of path(s) if available or None

Source code in workflow_zstack/paths.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
def get_volume_root_data_dir() -> List[str]:
    """Return root directory for volumetric data in dj.config

    Returns:
        path (any): List of path(s) if available or None
    """
    vol_root_dirs = dj.config.get("custom", {}).get("volume_root_data_dir", None)
    if not vol_root_dirs:
        return None
    elif not isinstance(vol_root_dirs, Sequence):
        return list(vol_root_dirs)
    else:
        return pathlib.Path(vol_root_dirs)

get_volume_tif_file(scan_key)

Retrieve the ScanImage file associated with a given Scan.

Parameters:

Name Type Description Default
scan_key dict

Primary key from Scan.

required

Returns:

Name Type Description
path str

Absolute path of the scan file.

Raises:

Type Description
FileNotFoundError

If the tiff file(s) are not found.

Source code in workflow_zstack/paths.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
def get_volume_tif_file(scan_key):
    """Retrieve the ScanImage file associated with a given Scan.

    Args:
        scan_key (dict): Primary key from Scan.

    Returns:
        path (str): Absolute path of the scan file.

    Raises:
        FileNotFoundError: If the tiff file(s) are not found.
    """
    # Folder structure: root / subject / session / .tif (raw)    
    sess_dir = find_full_path(
        get_volume_root_data_dir(),
        pathlib.Path((session.SessionDirectory & scan_key).fetch1("session_dir")),
    )

    tiff_filepaths = [fp.as_posix() for fp in sess_dir.rglob("*.tif")]

    if tiff_filepaths:
        assert len(tiff_filepaths) == 1, "More than 1 `.tif` file in file path. Please ensure the session directory contains only 1 image file."
        return tiff_filepaths[0]
    else:
        raise FileNotFoundError(f"No tiff file found in {sess_dir}")