Skip to content

Commit

Permalink
Revert "Remove pipeline script"
Browse files Browse the repository at this point in the history
This reverts commit bada53e.
  • Loading branch information
kabilar committed Aug 8, 2023
1 parent 402d87d commit 4e5e3d3
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions notebooks/tutorial_pipeline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import datajoint as dj
from element_animal import subject
from element_animal.subject import Subject
from element_calcium_imaging import imaging, scan, imaging_report, db_prefix, plotting
from element_lab import lab
from element_lab.lab import Lab, Location, Project, Protocol, Source, User
from element_lab.lab import Device as Equipment
from element_lab.lab import User as Experimenter
from element_session import session_with_datetime as session
from element_session.session_with_datetime import Session
import element_interface
import pathlib


# Declare functions for retrieving data
def get_imaging_root_data_dir():
"""Retrieve imaging root data directory."""
imaging_root_dirs = dj.config.get("custom", {}).get("imaging_root_data_dir", None)
if not imaging_root_dirs:
return None
elif isinstance(imaging_root_dirs, (str, pathlib.Path)):
return [imaging_root_dirs]
elif isinstance(imaging_root_dirs, list):
return imaging_root_dirs
else:
raise TypeError("`imaging_root_data_dir` must be a string, pathlib, or list")


def get_image_files(scan_key, file_type: str):
"""Retrieve the list of absolute paths associated with a given Scan."""
# Folder structure: root / subject / session / .tif or .sbx or .nd2
session_dir = element_interface.utils.find_full_path(
get_imaging_root_data_dir(),
(session.SessionDirectory & scan_key).fetch1("session_dir"),
)

filepaths = [fp.as_posix() for fp in session_dir.glob(file_type)]

if not filepaths:
raise FileNotFoundError(f"No {file_type} file found in {session_dir}")
return filepaths


# Activate schemas
lab.activate(db_prefix + "lab")
subject.activate(db_prefix + "subject", linking_module=__name__)
session.activate(db_prefix + "session", linking_module=__name__)
imaging.activate(db_prefix + "imaging", db_prefix + "scan", linking_module=__name__)

0 comments on commit 4e5e3d3

Please sign in to comment.