From a48d3c91d9004c0ccea1d72e618f6a32a25b7ae1 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Tue, 6 Aug 2024 09:04:36 +0000 Subject: [PATCH 1/3] Switch to append mechanism --- code/run_capsule.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/code/run_capsule.py b/code/run_capsule.py index 85060e2..ce78848 100644 --- a/code/run_capsule.py +++ b/code/run_capsule.py @@ -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: @@ -301,7 +307,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) From 034e377de52c820803864590542da82dd5c3f693 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Tue, 6 Aug 2024 09:11:55 +0000 Subject: [PATCH 2/3] Edited metadata.yml --- metadata/metadata.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata/metadata.yml b/metadata/metadata.yml index 02512ec..2b4da9b 100644 --- a/metadata/metadata.yml +++ b/metadata/metadata.yml @@ -1,5 +1,5 @@ metadata_version: 1 -name: NWB-Packaging-Units +name: NWB-Packaging-Units (append) description: This specialized capsule is designed to append units information to a base NWB file, including spiking data and unit properties. In particular, it adds the Units table and several properties associated with the units, such as quality From 1c53eb5b029648141e077960741a2792c6d8371d Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Thu, 8 Aug 2024 08:56:19 +0000 Subject: [PATCH 3/3] Revert name change --- metadata/metadata.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata/metadata.yml b/metadata/metadata.yml index 2b4da9b..02512ec 100644 --- a/metadata/metadata.yml +++ b/metadata/metadata.yml @@ -1,5 +1,5 @@ metadata_version: 1 -name: NWB-Packaging-Units (append) +name: NWB-Packaging-Units description: This specialized capsule is designed to append units information to a base NWB file, including spiking data and unit properties. In particular, it adds the Units table and several properties associated with the units, such as quality