Skip to content

Commit 4e5e3d3

Browse files
committed
Revert "Remove pipeline script"
This reverts commit bada53e.
1 parent 402d87d commit 4e5e3d3

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

notebooks/tutorial_pipeline.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import datajoint as dj
2+
from element_animal import subject
3+
from element_animal.subject import Subject
4+
from element_calcium_imaging import imaging, scan, imaging_report, db_prefix, plotting
5+
from element_lab import lab
6+
from element_lab.lab import Lab, Location, Project, Protocol, Source, User
7+
from element_lab.lab import Device as Equipment
8+
from element_lab.lab import User as Experimenter
9+
from element_session import session_with_datetime as session
10+
from element_session.session_with_datetime import Session
11+
import element_interface
12+
import pathlib
13+
14+
15+
# Declare functions for retrieving data
16+
def get_imaging_root_data_dir():
17+
"""Retrieve imaging root data directory."""
18+
imaging_root_dirs = dj.config.get("custom", {}).get("imaging_root_data_dir", None)
19+
if not imaging_root_dirs:
20+
return None
21+
elif isinstance(imaging_root_dirs, (str, pathlib.Path)):
22+
return [imaging_root_dirs]
23+
elif isinstance(imaging_root_dirs, list):
24+
return imaging_root_dirs
25+
else:
26+
raise TypeError("`imaging_root_data_dir` must be a string, pathlib, or list")
27+
28+
29+
def get_image_files(scan_key, file_type: str):
30+
"""Retrieve the list of absolute paths associated with a given Scan."""
31+
# Folder structure: root / subject / session / .tif or .sbx or .nd2
32+
session_dir = element_interface.utils.find_full_path(
33+
get_imaging_root_data_dir(),
34+
(session.SessionDirectory & scan_key).fetch1("session_dir"),
35+
)
36+
37+
filepaths = [fp.as_posix() for fp in session_dir.glob(file_type)]
38+
39+
if not filepaths:
40+
raise FileNotFoundError(f"No {file_type} file found in {session_dir}")
41+
return filepaths
42+
43+
44+
# Activate schemas
45+
lab.activate(db_prefix + "lab")
46+
subject.activate(db_prefix + "subject", linking_module=__name__)
47+
session.activate(db_prefix + "session", linking_module=__name__)
48+
imaging.activate(db_prefix + "imaging", db_prefix + "scan", linking_module=__name__)

0 commit comments

Comments
 (0)