Skip to content

Commit 652c8c8

Browse files
authored
Merge pull request #1 from ttngu207/main
`element-session` design and packaging (to be used in the workflows)
2 parents 32d31a2 + 0a82f19 commit 652c8c8

File tree

9 files changed

+228
-3
lines changed

9 files changed

+228
-3
lines changed

.gitignore

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
.idea/
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.coverage
43+
.coverage.*
44+
.cache
45+
nosetests.xml
46+
coverage.xml
47+
*.cover
48+
.hypothesis/
49+
50+
# Translations
51+
*.mo
52+
*.pot
53+
54+
# Django stuff:
55+
*.log
56+
local_settings.py
57+
58+
# Flask stuff:
59+
instance/
60+
.webassets-cache
61+
62+
# Scrapy stuff:
63+
.scrapy
64+
scratchpaper.*
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# Jupyter Notebook
73+
.ipynb_checkpoints
74+
75+
# pyenv
76+
.python-version
77+
78+
# celery beat schedule file
79+
celerybeat-schedule
80+
81+
# SageMath parsed files
82+
*.sage.py
83+
84+
# dotenv
85+
./.env
86+
87+
# virtualenv
88+
.venv
89+
venv/
90+
ENV/
91+
92+
# Spyder project settings
93+
.spyderproject
94+
.spyproject
95+
96+
# Rope project settings
97+
.ropeproject
98+
99+
# mkdocs documentation
100+
/site
101+
102+
# mypy
103+
.mypy_cache/
104+
105+
# datajoint
106+
dj_local_conf.json
107+
dj_local_conf_old.json
108+
109+
# emacs
110+
**/*~
111+
**/#*#
112+
**/.#*

Background.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Session Element
2+
3+
## Description of modality, user population
4+
5+
Session information is part of most data modalities.
6+
This is a minimal schema with a few number of tables describing the experiment session (date and time, experimenter, subject reference, experiment rig, aims, and notes),
7+
the project in which the sessions may belong to (project description, DOI, keywords, etc.), data directory for each session.
8+
9+
## Precursor projects and interviews
10+
11+
All DataJoint pipelines have some form of a session schema or tables.
12+
The session table is typically in the upstream part of the pipeline, referencing the subject and serves as a common node for other modalities to connect to and expand downstream (e.g. ephys, imaging, video tracking, behavioral events, optogenetic perturbation, etc.).
13+
14+
## Development
15+
We developed the Session Element under https://github.com/datajoint/element-session. This schema is validated as part of complete workflows in the specific modalities.

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Contribution Guidelines
2+
3+
This project follows the [DataJoint Contribution Guidelines](https://docs.datajoint.io/python/community/02-Contribute.html). Please reference the link for more full details.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 DataJoint
3+
Copyright (c) 2021 DataJoint NEURO
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,20 @@
1-
# element-session
2-
DataJoint Element for Session - NIH U24
1+
# DataJoint Element - Session
2+
3+
DataJoint element for session management - U24 effort
4+
5+
+ `element-session` features a DataJoint pipeline design for session management.
6+
7+
+ `element-session` is not a complete workflow by itself, but rather a modular design of tables and dependencies.
8+
9+
+ `element-session` can be flexibly attached to any DataJoint workflow.
10+
11+
See [Background](Background.md) for the background information and development timeline.
12+
13+
## Element usage
14+
15+
+ See the [workflow-calcium-imaging](https://github.com/datajoint/workflow-calcium-imaging)
16+
and [workflow-array-ephys](https://github.com/datajoint/workflow-array-ephys) repositories for example usages of `element-session`.
17+
18+
+ See the [datajoint-elements](https://github.com/datajoint/datajoint-elements) repository for a detailed description of the DataJoint elements and workflows.
19+
20+

element_session/__init__.py

Whitespace-only changes.

element_session/session.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import datajoint as dj
2+
import importlib
3+
import inspect
4+
5+
schema = dj.schema()
6+
7+
8+
def activate(schema_name, create_schema=True, create_tables=True, linking_module=None):
9+
"""
10+
activate(schema_name, create_schema=True, create_tables=True, linking_module=None)
11+
:param schema_name: schema name on the database server to activate the `session` element
12+
:param create_schema: when True (default), create schema in the database if it does not yet exist.
13+
:param create_tables: when True (default), create tables in the database if they do not yet exist.
14+
:param linking_module: a module name or a module containing the
15+
required dependencies to activate the `session` element:
16+
Upstream tables:
17+
+ Subject: the subject for which a particular experimental session is associated with
18+
+ Project: the project for which experimental sessions are associated with
19+
"""
20+
if isinstance(linking_module, str):
21+
linking_module = importlib.import_module(linking_module)
22+
assert inspect.ismodule(linking_module),\
23+
"The argument 'dependency' must be a module's name or a module"
24+
25+
schema.activate(schema_name, create_schema=create_schema,
26+
create_tables=create_tables, add_objects=linking_module.__dict__)
27+
28+
29+
@schema
30+
class Session(dj.Manual):
31+
definition = """
32+
-> Subject
33+
session_datetime: datetime(3)
34+
"""
35+
36+
37+
@schema
38+
class SessionDirectory(dj.Manual):
39+
definition = """
40+
-> Session
41+
---
42+
session_dir: varchar(256) # Path to the data directory for a particular session
43+
"""
44+
45+
46+
@schema
47+
class ProjectSession(dj.Manual):
48+
definition = """
49+
-> Project
50+
-> Session
51+
"""

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
datajoint>=0.13.dev7

setup.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from setuptools import setup, find_packages
2+
from os import path
3+
4+
here = path.abspath(path.dirname(__file__))
5+
6+
long_description = """"
7+
DataJoint Element for Session Management
8+
"""
9+
10+
with open(path.join(here, 'requirements.txt')) as f:
11+
requirements = f.read().splitlines()
12+
13+
setup(
14+
name='element-session',
15+
version='0.0.1',
16+
description="DataJoint Element for Session Management",
17+
long_description=long_description,
18+
author='DataJoint NEURO',
19+
author_email='[email protected]',
20+
license='MIT',
21+
url='https://github.com/datajoint/element-session',
22+
keywords='neuroscience session-management datajoint',
23+
packages=find_packages(exclude=['contrib', 'docs', 'tests*']),
24+
install_requires=requirements,
25+
)

0 commit comments

Comments
 (0)