Skip to content

Commit

Permalink
Check for activated module
Browse files Browse the repository at this point in the history
  • Loading branch information
kushalbakshi committed Sep 19, 2023
1 parent b2cd434 commit 7d9523e
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions element_calcium_imaging/export/nwb/nwb.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@
)

from ... import scan
from ... import imaging_no_curation as imaging
from ... import imaging_no_curation, imaging, imaging_preprocess
from ...scan import get_calcium_imaging_files, get_imaging_root_data_dir

logger = dj.logger

if imaging_no_curation.schema.is_activated():
imaging = imaging_no_curation
else:
raise DataJointError(
"This export function is designed for the `imaging_no_curation` module."
)


def _create_full_nwbfile(session_key, output_directory, nwb_path):
acquisition_software = (scan.Scan & session_key).fetch1("acq_software")
Expand Down Expand Up @@ -422,17 +429,12 @@ def imaging_session_to_nwb(
protocol_key=None,
nwbfile_kwargs=None,
):
session_to_nwb = getattr(imaging._linking_module, "session_to_nwb", False)
if processed_data_source not in ["database", "filesystem"]:
raise ValueError(
"Invalid processed data source. Expected one of 'database', 'filesystem'"
)

session_to_nwb = getattr(imaging._linking_module, "session_to_nwb", False)
output_relative_dir = (imaging.ProcessingTask & session_key).fetch1(
"processing_output_dir"
)
output_dir = find_full_path(get_imaging_root_data_dir(), output_relative_dir)

if not save_path:
output_relative_dir = (imaging.ProcessingTask & session_key).fetch1(
"processing_output_dir"
Expand All @@ -441,7 +443,7 @@ def imaging_session_to_nwb(

if include_raw_data and processed_data_source == "filesystem":
_create_full_nwbfile(
session_key, output_directory=output_dir, nwb_path=save_path
session_key, output_directory=save_path, nwb_path=save_path
)
with NWBHDF5IO(
(save_path / f'{session_key["subject"]}_nwbfile'), mode="r+"
Expand All @@ -460,7 +462,7 @@ def imaging_session_to_nwb(
io.write(nwb_file)
elif include_raw_data and processed_data_source == "database":
_create_raw_data_nwbfile(
session_key, output_directory=output_dir, nwb_path=save_path
session_key, output_directory=save_path, nwb_path=save_path
)
with NWBHDF5IO(
(save_path / f'{session_key["subject"]}_nwbfile'), mode="r+"
Expand Down

0 comments on commit 7d9523e

Please sign in to comment.