Skip to content

Commit

Permalink
Merge pull request #9 from catalystneuro/add_automatic_upload
Browse files Browse the repository at this point in the history
Add automatic upload to DANDI
  • Loading branch information
CodyCBakerPhD authored Dec 12, 2023
2 parents 2fc55b6 + 1a959f6 commit af8e6cf
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions src/jazayeri_lab_to_nwb/watters/watters_convert_session.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Primary script to run to convert an entire session for of data using the NWBConverter."""

import os
import datetime
import glob
import json
Expand All @@ -9,6 +9,7 @@
from uuid import uuid4
from zoneinfo import ZoneInfo

from neuroconv.tools.data_transfers import automatic_dandi_upload
from neuroconv.utils import load_dict_from_file, dict_deep_update

from jazayeri_lab_to_nwb.watters import WattersNWBConverter
Expand All @@ -34,8 +35,39 @@ def session_to_nwb(
data_dir: Union[str, Path],
output_dir_path: Union[str, Path],
stub_test: bool = False,
overwrite: bool = False,
overwrite: bool = True,
dandiset_id: Union[str, None] = None,
):
"""
Convert a single session to an NWB file.
Parameters
----------
data_dir : string or Path
Source data directory.
output_dir_path : string or Path
Output data directory.
stub_test : boolean
Whether or not to generate a preview file by limiting data write to a few MB.
Default is False.
overwrite : boolean
If the file exists already, True will delete and replace with a new file, False will append the contents.
Default is True.
dandiset_id : string, optional
If you want to upload the file to the DANDI archive, specify the six-digit ID here.
Requires the DANDI_API_KEY environment variable to be set.
To set this in your bash terminal in Linux or macOS, run
export DANDI_API_KEY=...
or in Windows
set DANDI_API_KEY=...
Default is None.
"""
if dandiset_id is not None:
import dandi # check importability
assert os.getenv("DANDI_API_KEY"), (
"Unable to find environment variable 'DANDI_API_KEY'. "
"Please retrieve your token from DANDI and set this environment variable."
)

logging.info("")
logging.info(f"data_dir = {data_dir}")
Expand Down Expand Up @@ -201,6 +233,7 @@ def session_to_nwb(
conversion_options=raw_conversion_options,
overwrite=overwrite,
)
automatic_dandi_upload(dandiset_id=dandiset_id)


if __name__ == "__main__":
Expand All @@ -216,4 +249,5 @@ def session_to_nwb(
output_dir_path=output_dir_path,
stub_test=stub_test,
overwrite=overwrite,
# dandiset_id = "000620",
)

0 comments on commit af8e6cf

Please sign in to comment.