diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..2ebb270 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,59 @@ +default_stages: [commit, push] +exclude: (^.github/|^docs/|^images/|^notebooks/py_scripts/|^tests/) +# Current tests/__init__ violates many flake8. Excluding pending change to conftest + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files # prevent giant files from being committed + - id: requirements-txt-fixer + - id: mixed-line-ending + args: ["--fix=lf"] + description: Forces to replace line ending by the UNIX 'lf' character. + + # black + - repo: https://github.com/psf/black + rev: 22.12.0 + hooks: + - id: black + - id: black-jupyter + args: + - --line-length=88 + + # isort + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + args: ["--profile", "black"] + description: Sorts imports in an alphabetical order + + # flake8 + - repo: https://github.com/pycqa/flake8 + rev: 4.0.1 + hooks: + - id: flake8 + args: # arguments to configure flake8 + # making isort line length compatible with black + - "--max-line-length=88" + - "--max-complexity=18" + - "--select=B,C,E,F,W,T4,B9" + + # these are errors that will be ignored by flake8 + # https://www.flake8rules.com/rules/{code}.html + - "--ignore=E203,E501,W503,W605,E402" + # E203 - Colons should not have any space before them. + # Needed for list indexing + # E501 - Line lengths are recommended to be no greater than 79 characters. + # Needed as we conform to 88 + # W503 - Line breaks should occur after the binary operator. + # Needed because not compatible with black + # W605 - a backslash-character pair that is not a valid escape sequence now + # generates a DeprecationWarning. This will eventually become a SyntaxError. + # Needed because we use \d as an escape sequence + # E402 - Place module level import at the top. + # Needed to prevent circular import error diff --git a/README.md b/README.md index 86393d6..edf021e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # DataJoint Workflow - Calcium Imaging Workflow for calcium imaging data acquired with -[ScanImage](http://scanimage.vidriotechnologies.com), +[ScanImage](http://scanimage.vidriotechnologies.com), [Scanbox](https://scanbox.org), or `Nikon NIS` software and processed with [Suite2p](https://github.com/MouseLand/suite2p) or [CaImAn](https://github.com/flatironinstitute/CaImAn). diff --git a/docker/Dockerfile.dev b/docker/Dockerfile.dev index a1c7b14..5638451 100644 --- a/docker/Dockerfile.dev +++ b/docker/Dockerfile.dev @@ -6,10 +6,10 @@ COPY ./workflow-calcium-imaging/docker/apt_requirements.txt /tmp/ RUN /entrypoint.sh echo "Installed dependencies." # Install Caiman -RUN git clone --branch master https://github.com/datajoint-company/CaImAn +RUN git clone --branch master https://github.com/datajoint-company/CaImAn WORKDIR /main/CaImAn RUN conda install -n base -c conda-forge -y mamba -RUN /bin/bash -c 'mamba env update --n base --file environment.yml' +RUN /bin/bash -c 'mamba env update --n base --file environment.yml' # Suite2p requires np.__version__ == 1.21 RUN pip install numpy==1.21 RUN pip install . @@ -42,4 +42,4 @@ RUN pip install -r /main/workflow-calcium-imaging/requirements_test.txt WORKDIR /main/workflow-calcium-imaging -ENTRYPOINT ["tail", "-f", "/dev/null"] \ No newline at end of file +ENTRYPOINT ["tail", "-f", "/dev/null"] diff --git a/docker/Dockerfile.test b/docker/Dockerfile.test index 8f1cf4a..c95504e 100644 --- a/docker/Dockerfile.test +++ b/docker/Dockerfile.test @@ -6,10 +6,10 @@ COPY ./workflow-calcium-imaging/docker/apt_requirements.txt /tmp/ RUN /entrypoint.sh echo "Installed dependencies." # Install Caiman -RUN git clone --branch master https://github.com/datajoint-company/CaImAn +RUN git clone --branch master https://github.com/datajoint-company/CaImAn WORKDIR /main/CaImAn RUN conda install -n base -c conda-forge -y mamba -RUN /bin/bash -c 'mamba env update --n base --file environment.yml' +RUN /bin/bash -c 'mamba env update --n base --file environment.yml' # Suite2p requires np.__version__ == 1.21 RUN pip install numpy==1.21 RUN pip install . @@ -54,4 +54,4 @@ RUN rm -f /main/workflow-calcium-imaging/dj_local_conf.json RUN pip install /main/workflow-calcium-imaging RUN pip install -r /main/workflow-calcium-imaging/requirements_test.txt -WORKDIR /main/workflow-calcium-imaging \ No newline at end of file +WORKDIR /main/workflow-calcium-imaging diff --git a/docker/apt_requirements.txt b/docker/apt_requirements.txt index 3766711..1d4204c 100644 --- a/docker/apt_requirements.txt +++ b/docker/apt_requirements.txt @@ -1,8 +1,8 @@ -git -gcc -g++ ffmpeg +g++ +gcc +git +libhdf5-dev libsm6 libxext6 -libhdf5-dev pkg-config diff --git a/notebooks/00-data-download-optional.ipynb b/notebooks/00-data-download-optional.ipynb index d1edc41..2e40a25 100644 --- a/notebooks/00-data-download-optional.ipynb +++ b/notebooks/00-data-download-optional.ipynb @@ -42,6 +42,7 @@ "source": [ "import os\n", "import djarchive_client\n", + "\n", "client = djarchive_client.client()" ] }, @@ -90,7 +91,7 @@ "metadata": {}, "outputs": [], "source": [ - "mkdir /tmp/example_data" + "mkdir / tmp / example_data" ] }, { @@ -107,7 +108,8 @@ "outputs": [], "source": [ "from workflow_calcium_imaging import version\n", - "revision = version.__version__.replace('.', '_')\n", + "\n", + "revision = version.__version__.replace(\".\", \"_\")\n", "revision" ] }, @@ -124,7 +126,11 @@ "metadata": {}, "outputs": [], "source": [ - "client.download('workflow-calcium-imaging-test-set', target_directory='/tmp/example_data', revision=revision)" + "client.download(\n", + " \"workflow-calcium-imaging-test-set\",\n", + " target_directory=\"/tmp/example_data\",\n", + " revision=revision,\n", + ")" ] }, { diff --git a/notebooks/01-configure.ipynb b/notebooks/01-configure.ipynb index 3925b87..2c97cb2 100644 --- a/notebooks/01-configure.ipynb +++ b/notebooks/01-configure.ipynb @@ -20,7 +20,9 @@ "outputs": [], "source": [ "import os\n", - "if os.path.basename(os.getcwd()) == \"notebooks\": os.chdir(\"..\")\n", + "\n", + "if os.path.basename(os.getcwd()) == \"notebooks\":\n", + " os.chdir(\"..\")\n", "import datajoint as dj" ] }, @@ -49,7 +51,8 @@ "outputs": [], "source": [ "import getpass\n", - "dj.config[\"database.host\"] = \"{YOUR_HOST}\" # CodeBook users should omit this\n", + "\n", + "dj.config[\"database.host\"] = \"{YOUR_HOST}\" # CodeBook users should omit this\n", "dj.config[\"database.user\"] = \"{YOUR_USERNAME}\"\n", "dj.config[\"database.password\"] = getpass.getpass() # enter the password securely" ] @@ -145,8 +148,8 @@ "metadata": {}, "outputs": [], "source": [ - "dj.config['custom']['imaging_root_data_dir'] = '/tmp/example_data' # local download\n", - "dj.config['custom']['imaging_root_data_dir'] = '/home/inbox/0_1_0a2/' # on CodeBook" + "dj.config[\"custom\"][\"imaging_root_data_dir\"] = \"/tmp/example_data\" # local download\n", + "dj.config[\"custom\"][\"imaging_root_data_dir\"] = \"/home/inbox/0_1_0a2/\" # on CodeBook" ] }, { diff --git a/notebooks/02-workflow-structure-optional.ipynb b/notebooks/02-workflow-structure-optional.ipynb index 605bc06..0917e92 100644 --- a/notebooks/02-workflow-structure-optional.ipynb +++ b/notebooks/02-workflow-structure-optional.ipynb @@ -24,7 +24,9 @@ "outputs": [], "source": [ "import os\n", - "if os.path.basename(os.getcwd()) == \"notebooks\": os.chdir(\"..\")" + "\n", + "if os.path.basename(os.getcwd()) == \"notebooks\":\n", + " os.chdir(\"..\")" ] }, { diff --git a/notebooks/03-process.ipynb b/notebooks/03-process.ipynb index fafaeaa..1e607b3 100644 --- a/notebooks/03-process.ipynb +++ b/notebooks/03-process.ipynb @@ -31,7 +31,9 @@ "outputs": [], "source": [ "import os\n", - "if os.path.basename(os.getcwd()) == \"notebooks\": os.chdir(\"..\")\n", + "\n", + "if os.path.basename(os.getcwd()) == \"notebooks\":\n", + " os.chdir(\"..\")\n", "import numpy as np" ] }, @@ -87,7 +89,12 @@ } ], "source": [ - "dj.Diagram(subject.Subject) + dj.Diagram(session.Session) + dj.Diagram(scan) + dj.Diagram(imaging.Processing)" + "(\n", + " dj.Diagram(subject.Subject)\n", + " + dj.Diagram(session.Session)\n", + " + dj.Diagram(scan)\n", + " + dj.Diagram(imaging.Processing)\n", + ")" ] }, { @@ -128,10 +135,14 @@ "metadata": {}, "outputs": [], "source": [ - "subject.Subject.insert1(dict(subject='subject3', \n", - " sex='F', \n", - " subject_birth_date='2020-01-01', \n", - " subject_description='Scanbox acquisition. Suite2p processing.'))" + "subject.Subject.insert1(\n", + " dict(\n", + " subject=\"subject3\",\n", + " sex=\"F\",\n", + " subject_birth_date=\"2020-01-01\",\n", + " subject_description=\"Scanbox acquisition. Suite2p processing.\",\n", + " )\n", + ")" ] }, { @@ -147,7 +158,7 @@ "metadata": {}, "outputs": [], "source": [ - "Equipment.insert1(dict(scanner='Scanbox'))" + "Equipment.insert1(dict(scanner=\"Scanbox\"))" ] }, { @@ -286,7 +297,7 @@ } ], "source": [ - "session_key = dict(subject='subject3', session_datetime='2021-04-30 12:22:15.032')\n", + "session_key = dict(subject=\"subject3\", session_datetime=\"2021-04-30 12:22:15.032\")\n", "\n", "session.Session.insert1(session_key)\n", "\n", @@ -440,9 +451,13 @@ } ], "source": [ - "session.SessionDirectory.insert1(dict(subject='subject3', \n", - " session_datetime='2021-04-30 12:22:15.032', \n", - " session_dir='subject3/210107_run00_orientation_8dir'))\n", + "session.SessionDirectory.insert1(\n", + " dict(\n", + " subject=\"subject3\",\n", + " session_datetime=\"2021-04-30 12:22:15.032\",\n", + " session_dir=\"subject3/210107_run00_orientation_8dir\",\n", + " )\n", + ")\n", "\n", "session.SessionDirectory()" ] @@ -585,12 +600,16 @@ } ], "source": [ - "scan.Scan.insert1(dict(subject='subject3', \n", - " session_datetime='2021-04-30 12:22:15.032', \n", - " scan_id=0, \n", - " scanner='Scanbox', \n", - " acq_software='Scanbox',\n", - " scan_notes=''))\n", + "scan.Scan.insert1(\n", + " dict(\n", + " subject=\"subject3\",\n", + " session_datetime=\"2021-04-30 12:22:15.032\",\n", + " scan_id=0,\n", + " scanner=\"Scanbox\",\n", + " acq_software=\"Scanbox\",\n", + " scan_notes=\"\",\n", + " )\n", + ")\n", "scan.Scan()" ] }, @@ -680,7 +699,7 @@ "metadata": {}, "outputs": [], "source": [ - "populate_settings = {'display_progress': True}" + "populate_settings = {\"display_progress\": True}" ] }, { @@ -854,67 +873,69 @@ "metadata": {}, "outputs": [], "source": [ - "params_suite2p = {'look_one_level_down': 0.0,\n", - " 'fast_disk': [],\n", - " 'delete_bin': False,\n", - " 'mesoscan': False,\n", - " 'h5py': [],\n", - " 'h5py_key': 'data',\n", - " 'save_path0': [],\n", - " 'subfolders': [],\n", - " 'nplanes': 1,\n", - " 'nchannels': 1,\n", - " 'functional_chan': 1,\n", - " 'tau': 1.0,\n", - " 'fs': 10.0,\n", - " 'force_sktiff': False,\n", - " 'preclassify': 0.0,\n", - " 'save_mat': False,\n", - " 'combined': True,\n", - " 'aspect': 1.0,\n", - " 'do_bidiphase': False,\n", - " 'bidiphase': 0.0,\n", - " 'do_registration': True,\n", - " 'keep_movie_raw': False,\n", - " 'nimg_init': 300,\n", - " 'batch_size': 500,\n", - " 'maxregshift': 0.1,\n", - " 'align_by_chan': 1,\n", - " 'reg_tif': False,\n", - " 'reg_tif_chan2': False,\n", - " 'subpixel': 10,\n", - " 'smooth_sigma': 1.15,\n", - " 'th_badframes': 1.0,\n", - " 'pad_fft': False,\n", - " 'nonrigid': True,\n", - " 'block_size': [128, 128],\n", - " 'snr_thresh': 1.2,\n", - " 'maxregshiftNR': 5.0,\n", - " '1Preg': False,\n", - " 'spatial_hp': 50.0,\n", - " 'pre_smooth': 2.0,\n", - " 'spatial_taper': 50.0,\n", - " 'roidetect': True,\n", - " 'sparse_mode': False,\n", - " 'diameter': 12,\n", - " 'spatial_scale': 0,\n", - " 'connected': True,\n", - " 'nbinned': 5000,\n", - " 'max_iterations': 20,\n", - " 'threshold_scaling': 1.0,\n", - " 'max_overlap': 0.75,\n", - " 'high_pass': 100.0,\n", - " 'inner_neuropil_radius': 2,\n", - " 'min_neuropil_pixels': 350,\n", - " 'allow_overlap': False,\n", - " 'chan2_thres': 0.65,\n", - " 'baseline': 'maximin',\n", - " 'win_baseline': 60.0,\n", - " 'sig_baseline': 10.0,\n", - " 'prctile_baseline': 8.0,\n", - " 'neucoeff': 0.7,\n", - " 'xrange': np.array([0, 0]),\n", - " 'yrange': np.array([0, 0])}" + "params_suite2p = {\n", + " \"look_one_level_down\": 0.0,\n", + " \"fast_disk\": [],\n", + " \"delete_bin\": False,\n", + " \"mesoscan\": False,\n", + " \"h5py\": [],\n", + " \"h5py_key\": \"data\",\n", + " \"save_path0\": [],\n", + " \"subfolders\": [],\n", + " \"nplanes\": 1,\n", + " \"nchannels\": 1,\n", + " \"functional_chan\": 1,\n", + " \"tau\": 1.0,\n", + " \"fs\": 10.0,\n", + " \"force_sktiff\": False,\n", + " \"preclassify\": 0.0,\n", + " \"save_mat\": False,\n", + " \"combined\": True,\n", + " \"aspect\": 1.0,\n", + " \"do_bidiphase\": False,\n", + " \"bidiphase\": 0.0,\n", + " \"do_registration\": True,\n", + " \"keep_movie_raw\": False,\n", + " \"nimg_init\": 300,\n", + " \"batch_size\": 500,\n", + " \"maxregshift\": 0.1,\n", + " \"align_by_chan\": 1,\n", + " \"reg_tif\": False,\n", + " \"reg_tif_chan2\": False,\n", + " \"subpixel\": 10,\n", + " \"smooth_sigma\": 1.15,\n", + " \"th_badframes\": 1.0,\n", + " \"pad_fft\": False,\n", + " \"nonrigid\": True,\n", + " \"block_size\": [128, 128],\n", + " \"snr_thresh\": 1.2,\n", + " \"maxregshiftNR\": 5.0,\n", + " \"1Preg\": False,\n", + " \"spatial_hp\": 50.0,\n", + " \"pre_smooth\": 2.0,\n", + " \"spatial_taper\": 50.0,\n", + " \"roidetect\": True,\n", + " \"sparse_mode\": False,\n", + " \"diameter\": 12,\n", + " \"spatial_scale\": 0,\n", + " \"connected\": True,\n", + " \"nbinned\": 5000,\n", + " \"max_iterations\": 20,\n", + " \"threshold_scaling\": 1.0,\n", + " \"max_overlap\": 0.75,\n", + " \"high_pass\": 100.0,\n", + " \"inner_neuropil_radius\": 2,\n", + " \"min_neuropil_pixels\": 350,\n", + " \"allow_overlap\": False,\n", + " \"chan2_thres\": 0.65,\n", + " \"baseline\": \"maximin\",\n", + " \"win_baseline\": 60.0,\n", + " \"sig_baseline\": 10.0,\n", + " \"prctile_baseline\": 8.0,\n", + " \"neucoeff\": 0.7,\n", + " \"xrange\": np.array([0, 0]),\n", + " \"yrange\": np.array([0, 0]),\n", + "}" ] }, { @@ -933,10 +954,11 @@ "outputs": [], "source": [ "imaging.ProcessingParamSet.insert_new_params(\n", - " processing_method='suite2p', \n", - " paramset_idx=0, \n", + " processing_method=\"suite2p\",\n", + " paramset_idx=0,\n", " params=params_suite2p,\n", - " paramset_desc='Calcium imaging analysis with Suite2p using default Suite2p parameters')" + " paramset_desc=\"Calcium imaging analysis with Suite2p using default Suite2p parameters\",\n", + ")" ] }, { @@ -962,11 +984,15 @@ "metadata": {}, "outputs": [], "source": [ - "imaging.ProcessingTask.insert1(dict(subject='subject3', \n", - " session_datetime='2021-04-30 12:22:15.032', \n", - " scan_id=0,\n", - " paramset_idx=0,\n", - " processing_output_dir='subject3/210107_run00_orientation_8dir/suite2p'))" + "imaging.ProcessingTask.insert1(\n", + " dict(\n", + " subject=\"subject3\",\n", + " session_datetime=\"2021-04-30 12:22:15.032\",\n", + " scan_id=0,\n", + " paramset_idx=0,\n", + " processing_output_dir=\"subject3/210107_run00_orientation_8dir/suite2p\",\n", + " )\n", + ")" ] }, { @@ -1016,15 +1042,19 @@ "metadata": {}, "outputs": [], "source": [ - "imaging.Curation.insert1(dict(subject='subject3', \n", - " session_datetime='2021-04-30 12:22:15.032', \n", - " scan_id=0,\n", - " paramset_idx=0,\n", - " curation_id=0,\n", - " curation_time='2021-04-30 12:22:15.032', \n", - " curation_output_dir='subject3/210107_run00_orientation_8dir/suite2p',\n", - " manual_curation=False,\n", - " curation_note=''))" + "imaging.Curation.insert1(\n", + " dict(\n", + " subject=\"subject3\",\n", + " session_datetime=\"2021-04-30 12:22:15.032\",\n", + " scan_id=0,\n", + " paramset_idx=0,\n", + " curation_id=0,\n", + " curation_time=\"2021-04-30 12:22:15.032\",\n", + " curation_output_dir=\"subject3/210107_run00_orientation_8dir/suite2p\",\n", + " manual_curation=False,\n", + " curation_note=\"\",\n", + " )\n", + ")" ] }, { diff --git a/notebooks/04-automate-optional.ipynb b/notebooks/04-automate-optional.ipynb index a97e489..31ac99a 100644 --- a/notebooks/04-automate-optional.ipynb +++ b/notebooks/04-automate-optional.ipynb @@ -28,7 +28,9 @@ ], "source": [ "import os\n", - "if os.path.basename(os.getcwd()) == \"notebooks\": os.chdir(\"..\")\n", + "\n", + "if os.path.basename(os.getcwd()) == \"notebooks\":\n", + " os.chdir(\"..\")\n", "import numpy as np\n", "from workflow_calcium_imaging.pipeline import lab, subject, session, scan, imaging" ] @@ -102,67 +104,69 @@ }, "outputs": [], "source": [ - "params_suite2p = {'look_one_level_down': 0.0,\n", - " 'fast_disk': [],\n", - " 'delete_bin': False,\n", - " 'mesoscan': False,\n", - " 'h5py': [],\n", - " 'h5py_key': 'data',\n", - " 'save_path0': [],\n", - " 'subfolders': [],\n", - " 'nplanes': 1,\n", - " 'nchannels': 1,\n", - " 'functional_chan': 1,\n", - " 'tau': 1.0,\n", - " 'fs': 10.0,\n", - " 'force_sktiff': False,\n", - " 'preclassify': 0.0,\n", - " 'save_mat': False,\n", - " 'combined': True,\n", - " 'aspect': 1.0,\n", - " 'do_bidiphase': False,\n", - " 'bidiphase': 0.0,\n", - " 'do_registration': True,\n", - " 'keep_movie_raw': False,\n", - " 'nimg_init': 300,\n", - " 'batch_size': 500,\n", - " 'maxregshift': 0.1,\n", - " 'align_by_chan': 1,\n", - " 'reg_tif': False,\n", - " 'reg_tif_chan2': False,\n", - " 'subpixel': 10,\n", - " 'smooth_sigma': 1.15,\n", - " 'th_badframes': 1.0,\n", - " 'pad_fft': False,\n", - " 'nonrigid': True,\n", - " 'block_size': [128, 128],\n", - " 'snr_thresh': 1.2,\n", - " 'maxregshiftNR': 5.0,\n", - " '1Preg': False,\n", - " 'spatial_hp': 50.0,\n", - " 'pre_smooth': 2.0,\n", - " 'spatial_taper': 50.0,\n", - " 'roidetect': True,\n", - " 'sparse_mode': False,\n", - " 'diameter': 12,\n", - " 'spatial_scale': 0,\n", - " 'connected': True,\n", - " 'nbinned': 5000,\n", - " 'max_iterations': 20,\n", - " 'threshold_scaling': 1.0,\n", - " 'max_overlap': 0.75,\n", - " 'high_pass': 100.0,\n", - " 'inner_neuropil_radius': 2,\n", - " 'min_neuropil_pixels': 350,\n", - " 'allow_overlap': False,\n", - " 'chan2_thres': 0.65,\n", - " 'baseline': 'maximin',\n", - " 'win_baseline': 60.0,\n", - " 'sig_baseline': 10.0,\n", - " 'prctile_baseline': 8.0,\n", - " 'neucoeff': 0.7,\n", - " 'xrange': np.array([0, 0]),\n", - " 'yrange': np.array([0, 0])}" + "params_suite2p = {\n", + " \"look_one_level_down\": 0.0,\n", + " \"fast_disk\": [],\n", + " \"delete_bin\": False,\n", + " \"mesoscan\": False,\n", + " \"h5py\": [],\n", + " \"h5py_key\": \"data\",\n", + " \"save_path0\": [],\n", + " \"subfolders\": [],\n", + " \"nplanes\": 1,\n", + " \"nchannels\": 1,\n", + " \"functional_chan\": 1,\n", + " \"tau\": 1.0,\n", + " \"fs\": 10.0,\n", + " \"force_sktiff\": False,\n", + " \"preclassify\": 0.0,\n", + " \"save_mat\": False,\n", + " \"combined\": True,\n", + " \"aspect\": 1.0,\n", + " \"do_bidiphase\": False,\n", + " \"bidiphase\": 0.0,\n", + " \"do_registration\": True,\n", + " \"keep_movie_raw\": False,\n", + " \"nimg_init\": 300,\n", + " \"batch_size\": 500,\n", + " \"maxregshift\": 0.1,\n", + " \"align_by_chan\": 1,\n", + " \"reg_tif\": False,\n", + " \"reg_tif_chan2\": False,\n", + " \"subpixel\": 10,\n", + " \"smooth_sigma\": 1.15,\n", + " \"th_badframes\": 1.0,\n", + " \"pad_fft\": False,\n", + " \"nonrigid\": True,\n", + " \"block_size\": [128, 128],\n", + " \"snr_thresh\": 1.2,\n", + " \"maxregshiftNR\": 5.0,\n", + " \"1Preg\": False,\n", + " \"spatial_hp\": 50.0,\n", + " \"pre_smooth\": 2.0,\n", + " \"spatial_taper\": 50.0,\n", + " \"roidetect\": True,\n", + " \"sparse_mode\": False,\n", + " \"diameter\": 12,\n", + " \"spatial_scale\": 0,\n", + " \"connected\": True,\n", + " \"nbinned\": 5000,\n", + " \"max_iterations\": 20,\n", + " \"threshold_scaling\": 1.0,\n", + " \"max_overlap\": 0.75,\n", + " \"high_pass\": 100.0,\n", + " \"inner_neuropil_radius\": 2,\n", + " \"min_neuropil_pixels\": 350,\n", + " \"allow_overlap\": False,\n", + " \"chan2_thres\": 0.65,\n", + " \"baseline\": \"maximin\",\n", + " \"win_baseline\": 60.0,\n", + " \"sig_baseline\": 10.0,\n", + " \"prctile_baseline\": 8.0,\n", + " \"neucoeff\": 0.7,\n", + " \"xrange\": np.array([0, 0]),\n", + " \"yrange\": np.array([0, 0]),\n", + "}" ] }, { @@ -172,10 +176,11 @@ "outputs": [], "source": [ "imaging.ProcessingParamSet.insert_new_params(\n", - " processing_method='suite2p', \n", - " paramset_idx=0, \n", + " processing_method=\"suite2p\",\n", + " paramset_idx=0,\n", " params=params_suite2p,\n", - " paramset_desc='Calcium imaging analysis with Suite2p using default Suite2p parameters')" + " paramset_desc=\"Calcium imaging analysis with Suite2p using default Suite2p parameters\",\n", + ")" ] }, { @@ -248,12 +253,17 @@ "metadata": {}, "outputs": [], "source": [ - "session_key = (session.Session & 'subject=\"subject3\"').fetch('KEY')[0]\n", + "session_key = (session.Session & 'subject=\"subject3\"').fetch(\"KEY\")[0]\n", "\n", - "imaging.ProcessingTask.insert1(dict(session_key, \n", - " scan_id=0,\n", - " paramset_idx=0,\n", - " processing_output_dir='subject3/210107_run00_orientation_8dir/suite2p'), skip_duplicates=True)" + "imaging.ProcessingTask.insert1(\n", + " dict(\n", + " session_key,\n", + " scan_id=0,\n", + " paramset_idx=0,\n", + " processing_output_dir=\"subject3/210107_run00_orientation_8dir/suite2p\",\n", + " ),\n", + " skip_duplicates=True,\n", + ")" ] }, { @@ -303,7 +313,7 @@ "metadata": {}, "outputs": [], "source": [ - "key = (imaging.ProcessingTask & session_key).fetch1('KEY')\n", + "key = (imaging.ProcessingTask & session_key).fetch1(\"KEY\")\n", "imaging.Curation().create1_from_processing_task(key)" ] }, diff --git a/notebooks/05-explore.ipynb b/notebooks/05-explore.ipynb index 156fa74..1fd0eeb 100644 --- a/notebooks/05-explore.ipynb +++ b/notebooks/05-explore.ipynb @@ -16,7 +16,9 @@ "outputs": [], "source": [ "import os\n", - "if os.path.basename(os.getcwd()) == \"notebooks\": os.chdir(\"..\")" + "\n", + "if os.path.basename(os.getcwd()) == \"notebooks\":\n", + " os.chdir(\"..\")" ] }, { @@ -296,7 +298,7 @@ "metadata": {}, "outputs": [], "source": [ - "session_key = (session.Session & 'subject = \"subject3\"').fetch('KEY')[0]" + "session_key = (session.Session & 'subject = \"subject3\"').fetch(\"KEY\")[0]" ] }, { @@ -1114,7 +1116,7 @@ "metadata": {}, "outputs": [], "source": [ - "curation_key = (imaging.Curation & session_key & 'curation_id=0').fetch1('KEY')" + "curation_key = (imaging.Curation & session_key & \"curation_id=0\").fetch1(\"KEY\")" ] }, { @@ -1550,7 +1552,7 @@ } ], "source": [ - "imaging.MotionCorrection.Block & curation_key & 'block_id=0'" + "imaging.MotionCorrection.Block & curation_key & \"block_id=0\"" ] }, { @@ -1688,7 +1690,7 @@ } ], "source": [ - "imaging.MotionCorrection.Summary & curation_key & 'field_idx=0'" + "imaging.MotionCorrection.Summary & curation_key & \"field_idx=0\"" ] }, { @@ -1704,7 +1706,9 @@ "metadata": {}, "outputs": [], "source": [ - "average_image = (imaging.MotionCorrection.Summary & curation_key & 'field_idx=0').fetch1('average_image')" + "average_image = (\n", + " imaging.MotionCorrection.Summary & curation_key & \"field_idx=0\"\n", + ").fetch1(\"average_image\")" ] }, { @@ -1747,7 +1751,12 @@ "metadata": {}, "outputs": [], "source": [ - "mask_xpix, mask_ypix = (imaging.Segmentation.Mask * imaging.MaskClassification.MaskType & curation_key & 'mask_center_z=0' & 'mask_npix > 130').fetch('mask_xpix','mask_ypix')" + "mask_xpix, mask_ypix = (\n", + " imaging.Segmentation.Mask * imaging.MaskClassification.MaskType\n", + " & curation_key\n", + " & \"mask_center_z=0\"\n", + " & \"mask_npix > 130\"\n", + ").fetch(\"mask_xpix\", \"mask_ypix\")" ] }, { @@ -1781,8 +1790,8 @@ } ], "source": [ - "plt.imshow(average_image);\n", - "plt.contour(mask_image, colors='white', linewidths=0.5);" + "plt.imshow(average_image)\n", + "plt.contour(mask_image, colors=\"white\", linewidths=0.5);" ] }, { @@ -1910,7 +1919,7 @@ } ], "source": [ - "imaging.MaskClassification.MaskType & curation_key & 'mask=0'" + "imaging.MaskClassification.MaskType & curation_key & \"mask=0\"" ] }, { @@ -1928,7 +1937,12 @@ "metadata": {}, "outputs": [], "source": [ - "query_cells = (imaging.Segmentation.Mask * imaging.MaskClassification.MaskType & curation_key & 'mask_center_z=0' & 'mask_npix > 130').proj()" + "query_cells = (\n", + " imaging.Segmentation.Mask * imaging.MaskClassification.MaskType\n", + " & curation_key\n", + " & \"mask_center_z=0\"\n", + " & \"mask_npix > 130\"\n", + ").proj()" ] }, { @@ -1937,11 +1951,15 @@ "metadata": {}, "outputs": [], "source": [ - "fluorescence_traces = (imaging.Fluorescence.Trace & query_cells).fetch('fluorescence', order_by='mask')\n", + "fluorescence_traces = (imaging.Fluorescence.Trace & query_cells).fetch(\n", + " \"fluorescence\", order_by=\"mask\"\n", + ")\n", "\n", - "activity_traces = (imaging.Activity.Trace & query_cells).fetch('activity_trace', order_by='mask')\n", + "activity_traces = (imaging.Activity.Trace & query_cells).fetch(\n", + " \"activity_trace\", order_by=\"mask\"\n", + ")\n", "\n", - "sampling_rate = (scan.ScanInfo & curation_key).fetch1('fps') # [Hz]" + "sampling_rate = (scan.ScanInfo & curation_key).fetch1(\"fps\") # [Hz]" ] }, { @@ -1968,20 +1986,26 @@ "ax2 = ax.twinx()\n", "\n", "for f, a in zip(fluorescence_traces, activity_traces):\n", - " ax.plot(np.r_[:f.size] * 1/sampling_rate, f, 'k', label='fluorescence trace') \n", - " ax2.plot(np.r_[:a.size] * 1/sampling_rate, a, 'r', alpha=0.5, label='deconvolved trace')\n", - " \n", + " ax.plot(np.r_[: f.size] * 1 / sampling_rate, f, \"k\", label=\"fluorescence trace\")\n", + " ax2.plot(\n", + " np.r_[: a.size] * 1 / sampling_rate,\n", + " a,\n", + " \"r\",\n", + " alpha=0.5,\n", + " label=\"deconvolved trace\",\n", + " )\n", + "\n", " break\n", "\n", "ax.tick_params(labelsize=14)\n", "ax2.tick_params(labelsize=14)\n", "\n", - "ax.legend(loc='upper left', prop={'size': 14})\n", - "ax2.legend(loc='upper right', prop={'size': 14})\n", + "ax.legend(loc=\"upper left\", prop={\"size\": 14})\n", + "ax2.legend(loc=\"upper right\", prop={\"size\": 14})\n", "\n", - "ax.set_xlabel('Time (s)')\n", - "ax.set_ylabel('Activity (a.u.)')\n", - "ax2.set_ylabel('Activity (a.u.)');" + "ax.set_xlabel(\"Time (s)\")\n", + "ax.set_ylabel(\"Activity (a.u.)\")\n", + "ax2.set_ylabel(\"Activity (a.u.)\");" ] }, { diff --git a/notebooks/06-drop-optional.ipynb b/notebooks/06-drop-optional.ipynb index d54a927..7f96132 100644 --- a/notebooks/06-drop-optional.ipynb +++ b/notebooks/06-drop-optional.ipynb @@ -25,7 +25,9 @@ "outputs": [], "source": [ "import os\n", - "if os.path.basename(os.getcwd()) == \"notebooks\": os.chdir(\"..\")" + "\n", + "if os.path.basename(os.getcwd()) == \"notebooks\":\n", + " os.chdir(\"..\")" ] }, { diff --git a/notebooks/07-downstream-analysis-optional.ipynb b/notebooks/07-downstream-analysis-optional.ipynb index 9612d4d..349fb9b 100644 --- a/notebooks/07-downstream-analysis-optional.ipynb +++ b/notebooks/07-downstream-analysis-optional.ipynb @@ -36,10 +36,14 @@ "outputs": [], "source": [ "import os\n", + "\n", "# change to the upper level folder to detect dj_local_conf.json\n", - "if os.path.basename(os.getcwd())=='notebooks': os.chdir('..')\n", + "if os.path.basename(os.getcwd()) == \"notebooks\":\n", + " os.chdir(\"..\")\n", "# We'll be working with long tables, so we'll make visualization easier with a limit\n", - "import datajoint as dj; dj.config['display.limit']=10" + "import datajoint as dj\n", + "\n", + "dj.config[\"display.limit\"] = 10" ] }, { @@ -123,8 +127,12 @@ "metadata": {}, "outputs": [], "source": [ - "from workflow_calcium_imaging.ingest import ingest_subjects, ingest_sessions,\\\n", - " ingest_events, ingest_alignment" + "from workflow_calcium_imaging.ingest import (\n", + " ingest_subjects,\n", + " ingest_sessions,\n", + " ingest_events,\n", + " ingest_alignment,\n", + ")" ] }, { @@ -487,7 +495,7 @@ } ], "source": [ - "trial.TrialEvent() & 'trial_id<5'" + "trial.TrialEvent() & \"trial_id<5\"" ] }, { @@ -811,8 +819,9 @@ "metadata": {}, "outputs": [], "source": [ - "ca_activity_key = (imaging.Activity & {'subject': 'subject3', 'scan_id': 0}\n", - " ).fetch('KEY')[0]" + "ca_activity_key = (imaging.Activity & {\"subject\": \"subject3\", \"scan_id\": 0}).fetch(\n", + " \"KEY\"\n", + ")[0]" ] }, { @@ -1184,8 +1193,9 @@ } ], "source": [ - "alignment_key = (event.AlignmentEvent & 'alignment_name = \"center_button\"'\n", - " ).fetch1('KEY')\n", + "alignment_key = (event.AlignmentEvent & 'alignment_name = \"center_button\"').fetch1(\n", + " \"KEY\"\n", + ")\n", "alignment_key" ] }, @@ -1214,8 +1224,11 @@ } ], "source": [ - "alignment_condition = {**ca_activity_key, **alignment_key, \n", - " 'trial_condition': 'ctrl_center_button'}\n", + "alignment_condition = {\n", + " **ca_activity_key,\n", + " **alignment_key,\n", + " \"trial_condition\": \"ctrl_center_button\",\n", + "}\n", "alignment_condition" ] }, @@ -1568,7 +1581,9 @@ } ], "source": [ - "sample = (analysis.ActivityAlignmentCondition * ctrl_trials & alignment_condition).proj()\n", + "sample = (\n", + " analysis.ActivityAlignmentCondition * ctrl_trials & alignment_condition\n", + ").proj()\n", "sample" ] }, @@ -1815,12 +1830,16 @@ "outputs": [], "source": [ "stim_trials = trial.Trial & ca_activity_key & 'trial_type = \"stim\"'\n", - "alignment_condition = {**ca_activity_key, **alignment_key, \n", - " 'trial_condition': 'stim_center_button'}\n", + "alignment_condition = {\n", + " **ca_activity_key,\n", + " **alignment_key,\n", + " \"trial_condition\": \"stim_center_button\",\n", + "}\n", "analysis.ActivityAlignmentCondition.insert1(alignment_condition, skip_duplicates=True)\n", "analysis.ActivityAlignmentCondition.Trial.insert(\n", " (analysis.ActivityAlignmentCondition * stim_trials & alignment_condition).proj(),\n", - " skip_duplicates=True)" + " skip_duplicates=True,\n", + ")" ] }, { @@ -2842,7 +2861,7 @@ } ], "source": [ - "imaging.Segmentation.Mask & 'mask<3'" + "imaging.Segmentation.Mask & \"mask<3\"" ] }, { @@ -2862,14 +2881,23 @@ "source": [ "from workflow_calcium_imaging import analysis\n", "from workflow_calcium_imaging.pipeline import session, imaging, trial, event\n", - "ca_activity_key = (imaging.Activity & {'subject': 'subject3', 'scan_id': 0}\n", - " ).fetch('KEY')[0]\n", - "alignment_key = (event.AlignmentEvent & 'alignment_name = \"center_button\"'\n", - " ).fetch1('KEY')\n", - "alignment_condition_ctrl = {**ca_activity_key, **alignment_key, \n", - " 'trial_condition': 'ctrl_center_button'}\n", - "alignment_condition_stim = {**ca_activity_key, **alignment_key, \n", - " 'trial_condition': 'stim_center_button'}" + "\n", + "ca_activity_key = (imaging.Activity & {\"subject\": \"subject3\", \"scan_id\": 0}).fetch(\n", + " \"KEY\"\n", + ")[0]\n", + "alignment_key = (event.AlignmentEvent & 'alignment_name = \"center_button\"').fetch1(\n", + " \"KEY\"\n", + ")\n", + "alignment_condition_ctrl = {\n", + " **ca_activity_key,\n", + " **alignment_key,\n", + " \"trial_condition\": \"ctrl_center_button\",\n", + "}\n", + "alignment_condition_stim = {\n", + " **ca_activity_key,\n", + " **alignment_key,\n", + " \"trial_condition\": \"stim_center_button\",\n", + "}" ] }, { @@ -2904,10 +2932,12 @@ } ], "source": [ - "analysis.ActivityAlignment().plot_aligned_activities(alignment_condition_stim, roi=2,\n", - " title='Stimulus Center Button');\n", - "analysis.ActivityAlignment().plot_aligned_activities(alignment_condition_ctrl, roi=2,\n", - " title='Control Center Button');" + "analysis.ActivityAlignment().plot_aligned_activities(\n", + " alignment_condition_stim, roi=2, title=\"Stimulus Center Button\"\n", + ")\n", + "analysis.ActivityAlignment().plot_aligned_activities(\n", + " alignment_condition_ctrl, roi=2, title=\"Control Center Button\"\n", + ");" ] }, { diff --git a/notebooks/2022-allen-institute-workshop.ipynb b/notebooks/2022-allen-institute-workshop.ipynb index 9d607ba..09a8415 100644 --- a/notebooks/2022-allen-institute-workshop.ipynb +++ b/notebooks/2022-allen-institute-workshop.ipynb @@ -23,7 +23,7 @@ "metadata": {}, "outputs": [], "source": [ - "import datajoint as dj \n", + "import datajoint as dj\n", "import numpy as np\n", "from matplotlib import pyplot\n", "import os\n", @@ -64,9 +64,9 @@ "outputs": [], "source": [ "username_as_prefix = dj.config[\"database.user\"] + \"_img_\"\n", - "dj.config['custom'] = {\n", - " 'database.prefix': username_as_prefix,\n", - " 'imaging_root_data_dir': '/home/'\n", + "dj.config[\"custom\"] = {\n", + " \"database.prefix\": username_as_prefix,\n", + " \"imaging_root_data_dir\": \"/home/\",\n", "}" ] }, @@ -165,88 +165,95 @@ } ], "source": [ - "\n", - "from workflow_calcium_imaging.pipeline import session, imaging # import schemas\n", - "from workflow_calcium_imaging.ingest import ingest_subjects, ingest_sessions #csv loaders\n", + "from workflow_calcium_imaging.pipeline import session, imaging # import schemas\n", + "from workflow_calcium_imaging.ingest import (\n", + " ingest_subjects,\n", + " ingest_sessions,\n", + ") # csv loaders\n", "\n", "import csv\n", "\n", "sessions_csv_path = f\"/home/{dj.config['database.user']}/sessions.csv\"\n", - "with open(sessions_csv_path, 'w', newline='') as f:\n", + "with open(sessions_csv_path, \"w\", newline=\"\") as f:\n", " csv_writer = csv.writer(f)\n", - " csv_writer.writerow([\"subject\",\"session_dir\"])\n", - " csv_writer.writerow([\"subject3\",\"inbox/0_1_0a2/subject3/210107_run00_orientation_8dir/\"])\n", + " csv_writer.writerow([\"subject\", \"session_dir\"])\n", + " csv_writer.writerow(\n", + " [\"subject3\", \"inbox/0_1_0a2/subject3/210107_run00_orientation_8dir/\"]\n", + " )\n", "\n", "ingest_subjects(subject_csv_path=\"/home/user_data/subjects.csv\")\n", "ingest_sessions(session_csv_path=sessions_csv_path)\n", "\n", - "params_suite2p = {'look_one_level_down': 0.0,\n", - " 'fast_disk': [],\n", - " 'delete_bin': False,\n", - " 'mesoscan': False,\n", - " 'h5py': [],\n", - " 'h5py_key': 'data',\n", - " 'save_path0': [],\n", - " 'subfolders': [],\n", - " 'nplanes': 1,\n", - " 'nchannels': 1,\n", - " 'functional_chan': 1,\n", - " 'tau': 1.0,\n", - " 'fs': 10.0,\n", - " 'force_sktiff': False,\n", - " 'preclassify': 0.0,\n", - " 'save_mat': False,\n", - " 'combined': True,\n", - " 'aspect': 1.0,\n", - " 'do_bidiphase': False,\n", - " 'bidiphase': 0.0,\n", - " 'do_registration': True,\n", - " 'keep_movie_raw': False,\n", - " 'nimg_init': 300,\n", - " 'batch_size': 500,\n", - " 'maxregshift': 0.1,\n", - " 'align_by_chan': 1,\n", - " 'reg_tif': False,\n", - " 'reg_tif_chan2': False,\n", - " 'subpixel': 10,\n", - " 'smooth_sigma': 1.15,\n", - " 'th_badframes': 1.0,\n", - " 'pad_fft': False,\n", - " 'nonrigid': True,\n", - " 'block_size': [128, 128],\n", - " 'snr_thresh': 1.2,\n", - " 'maxregshiftNR': 5.0,\n", - " '1Preg': False,\n", - " 'spatial_hp': 50.0,\n", - " 'pre_smooth': 2.0,\n", - " 'spatial_taper': 50.0,\n", - " 'roidetect': True,\n", - " 'sparse_mode': False,\n", - " 'diameter': 12,\n", - " 'spatial_scale': 0,\n", - " 'connected': True,\n", - " 'nbinned': 5000,\n", - " 'max_iterations': 20,\n", - " 'threshold_scaling': 1.0,\n", - " 'max_overlap': 0.75,\n", - " 'high_pass': 100.0,\n", - " 'inner_neuropil_radius': 2,\n", - " 'min_neuropil_pixels': 350,\n", - " 'allow_overlap': False,\n", - " 'chan2_thres': 0.65,\n", - " 'baseline': 'maximin',\n", - " 'win_baseline': 60.0,\n", - " 'sig_baseline': 10.0,\n", - " 'prctile_baseline': 8.0,\n", - " 'neucoeff': 0.7,\n", - " 'xrange': np.array([0, 0]),\n", - " 'yrange': np.array([0, 0])}\n", + "params_suite2p = {\n", + " \"look_one_level_down\": 0.0,\n", + " \"fast_disk\": [],\n", + " \"delete_bin\": False,\n", + " \"mesoscan\": False,\n", + " \"h5py\": [],\n", + " \"h5py_key\": \"data\",\n", + " \"save_path0\": [],\n", + " \"subfolders\": [],\n", + " \"nplanes\": 1,\n", + " \"nchannels\": 1,\n", + " \"functional_chan\": 1,\n", + " \"tau\": 1.0,\n", + " \"fs\": 10.0,\n", + " \"force_sktiff\": False,\n", + " \"preclassify\": 0.0,\n", + " \"save_mat\": False,\n", + " \"combined\": True,\n", + " \"aspect\": 1.0,\n", + " \"do_bidiphase\": False,\n", + " \"bidiphase\": 0.0,\n", + " \"do_registration\": True,\n", + " \"keep_movie_raw\": False,\n", + " \"nimg_init\": 300,\n", + " \"batch_size\": 500,\n", + " \"maxregshift\": 0.1,\n", + " \"align_by_chan\": 1,\n", + " \"reg_tif\": False,\n", + " \"reg_tif_chan2\": False,\n", + " \"subpixel\": 10,\n", + " \"smooth_sigma\": 1.15,\n", + " \"th_badframes\": 1.0,\n", + " \"pad_fft\": False,\n", + " \"nonrigid\": True,\n", + " \"block_size\": [128, 128],\n", + " \"snr_thresh\": 1.2,\n", + " \"maxregshiftNR\": 5.0,\n", + " \"1Preg\": False,\n", + " \"spatial_hp\": 50.0,\n", + " \"pre_smooth\": 2.0,\n", + " \"spatial_taper\": 50.0,\n", + " \"roidetect\": True,\n", + " \"sparse_mode\": False,\n", + " \"diameter\": 12,\n", + " \"spatial_scale\": 0,\n", + " \"connected\": True,\n", + " \"nbinned\": 5000,\n", + " \"max_iterations\": 20,\n", + " \"threshold_scaling\": 1.0,\n", + " \"max_overlap\": 0.75,\n", + " \"high_pass\": 100.0,\n", + " \"inner_neuropil_radius\": 2,\n", + " \"min_neuropil_pixels\": 350,\n", + " \"allow_overlap\": False,\n", + " \"chan2_thres\": 0.65,\n", + " \"baseline\": \"maximin\",\n", + " \"win_baseline\": 60.0,\n", + " \"sig_baseline\": 10.0,\n", + " \"prctile_baseline\": 8.0,\n", + " \"neucoeff\": 0.7,\n", + " \"xrange\": np.array([0, 0]),\n", + " \"yrange\": np.array([0, 0]),\n", + "}\n", "\n", "imaging.ProcessingParamSet.insert_new_params(\n", - " processing_method='suite2p', \n", - " paramset_idx=0, \n", + " processing_method=\"suite2p\",\n", + " paramset_idx=0,\n", " params=params_suite2p,\n", - " paramset_desc='Calcium imaging analysis with Suite2p using default Suite2p parameters')" + " paramset_desc=\"Calcium imaging analysis with Suite2p using default Suite2p parameters\",\n", + ")" ] }, { @@ -267,15 +274,15 @@ "from workflow_calcium_imaging import process\n", "\n", "process.run()\n", - "session_key = (session.Session & 'subject=\"subject3\"').fetch('KEY')[0]\n", + "session_key = (session.Session & 'subject=\"subject3\"').fetch(\"KEY\")[0]\n", "imaging.ProcessingTask.insert1(\n", " dict(\n", - " session_key, \n", + " session_key,\n", " scan_id=0,\n", " paramset_idx=0,\n", - " processing_output_dir='inbox/0_1_0a2/subject3/210107_run00_orientation_8dir/suite2p'\n", + " processing_output_dir=\"inbox/0_1_0a2/subject3/210107_run00_orientation_8dir/suite2p\",\n", " ),\n", - " skip_duplicates=True\n", + " skip_duplicates=True,\n", ")\n", "process.run()" ] @@ -295,7 +302,7 @@ "metadata": {}, "outputs": [], "source": [ - "key = (imaging.ProcessingTask & session_key).fetch1('KEY')\n", + "key = (imaging.ProcessingTask & session_key).fetch1(\"KEY\")\n", "imaging.Curation().create1_from_processing_task(key)\n", "process.run()" ] @@ -341,8 +348,13 @@ }, "outputs": [], "source": [ - "dj.Diagram(lab.Lab) + dj.Diagram(subject.Subject) + dj.Diagram(session.Session) + \\\n", - "dj.Diagram(scan) + dj.Diagram(imaging)" + "(\n", + " dj.Diagram(lab.Lab)\n", + " + dj.Diagram(subject.Subject)\n", + " + dj.Diagram(session.Session)\n", + " + dj.Diagram(scan)\n", + " + dj.Diagram(imaging)\n", + ")" ] }, { @@ -410,9 +422,12 @@ "metadata": {}, "outputs": [], "source": [ - "query_trace = imaging.Fluorescence.Trace & 'subject=\"subject3\"' \\\n", - " & 'session_datetime=\"2022-09-01 19:16:44\"' \\\n", - " & 'mask=120'\n", + "query_trace = (\n", + " imaging.Fluorescence.Trace\n", + " & 'subject=\"subject3\"'\n", + " & 'session_datetime=\"2022-09-01 19:16:44\"'\n", + " & \"mask=120\"\n", + ")\n", "query_trace" ] }, @@ -431,7 +446,7 @@ "metadata": {}, "outputs": [], "source": [ - "trace = (query_trace).fetch('fluorescence')[0]" + "trace = (query_trace).fetch(\"fluorescence\")[0]" ] }, { @@ -449,14 +464,16 @@ "metadata": {}, "outputs": [], "source": [ - "sampling_rate = (scan.ScanInfo & 'subject=\"subject3\"' & 'session_datetime=\"2022-09-01 19:16:44\"').fetch1('fps')\n", + "sampling_rate = (\n", + " scan.ScanInfo & 'subject=\"subject3\"' & 'session_datetime=\"2022-09-01 19:16:44\"'\n", + ").fetch1(\"fps\")\n", "\n", - "pyplot.plot(np.r_[:trace.size] * 1/sampling_rate, trace, 'k')\n", + "pyplot.plot(np.r_[: trace.size] * 1 / sampling_rate, trace, \"k\")\n", "\n", - "pyplot.title('Fluorescence trace for mask 120', fontsize=14)\n", + "pyplot.title(\"Fluorescence trace for mask 120\", fontsize=14)\n", "pyplot.tick_params(labelsize=14)\n", - "pyplot.xlabel('Time (s)')\n", - "pyplot.ylabel('Activity (a.u.)')" + "pyplot.xlabel(\"Time (s)\")\n", + "pyplot.ylabel(\"Activity (a.u.)\")" ] }, { @@ -476,7 +493,7 @@ "metadata": {}, "outputs": [], "source": [ - "dj.Diagram(imaging.Processing)-2" + "dj.Diagram(imaging.Processing) - 2" ] }, { @@ -506,67 +523,69 @@ "metadata": {}, "outputs": [], "source": [ - "params_suite2p = {'look_one_level_down': 0.0,\n", - " 'fast_disk': [],\n", - " 'delete_bin': False,\n", - " 'mesoscan': False,\n", - " 'h5py': [],\n", - " 'h5py_key': 'data',\n", - " 'save_path0': [],\n", - " 'subfolders': [],\n", - " 'nplanes': 4,\n", - " 'nchannels': 1,\n", - " 'functional_chan': 1,\n", - " 'tau': 1.0,\n", - " 'fs': 10.0,\n", - " 'force_sktiff': False,\n", - " 'preclassify': 0.0,\n", - " 'save_mat': False,\n", - " 'combined': True,\n", - " 'aspect': 1.0,\n", - " 'do_bidiphase': False,\n", - " 'bidiphase': 0.0,\n", - " 'do_registration': True,\n", - " 'keep_movie_raw': False,\n", - " 'nimg_init': 300,\n", - " 'batch_size': 500,\n", - " 'maxregshift': 0.1,\n", - " 'align_by_chan': 1,\n", - " 'reg_tif': False,\n", - " 'reg_tif_chan2': False,\n", - " 'subpixel': 10,\n", - " 'smooth_sigma': 1.15,\n", - " 'th_badframes': 1.0,\n", - " 'pad_fft': False,\n", - " 'nonrigid': True,\n", - " 'block_size': [128, 128],\n", - " 'snr_thresh': 1.2,\n", - " 'maxregshiftNR': 5.0,\n", - " '1Preg': False,\n", - " 'spatial_hp': 50.0,\n", - " 'pre_smooth': 2.0,\n", - " 'spatial_taper': 50.0,\n", - " 'roidetect': True,\n", - " 'sparse_mode': False,\n", - " 'diameter': 10,\n", - " 'spatial_scale': 0,\n", - " 'connected': True,\n", - " 'nbinned': 5000,\n", - " 'max_iterations': 20,\n", - " 'threshold_scaling': 1.0,\n", - " 'max_overlap': 0.75,\n", - " 'high_pass': 100.0,\n", - " 'inner_neuropil_radius': 2,\n", - " 'min_neuropil_pixels': 350,\n", - " 'allow_overlap': False,\n", - " 'chan2_thres': 0.65,\n", - " 'baseline': 'maximin',\n", - " 'win_baseline': 60.0,\n", - " 'sig_baseline': 10.0,\n", - " 'prctile_baseline': 8.0,\n", - " 'neucoeff': 0.7,\n", - " 'xrange': np.array([0, 0]),\n", - " 'yrange': np.array([0, 0])}" + "params_suite2p = {\n", + " \"look_one_level_down\": 0.0,\n", + " \"fast_disk\": [],\n", + " \"delete_bin\": False,\n", + " \"mesoscan\": False,\n", + " \"h5py\": [],\n", + " \"h5py_key\": \"data\",\n", + " \"save_path0\": [],\n", + " \"subfolders\": [],\n", + " \"nplanes\": 4,\n", + " \"nchannels\": 1,\n", + " \"functional_chan\": 1,\n", + " \"tau\": 1.0,\n", + " \"fs\": 10.0,\n", + " \"force_sktiff\": False,\n", + " \"preclassify\": 0.0,\n", + " \"save_mat\": False,\n", + " \"combined\": True,\n", + " \"aspect\": 1.0,\n", + " \"do_bidiphase\": False,\n", + " \"bidiphase\": 0.0,\n", + " \"do_registration\": True,\n", + " \"keep_movie_raw\": False,\n", + " \"nimg_init\": 300,\n", + " \"batch_size\": 500,\n", + " \"maxregshift\": 0.1,\n", + " \"align_by_chan\": 1,\n", + " \"reg_tif\": False,\n", + " \"reg_tif_chan2\": False,\n", + " \"subpixel\": 10,\n", + " \"smooth_sigma\": 1.15,\n", + " \"th_badframes\": 1.0,\n", + " \"pad_fft\": False,\n", + " \"nonrigid\": True,\n", + " \"block_size\": [128, 128],\n", + " \"snr_thresh\": 1.2,\n", + " \"maxregshiftNR\": 5.0,\n", + " \"1Preg\": False,\n", + " \"spatial_hp\": 50.0,\n", + " \"pre_smooth\": 2.0,\n", + " \"spatial_taper\": 50.0,\n", + " \"roidetect\": True,\n", + " \"sparse_mode\": False,\n", + " \"diameter\": 10,\n", + " \"spatial_scale\": 0,\n", + " \"connected\": True,\n", + " \"nbinned\": 5000,\n", + " \"max_iterations\": 20,\n", + " \"threshold_scaling\": 1.0,\n", + " \"max_overlap\": 0.75,\n", + " \"high_pass\": 100.0,\n", + " \"inner_neuropil_radius\": 2,\n", + " \"min_neuropil_pixels\": 350,\n", + " \"allow_overlap\": False,\n", + " \"chan2_thres\": 0.65,\n", + " \"baseline\": \"maximin\",\n", + " \"win_baseline\": 60.0,\n", + " \"sig_baseline\": 10.0,\n", + " \"prctile_baseline\": 8.0,\n", + " \"neucoeff\": 0.7,\n", + " \"xrange\": np.array([0, 0]),\n", + " \"yrange\": np.array([0, 0]),\n", + "}" ] }, { @@ -576,10 +595,12 @@ "metadata": {}, "outputs": [], "source": [ - "imaging.ProcessingParamSet.insert_new_params(processing_method='suite2p', \n", - " paramset_idx=1, \n", - " params=params_suite2p,\n", - " paramset_desc='diameter=10')" + "imaging.ProcessingParamSet.insert_new_params(\n", + " processing_method=\"suite2p\",\n", + " paramset_idx=1,\n", + " params=params_suite2p,\n", + " paramset_desc=\"diameter=10\",\n", + ")" ] }, { @@ -605,12 +626,12 @@ "\n", "imaging.ProcessingTask.insert1(\n", " dict(\n", - " subject='subject3', \n", - " session_datetime='2022-09-01 19:16:44', \n", + " subject=\"subject3\",\n", + " session_datetime=\"2022-09-01 19:16:44\",\n", " scan_id=0,\n", " paramset_idx=1,\n", " processing_output_dir=output_dir,\n", - " task_mode='trigger'\n", + " task_mode=\"trigger\",\n", " )\n", ")" ] @@ -644,7 +665,11 @@ "\n", "imaging.Processing.populate(**populate_settings)\n", "\n", - "key = (imaging.ProcessingTask & 'subject=\"subject3\"' & 'session_datetime=\"2022-09-01 19:16:44\"').fetch1('KEY')\n", + "key = (\n", + " imaging.ProcessingTask\n", + " & 'subject=\"subject3\"'\n", + " & 'session_datetime=\"2022-09-01 19:16:44\"'\n", + ").fetch1(\"KEY\")\n", "\n", "imaging.Curation().create1_from_processing_task(key)\n", "\n", diff --git a/requirements.txt b/requirements.txt index 1f2712e..49a0d17 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,13 +1,13 @@ datajoint>=0.13.0 -element-calcium-imaging>=0.3.0 -element-lab>=0.1.1 element-animal>=0.1.2 -element-session>=0.1.2 +element-calcium-imaging>=0.3.0 element-event @ git+https://github.com/datajoint/element-event.git element-interface @ git+https://github.com/datajoint/element-interface.git +element-lab>=0.1.1 +element-session>=0.1.2 ipykernel>=6.0.1 jupytext>=1.13.7 +nd2 sbxreader @ git+https://github.com/datajoint-company/sbxreader scanreader @ git+https://github.com/atlab/scanreader.git -nd2 -suite2p @ git+https://github.com/datajoint-company/suite2p.git \ No newline at end of file +suite2p @ git+https://github.com/datajoint-company/suite2p.git diff --git a/requirements_dev.txt b/requirements_dev.txt index 5129e6e..c3b38b0 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,4 +1,4 @@ +djarchive-client @ git+https://github.com/datajoint/djarchive-client.git pytest pytest-cov -djarchive-client @ git+https://github.com/datajoint/djarchive-client.git shutils diff --git a/setup.py b/setup.py index 5ee9453..5c40b90 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python -from setuptools import setup, find_packages from os import path -import sys + +from setuptools import find_packages, setup pkg_name = "workflow_calcium_imaging" here = path.abspath(path.dirname(__file__)) @@ -25,7 +25,7 @@ setup( name="workflow-calcium-imaging", - version=__version__, + version=__version__, # noqa: F821 description="Calcium imaging workflow using the DataJoint elements", long_description=long_description, long_description_content_type="text/markdown", diff --git a/tests/__init__.py b/tests/__init__.py index d21ec41..e607540 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,13 +1,14 @@ # run tests: pytest -sv --cov-report term-missing --cov=element_calcium_imaging --sw -p no:warnings import os -import sys -import pytest import pathlib +import sys +from contextlib import nullcontext + +import datajoint as dj import numpy as np import pandas as pd -import datajoint as dj -from contextlib import nullcontext +import pytest from element_interface.utils import find_full_path, find_root_directory # ------------------- SOME CONSTANTS ------------------- @@ -60,7 +61,7 @@ def dj_config(): dj.config["safemode"] = False environ_root = os.environ.get("IMAGING_ROOT_DATA_DIR") - if (environ_root and not isinstance(environ_root, list)): + if environ_root and not isinstance(environ_root, list): environ_root = list(environ_root) config_root = dj.config["custom"]["imaging_root_data_dir"] if not isinstance(config_root, list): @@ -79,8 +80,7 @@ def dj_config(): def pipeline(): with verbose_context: print("\n") - from workflow_calcium_imaging import pipeline - from workflow_calcium_imaging import paths + from workflow_calcium_imaging import paths, pipeline global is_multi_scan_processing is_multi_scan_processing = ( @@ -133,6 +133,7 @@ def test_data(dj_config, pipeline): ) import djarchive_client + from workflow_calcium_imaging import version client = djarchive_client.client() diff --git a/tests/test_ingest.py b/tests/test_ingest.py index cfe018f..95fdc05 100644 --- a/tests/test_ingest.py +++ b/tests/test_ingest.py @@ -1,23 +1,25 @@ -import sys import pathlib +import sys + +from element_interface.utils import find_full_path, find_root_directory + from . import ( + caiman2D_paramset, + caiman3D_paramset, + curations, dj_config, - pipeline, - test_data, - subjects_csv, + ingest_sessions, ingest_subjects, + pipeline, + processing, + processing_tasks, + scan_info, sessions_csv, - ingest_sessions, - testdata_paths, + subjects_csv, suite2p_paramset, - caiman2D_paramset, - caiman3D_paramset, - scan_info, - processing_tasks, - processing, - curations, + test_data, + testdata_paths, ) -from element_interface.utils import find_full_path, find_root_directory def test_ingest_subjects(pipeline, ingest_subjects): diff --git a/tests/test_populate.py b/tests/test_populate.py index be289a1..e4a8743 100644 --- a/tests/test_populate.py +++ b/tests/test_populate.py @@ -1,22 +1,24 @@ -import pytest import shutil + +import pytest + from . import ( + caiman2D_paramset, + caiman3D_paramset, + curations, dj_config, - pipeline, - test_data, - subjects_csv, + ingest_sessions, ingest_subjects, + pipeline, + processing, + processing_tasks, + scan_info, sessions_csv, - ingest_sessions, - testdata_paths, + subjects_csv, suite2p_paramset, - caiman2D_paramset, - caiman3D_paramset, - scan_info, + test_data, + testdata_paths, trigger_processing_suite2p_2D, - processing_tasks, - processing, - curations, verbose_context, ) diff --git a/user_data/subjects.csv b/user_data/subjects.csv index 1b3d6ca..a2d4099 100644 --- a/user_data/subjects.csv +++ b/user_data/subjects.csv @@ -1,2 +1,2 @@ subject,sex,subject_birth_date,subject_description -subject3,F,2020-01-01,Scanbox acquisition. Suite2p processing. \ No newline at end of file +subject3,F,2020-01-01,Scanbox acquisition. Suite2p processing. diff --git a/user_data/trials.csv b/user_data/trials.csv index 3a4c31d..e6d7b89 100644 --- a/user_data/trials.csv +++ b/user_data/trials.csv @@ -1,41 +1,41 @@ -subject,session_datetime,block_id,trial_id,trial_start_time,trial_stop_time,trial_type,attribute_name,attribute_value -subject3,2021-04-30 12:22:15,1,1,0.285,20.285,stim,lumen,535 -subject3,2021-04-30 12:22:15,1,2,23.927,43.927,ctrl,lumen,747 -subject3,2021-04-30 12:22:15,1,3,47.622,67.622,stim,lumen,920 -subject3,2021-04-30 12:22:15,1,4,71.443,91.443,ctrl,lumen,927 -subject3,2021-04-30 12:22:15,1,5,95.385,115.385,ctrl,lumen,634 -subject3,2021-04-30 12:22:15,1,6,119.331,139.331,ctrl,lumen,666 -subject3,2021-04-30 12:22:15,1,7,143.254,163.254,ctrl,lumen,985 -subject3,2021-04-30 12:22:15,1,8,166.86,186.86,stim,lumen,882 -subject3,2021-04-30 12:22:15,1,9,190.465,210.465,ctrl,lumen,767 -subject3,2021-04-30 12:22:15,1,10,214.395,234.395,ctrl,lumen,811 -subject3,2021-04-30 12:22:15,2,11,241.13,261.13,stim,lumen,0 -subject3,2021-04-30 12:22:15,2,12,264.974,284.974,ctrl,lumen,0 -subject3,2021-04-30 12:22:15,2,13,288.79,308.79,stim,lumen,0 -subject3,2021-04-30 12:22:15,2,14,312.774,332.774,stim,lumen,0 -subject3,2021-04-30 12:22:15,2,15,336.724,356.724,ctrl,lumen,0 -subject3,2021-04-30 12:22:15,2,16,360.342,380.342,stim,lumen,0 -subject3,2021-04-30 12:22:15,2,17,383.845,403.845,stim,lumen,0 -subject3,2021-04-30 12:22:15,2,18,407.603,427.603,stim,lumen,0 -subject3,2021-04-30 12:22:15,2,19,431.431,451.431,ctrl,lumen,0 -subject3,2021-04-30 12:22:15,2,20,455.293,475.293,stim,lumen,0 -subject3,2021-04-30 12:22:15,3,21,482.429,502.429,stim,lumen,614 -subject3,2021-04-30 12:22:15,3,22,506.24,526.24,ctrl,lumen,643 -subject3,2021-04-30 12:22:15,3,23,529.803,549.803,ctrl,lumen,511 -subject3,2021-04-30 12:22:15,3,24,553.631,573.631,stim,lumen,527 -subject3,2021-04-30 12:22:15,3,25,577.148,597.148,ctrl,lumen,880 -subject3,2021-04-30 12:22:15,3,26,600.7,620.7,stim,lumen,851 -subject3,2021-04-30 12:22:15,3,27,624.471,644.471,stim,lumen,970 -subject3,2021-04-30 12:22:15,3,28,648.028,668.028,ctrl,lumen,780 -subject3,2021-04-30 12:22:15,3,29,671.775,691.775,stim,lumen,874 -subject3,2021-04-30 12:22:15,3,30,695.579,715.579,ctrl,lumen,638 -subject3,2021-04-30 12:22:15,4,31,723.489,743.489,stim,lumen,0 -subject3,2021-04-30 12:22:15,4,32,747.103,767.103,stim,lumen,0 -subject3,2021-04-30 12:22:15,4,33,770.923,790.923,ctrl,lumen,0 -subject3,2021-04-30 12:22:15,4,34,794.423,814.423,stim,lumen,0 -subject3,2021-04-30 12:22:15,4,35,818.058,838.058,stim,lumen,0 -subject3,2021-04-30 12:22:15,4,36,841.863,861.863,ctrl,lumen,0 -subject3,2021-04-30 12:22:15,4,37,865.704,885.704,stim,lumen,0 -subject3,2021-04-30 12:22:15,4,38,889.613,909.613,ctrl,lumen,0 -subject3,2021-04-30 12:22:15,4,39,913.301,933.301,stim,lumen,0 -subject3,2021-04-30 12:22:15,4,40,937.232,957.232,ctrl,lumen,0 +subject,session_datetime,block_id,trial_id,trial_start_time,trial_stop_time,trial_type,attribute_name,attribute_value +subject3,2021-04-30 12:22:15,1,1,0.285,20.285,stim,lumen,535 +subject3,2021-04-30 12:22:15,1,2,23.927,43.927,ctrl,lumen,747 +subject3,2021-04-30 12:22:15,1,3,47.622,67.622,stim,lumen,920 +subject3,2021-04-30 12:22:15,1,4,71.443,91.443,ctrl,lumen,927 +subject3,2021-04-30 12:22:15,1,5,95.385,115.385,ctrl,lumen,634 +subject3,2021-04-30 12:22:15,1,6,119.331,139.331,ctrl,lumen,666 +subject3,2021-04-30 12:22:15,1,7,143.254,163.254,ctrl,lumen,985 +subject3,2021-04-30 12:22:15,1,8,166.86,186.86,stim,lumen,882 +subject3,2021-04-30 12:22:15,1,9,190.465,210.465,ctrl,lumen,767 +subject3,2021-04-30 12:22:15,1,10,214.395,234.395,ctrl,lumen,811 +subject3,2021-04-30 12:22:15,2,11,241.13,261.13,stim,lumen,0 +subject3,2021-04-30 12:22:15,2,12,264.974,284.974,ctrl,lumen,0 +subject3,2021-04-30 12:22:15,2,13,288.79,308.79,stim,lumen,0 +subject3,2021-04-30 12:22:15,2,14,312.774,332.774,stim,lumen,0 +subject3,2021-04-30 12:22:15,2,15,336.724,356.724,ctrl,lumen,0 +subject3,2021-04-30 12:22:15,2,16,360.342,380.342,stim,lumen,0 +subject3,2021-04-30 12:22:15,2,17,383.845,403.845,stim,lumen,0 +subject3,2021-04-30 12:22:15,2,18,407.603,427.603,stim,lumen,0 +subject3,2021-04-30 12:22:15,2,19,431.431,451.431,ctrl,lumen,0 +subject3,2021-04-30 12:22:15,2,20,455.293,475.293,stim,lumen,0 +subject3,2021-04-30 12:22:15,3,21,482.429,502.429,stim,lumen,614 +subject3,2021-04-30 12:22:15,3,22,506.24,526.24,ctrl,lumen,643 +subject3,2021-04-30 12:22:15,3,23,529.803,549.803,ctrl,lumen,511 +subject3,2021-04-30 12:22:15,3,24,553.631,573.631,stim,lumen,527 +subject3,2021-04-30 12:22:15,3,25,577.148,597.148,ctrl,lumen,880 +subject3,2021-04-30 12:22:15,3,26,600.7,620.7,stim,lumen,851 +subject3,2021-04-30 12:22:15,3,27,624.471,644.471,stim,lumen,970 +subject3,2021-04-30 12:22:15,3,28,648.028,668.028,ctrl,lumen,780 +subject3,2021-04-30 12:22:15,3,29,671.775,691.775,stim,lumen,874 +subject3,2021-04-30 12:22:15,3,30,695.579,715.579,ctrl,lumen,638 +subject3,2021-04-30 12:22:15,4,31,723.489,743.489,stim,lumen,0 +subject3,2021-04-30 12:22:15,4,32,747.103,767.103,stim,lumen,0 +subject3,2021-04-30 12:22:15,4,33,770.923,790.923,ctrl,lumen,0 +subject3,2021-04-30 12:22:15,4,34,794.423,814.423,stim,lumen,0 +subject3,2021-04-30 12:22:15,4,35,818.058,838.058,stim,lumen,0 +subject3,2021-04-30 12:22:15,4,36,841.863,861.863,ctrl,lumen,0 +subject3,2021-04-30 12:22:15,4,37,865.704,885.704,stim,lumen,0 +subject3,2021-04-30 12:22:15,4,38,889.613,909.613,ctrl,lumen,0 +subject3,2021-04-30 12:22:15,4,39,913.301,933.301,stim,lumen,0 +subject3,2021-04-30 12:22:15,4,40,937.232,957.232,ctrl,lumen,0 diff --git a/workflow_calcium_imaging/analysis.py b/workflow_calcium_imaging/analysis.py index c12f50c..6615ce2 100644 --- a/workflow_calcium_imaging/analysis.py +++ b/workflow_calcium_imaging/analysis.py @@ -1,8 +1,8 @@ -import datajoint as dj -import numpy as np import importlib import inspect +import datajoint as dj +import numpy as np schema = dj.schema() diff --git a/workflow_calcium_imaging/ingest.py b/workflow_calcium_imaging/ingest.py index 72434fb..d9623e6 100644 --- a/workflow_calcium_imaging/ingest.py +++ b/workflow_calcium_imaging/ingest.py @@ -1,21 +1,23 @@ import csv import pathlib -from pathlib import Path from datetime import datetime +from pathlib import Path + from element_interface.utils import ( find_full_path, find_root_directory, ingest_csv_to_table, ) + +from workflow_calcium_imaging.paths import get_imaging_root_data_dir from workflow_calcium_imaging.pipeline import ( - subject, + Equipment, + event, scan, session, - Equipment, + subject, trial, - event, ) -from workflow_calcium_imaging.paths import get_imaging_root_data_dir def ingest_subjects( diff --git a/workflow_calcium_imaging/paths.py b/workflow_calcium_imaging/paths.py index 1a6abf1..8478162 100644 --- a/workflow_calcium_imaging/paths.py +++ b/workflow_calcium_imaging/paths.py @@ -1,7 +1,8 @@ -import datajoint as dj from collections import abc -from element_session import session_with_datetime as session # If pipeline, circular + +import datajoint as dj from element_interface.utils import find_full_path +from element_session import session_with_datetime as session # If pipeline, circular def get_imaging_root_data_dir(): diff --git a/workflow_calcium_imaging/pipeline.py b/workflow_calcium_imaging/pipeline.py index 593bf8b..02ea8d0 100644 --- a/workflow_calcium_imaging/pipeline.py +++ b/workflow_calcium_imaging/pipeline.py @@ -1,23 +1,24 @@ import datajoint as dj -from element_lab import lab from element_animal import subject -from element_session import session_with_datetime as session -from element_event import trial, event -from element_calcium_imaging import scan, imaging -from element_lab.lab import Source, Lab, Protocol, User, Location, Project from element_animal.subject import Subject +from element_calcium_imaging import imaging, scan +from element_event import event, trial +from element_lab import lab +from element_lab.lab import Lab, Location, Project, Protocol, Source, User +from element_session import session_with_datetime as session + +from . import analysis, db_prefix from .paths import ( get_imaging_root_data_dir, - get_scan_image_files, - get_scan_box_files, get_nd2_files, get_prairieview_files, + get_scan_box_files, + get_scan_image_files, ) -from . import analysis from .reference import Equipment -from . import db_prefix __all__ = [ + "dj", "subject", "lab", "session", diff --git a/workflow_calcium_imaging/process.py b/workflow_calcium_imaging/process.py index f188569..3c65bfa 100644 --- a/workflow_calcium_imaging/process.py +++ b/workflow_calcium_imaging/process.py @@ -1,6 +1,7 @@ -from workflow_calcium_imaging.pipeline import imaging, scan import warnings +from workflow_calcium_imaging.pipeline import imaging, scan + warnings.filterwarnings("ignore") diff --git a/workflow_calcium_imaging/reference.py b/workflow_calcium_imaging/reference.py index 2957ac0..efe9054 100644 --- a/workflow_calcium_imaging/reference.py +++ b/workflow_calcium_imaging/reference.py @@ -1,4 +1,5 @@ import datajoint as dj + from . import db_prefix schema = dj.Schema(db_prefix + "reference") diff --git a/workflow_calcium_imaging/version.py b/workflow_calcium_imaging/version.py index 23b6780..3c77e6b 100644 --- a/workflow_calcium_imaging/version.py +++ b/workflow_calcium_imaging/version.py @@ -1,6 +1,6 @@ """ Package metadata -Update the Docker image tag in `docker-compose-test.yaml` and +Update the Docker image tag in `docker-compose-test.yaml` and `docker-compose-dev.yaml` to match """ __version__ = "0.2.0"