diff --git a/studio/app/common/core/rules/runner.py b/studio/app/common/core/rules/runner.py index a55b5ae20..04394541e 100644 --- a/studio/app/common/core/rules/runner.py +++ b/studio/app/common/core/rules/runner.py @@ -114,13 +114,10 @@ def save_all_nwb(cls, save_path, all_nwbfile): timeout = 30 # ロック取得のタイムアウト時間(秒) with FileLock(lock_path, timeout=timeout): # ロックが取得できたら、ファイルに書き込みを行う - try: - if os.path.exists(save_path): - overwrite_nwbfile(save_path, nwbconfig) - else: - save_nwb(save_path, input_nwbfile, nwbconfig) - except Exception as e: - print(e) + if os.path.exists(save_path): + overwrite_nwbfile(save_path, nwbconfig) + else: + save_nwb(save_path, input_nwbfile, nwbconfig) @classmethod def execute_function(cls, path, params, nwb_params, output_dir, input_info): diff --git a/studio/app/optinist/core/nwb/nwb_creater.py b/studio/app/optinist/core/nwb/nwb_creater.py index 080eb2821..b8943df0d 100644 --- a/studio/app/optinist/core/nwb/nwb_creater.py +++ b/studio/app/optinist/core/nwb/nwb_creater.py @@ -121,6 +121,12 @@ def add_plane_segmentation(cls, nwbfile, function_id): if "TwoPhotonSeries" in nwbfile.acquisition: reference_images = nwbfile.acquisition["TwoPhotonSeries"] + try: + image_seg.plane_segmentations.pop(function_id) + nwbfile.processing["ophys"].data_interfaces.pop(function_id) + except KeyError: + pass + image_seg.create_plane_segmentation( name=function_id, description="output", @@ -248,14 +254,15 @@ def behavior(cls, nwbfile, key, value): @classmethod def postprocess(cls, nwbfile, function_id, data): - nwbfile.create_processing_module(name=function_id, description="description") - for key, value in data.items(): - postprocess = PostProcess( - name=key, - data=value, - ) - nwbfile.processing[function_id].add_container(postprocess) + process_name = f"{function_id}_{key}" + postprocess = PostProcess(name=process_name, data=value) + + try: + nwbfile.processing["optinist"].add_container(postprocess) + except ValueError: + nwbfile.processing["optinist"].data_interfaces.pop(process_name) + nwbfile.processing["optinist"].add_container(postprocess) return nwbfile