Skip to content

Commit

Permalink
Merge pull request #1 from kushalbakshi/tutorial-fix
Browse files Browse the repository at this point in the history
Updates to the tutorial and devcontainer
  • Loading branch information
MilagrosMarin authored Jan 29, 2024
2 parents 5e9c692 + 6523c15 commit cee790c
Show file tree
Hide file tree
Showing 8 changed files with 3,204 additions and 754 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ENV DJ_HOST fakeservices.datajoint.io
ENV DJ_USER root
ENV DJ_PASS simple

ENV DATA_MOUNTPOINT /workspaces/element-electrode-localization/example_data
ENV EPHYS_ROOT_DATA_DIR /workspaces/element-electrode-localization/example_data
ENV DATABASE_PREFIX neuro_

USER vscode
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"remoteEnv": {
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
},
"onCreateCommand": "mkdir -p ${DATA_MOUNTPOINT} && pip install -e .",
"postStartCommand": "docker volume prune -f ",
"onCreateCommand": "mkdir -p ${EPHYS_ROOT_DATA_DIR} && pip install -e .",
"postStartCommand": "docker volume prune -f && s3fs ${DJ_PUBLIC_S3_LOCATION} ${EPHYS_ROOT_DATA_DIR} -o nonempty,multipart_size=530,endpoint=us-east-1,url=http://s3.amazonaws.com,public_bucket=1",
"hostRequirements": {
"cpus": 4,
"memory": "8gb",
Expand Down
2 changes: 2 additions & 0 deletions .devcontainer/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ services:
dockerfile: ./.devcontainer/Dockerfile
extra_hosts:
- fakeservices.datajoint.io:127.0.0.1
environment:
- DJ_PUBLIC_S3_LOCATION=djhub.vathes.datapub.elements:/workflow-array-ephys-benchmark/v2
devices:
- /dev/fuse
cap_add:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ dj_local_c*.json
temp*
*nwb

#mkdocs documentation
# mkdocs documentation
site
docs/src/tutorials/*ipynb

# Codespaces
example_data/*
1 change: 1 addition & 0 deletions element_electrode_localization/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Package metadata."""

__version__ = "0.2.0"
2 changes: 1 addition & 1 deletion images/flowchart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,895 changes: 3,151 additions & 744 deletions notebooks/tutorial.ipynb

Large diffs are not rendered by default.

47 changes: 42 additions & 5 deletions notebooks/tutorial_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import datajoint as dj
from element_animal import subject
from element_animal.subject import Subject
from element_interface.utils import find_full_path
from element_array_ephys import probe, ephys_acute as ephys
from element_lab import lab
from element_lab.lab import Lab, Location, Project, Protocol, Source, User
Expand All @@ -20,12 +21,27 @@
"DATABASE_PREFIX", dj.config["custom"].get("database.prefix", "")
)

if "custom" not in dj.config:
dj.config["custom"] = {}
dj.config["custom"]["ephys_root_data_dir"] = os.getenv(
"EPHYS_ROOT_DATA_DIR", dj.config["custom"].get("ephys_root_data_dir", "")
)

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


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


@lab.schema
class SkullReference(dj.Lookup):
definition = """
Expand All @@ -44,8 +60,29 @@ class SkullReference(dj.Lookup):

ephys.activate(db_prefix + "ephys", db_prefix + "probe", linking_module=__name__)
ProbeInsertion = ephys.ProbeInsertion

electrode_localization.activate(
db_prefix + "electrode_localization",
db_prefix + "coordinate_framework",
linking_module=__name__,
db_prefix + "electrode_localization", db_prefix + "ccf", linking_module=__name__
)

ccf_id = 0 # Atlas ID
voxel_resolution = 100

nrrd_filepath = find_full_path(
get_ephys_root_data_dir(), f"annotation_{voxel_resolution}.nrrd"
)
ontology_csv_filepath = find_full_path(get_ephys_root_data_dir(), "query.csv")


if (
not (coordinate_framework.CCF & {"ccf_id": ccf_id})
and nrrd_filepath.exists()
and ontology_csv_filepath.exists()
):
coordinate_framework.load_ccf_annotation(
ccf_id=ccf_id,
version_name="ccf_2017",
voxel_resolution=voxel_resolution,
nrrd_filepath=nrrd_filepath,
ontology_csv_filepath=ontology_csv_filepath,
)

0 comments on commit cee790c

Please sign in to comment.