Skip to content

Commit

Permalink
Merge branch 'main' into final_feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
pauladkisson authored May 28, 2024
2 parents 84c404f + ae83b75 commit 4bdb25f
Show file tree
Hide file tree
Showing 11 changed files with 452 additions and 249 deletions.
15 changes: 9 additions & 6 deletions frozen_dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ aiobotocore==2.11.1
aiohttp==3.9.2
aioitertools==0.11.0
aiosignal==1.3.1
annotated-types==0.7.0
appdirs==1.4.4
appnope==0.1.4
arrow==1.3.0
Expand All @@ -23,11 +24,12 @@ comm==0.2.1
contourpy==1.2.0
cycler==0.12.1
dandi==0.59.1
dandischema==0.8.4
dandischema==0.8.2
debugpy==1.8.1
decorator==5.1.1
distlib==0.3.8
dnspython==2.5.0
docstring_parser==0.16
email-validator==2.1.0.post1
entrypoints==0.4
et-xmlfile==1.1.0
Expand All @@ -44,7 +46,7 @@ fsspec==2023.12.2
gast==0.4.0
h5py==3.10.0
hdmf==3.13.0
hdmf_zarr==0.5.0
hdmf_zarr==0.7.0
humanize==4.9.0
identify==2.5.33
idna==3.6
Expand Down Expand Up @@ -86,14 +88,14 @@ more-itertools==10.2.0
multidict==6.0.4
natsort==8.4.0
ndx-events==0.2.0
ndx-fiber-photometry @ git+https://github.com/catalystneuro/ndx-fiber-photometry.git@2e80a7ac040ddca2873cce03aceaabd7c816a5f6
ndx-fiber-photometry @ git+https://github.com/catalystneuro/ndx-fiber-photometry.git@14e05cda86026db694c1c577918284f435b7ec10
ndx-grayscalevolume==0.0.2
ndx-icephys-meta==0.1.0
ndx-photometry @ git+https://github.com/catalystneuro/ndx-photometry.git@c1284c91a7e0a5dfd19f84bbf683e17fa607d4ec
ndx-spectrum==0.2.2
nest-asyncio==1.6.0
networkx==3.2.1
neuroconv==0.4.7
neuroconv @ git+https://github.com/catalystneuro/neuroconv.git@f45e77e152369916459a764c918d4c5cbbf1fad1
nodeenv==1.8.0
numcodecs==0.11.0
numpy==1.26.3
Expand All @@ -116,9 +118,10 @@ ptyprocess==0.7.0
pure-eval==0.2.2
py2vega==0.6.1
pycryptodomex==3.20.0
pydantic==1.10.14
pydantic==2.7.1
pydantic_core==2.18.2
Pygments==2.17.2
pynwb==2.6.0
pynwb==2.7.0
pyout==0.7.3
pyparsing==3.1.1
pytest==8.1.1
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
hdmf
neuroconv
neuroconv @ git+https://github.com/catalystneuro/neuroconv.git@main
nwbwidgets
nwbinspector
dandi
Expand Down
3 changes: 2 additions & 1 deletion src/lerner_lab_to_nwb/seiler_2024/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
from .seiler_2024fiberphotometryinterface import Seiler2024FiberPhotometryInterface
from .seiler_2024optogeneticinterface import Seiler2024OptogeneticInterface
from .seiler_2024excelmetadatainterface import Seiler2024ExcelMetadataInterface
from .seiler_2024nwbconverter import Seiler2024NWBConverter
from .seiler_2024westernblotinterface import Seiler2024WesternBlotInterface
from .seiler_2024nwbconverter import Seiler2024NWBConverter, Seiler2024WesternBlotNWBConverter
102 changes: 101 additions & 1 deletion src/lerner_lab_to_nwb/seiler_2024/seiler_2024_convert_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
import traceback
import re

from lerner_lab_to_nwb.seiler_2024.seiler_2024_convert_session import session_to_nwb
from lerner_lab_to_nwb.seiler_2024.seiler_2024_convert_session import (
session_to_nwb,
western_blot_to_nwb,
split_western_blot,
)
from lerner_lab_to_nwb.seiler_2024.medpc import get_medpc_variables
from lerner_lab_to_nwb.seiler_2024.medpc import read_medpc_file

