Skip to content

Commit

Permalink
Merge pull request #8 from AllenNeuralDynamics/nwbfile-copy
Browse files Browse the repository at this point in the history
Replace `export` with `append` and write
  • Loading branch information
alejoe91 authored Aug 8, 2024
2 parents e9cf92d + 1c53eb5 commit 6e6974d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions code/run_capsule.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,19 @@
nwb_file_name = f"{nwb_original_file_name}_{block_str}_{recording_str}.nwb"
nwbfile_output_path = output_folder / nwb_file_name

# copy to results to avoid read-only issues
if nwbfile_input_path.is_dir():
shutil.copytree(nwbfile_input_path, nwbfile_output_path)
else:
shutil.copyfile(nwbfile_input_path, nwbfile_output_path)

# Find probe devices (this will only work for AIND)
devices_from_rig, target_locations = get_devices_from_rig_metadata(
ecephys_folder, segment_index=segment_index
)

with io_class(str(nwbfile_input_path), "r") as read_io:
nwbfile = read_io.read()
with io_class(str(nwbfile_output_path), "a") as append_io:
nwbfile = append_io.read()

added_stream_names = []
for stream_name in stream_names:
Expand Down Expand Up @@ -302,7 +308,8 @@
else:
write_args = {}

with io_class(str(nwbfile_output_path), "w") as export_io:
export_io.export(src_io=read_io, nwbfile=nwbfile, write_args=write_args)
append_io.write(nwbfile)
# with io_class(str(nwbfile_output_path), "w") as export_io:
# export_io.export(src_io=read_io, nwbfile=nwbfile, write_args=write_args)
print(f"Done writing {nwbfile_output_path}")
nwb_output_files.append(nwbfile_output_path)

0 comments on commit 6e6974d

Please sign in to comment.