Expand All @@ -37,6 +41,22 @@ def dataset_to_nwb(
verbose : bool, optional
Whether to print verbose output, by default True
"""
subjects_to_skip = {
"289.407",
"244.464",
"264.477",
"102.260",
"262.478",
"289.408",
"264.475",
"129.425",
"250.427",
"95.259",
"309.399",
"433.421",
"416.405",
"364.426",
}
start_variable = "Start Date"
data_dir_path = Path(data_dir_path)
output_dir_path = Path(output_dir_path)
Expand All @@ -62,6 +82,8 @@ def dataset_to_nwb(
experiment_type = session_to_nwb_kwargs["experiment_type"]
experimental_group = session_to_nwb_kwargs["experimental_group"]
subject_id = session_to_nwb_kwargs["subject_id"]
if subject_id in subjects_to_skip:
continue
start_datetime = session_to_nwb_kwargs["start_datetime"]
optogenetic_treatment = session_to_nwb_kwargs.get("optogenetic_treatment", None)
if experiment_type == "FP":
Expand Down Expand Up @@ -195,6 +217,13 @@ def fp_to_nwb(
"Photo_100_258-190509-133212",
"Photo_101_260-190425-120029",
}
partial_subject_ids_to_subject_id = {
"300": "300.405",
"418": "418.404",
"299": "299.405",
"276": "276.405",
"262.259.478": "262.478",
}
raw_file_to_info = get_raw_info(behavior_path)

# Iterate through file system to get necessary information for converting each session
Expand Down Expand Up @@ -327,6 +356,8 @@ def fp_to_nwb(
if box_number is not None:
session_conditions["Box"] = box_number
start_datetime = datetime.strptime(f"{start_date} {start_time}", "%m/%d/%y %H:%M:%S")
if photometry_subject_id in partial_subject_ids_to_subject_id:
photometry_subject_id = partial_subject_ids_to_subject_id[photometry_subject_id]
session_to_nwb_args = dict(
data_dir_path=data_dir_path,
output_dir_path=output_dir_path,
Expand Down Expand Up @@ -399,6 +430,8 @@ def fp_to_nwb(
if box_number is not None:
session_conditions["Box"] = box_number
start_datetime = datetime.strptime(f"{start_date} {start_time}", "%m/%d/%y %H:%M:%S")
if subject_id in partial_subject_ids_to_subject_id:
subject_id = partial_subject_ids_to_subject_id[subject_id]
session_to_nwb_args = dict(
data_dir_path=data_dir_path,
output_dir_path=output_dir_path,
Expand Down Expand Up @@ -446,6 +479,36 @@ def opto_to_nwb(
list[dict]
A list of dictionaries containing the arguments for session_to_nwb for each session.
"""
partial_subject_ids_to_subject_id = {
"268": "268.476",
"266": "266.477",
"244": "244.465",
"343": "343.483",
"419": "419.404",
"245": "245.464",
"342": "342.483",
"202": "202.465",
"313": "313.403",
"418": "418.404",
"340": "340.483",
"259": "259.478",
"264": "264.478",
"421": "421.404",
"417": "417.404",
"233": "233.469",
"261": "261.478",
"265": "265.476",
"311": "311.403",
"206": "206.468",
"243": "243.468",
"263": "263.477",
"338": "338.398",
"414": "414.405",
"300": "300.405",
"299": "299.405",
"276": "276.405",
"262.259.478": "262.478",
}
experiment_type = "Opto"
experimental_group_to_optogenetic_treatments = {
"DLS-Excitatory": ["ChR2", "EYFP", "ChR2Scrambled"],
Expand Down Expand Up @@ -567,6 +630,8 @@ def opto_to_nwb(
"Box": box_number,
}
start_datetime = datetime.strptime(f"{start_date} {start_time}", "%m/%d/%y %H:%M:%S")
if subject in partial_subject_ids_to_subject_id:
subject = partial_subject_ids_to_subject_id[subject]
session_to_nwb_args = dict(
data_dir_path=data_dir_path,
output_dir_path=output_dir_path,
Expand Down Expand Up @@ -627,6 +692,10 @@ def get_opto_subject_id(subject_path: Path):
"263": "263.477",
"338": "338.398",
"414": "414.405",
"300": "300.405",
"299": "299.405",
"276": "276.405",
"262.259.478": "262.478",
}

# fmt: off
Expand Down Expand Up @@ -923,6 +992,36 @@ def get_raw_info(behavior_path):
return raw_file_to_info


def western_dataset_to_nwb(*, data_dir_path: Path, output_dir_path: Path, verbose: bool = True):
"""Convert all Western Blot data to NWB.
Parameters
----------
data_dir_path : Path
The path to the directory containing the raw data.
output_dir_path : Path
The path to the directory where the NWB files will be saved.
verbose : bool, optional
Whether to print verbose output, by default True
"""
western_path = data_dir_path / "DATCre Western blot final images and analysis"
raw_western_file_names = [
"Female_DLS_Actin.tif",
"Female_DLS_DAT.tif",
"Female_DMS_Actin.tif",
"Female_DMS_DAT.tif",
"Male_DLS_Actin.tif",
"Male_DLS_DAT.tif",
"Male_DMS_Actin.tif",
"Male_DMS_DAT.tif",
]
for raw_western_file_name in raw_western_file_names:
raw_western_file_path = western_path / raw_western_file_name
wt_file_path, dat_file_path = split_western_blot(file_path=raw_western_file_path)
western_blot_to_nwb(file_path=wt_file_path, output_dir_path=output_dir_path, verbose=verbose)
western_blot_to_nwb(file_path=dat_file_path, output_dir_path=output_dir_path, verbose=verbose)


if __name__ == "__main__":
data_dir_path = Path("/Volumes/T7/CatalystNeuro/NWB/Lerner/raw_data")
output_dir_path = Path("/Volumes/T7/CatalystNeuro/NWB/Lerner/conversion_nwb")
Expand All @@ -938,3 +1037,4 @@ def get_raw_info(behavior_path):
stub_test=False,
verbose=False,
)
western_dataset_to_nwb(data_dir_path=data_dir_path, output_dir_path=output_dir_path, verbose=False)
Loading

0 comments on commit 4bdb25f

Please sign in to comment.