Skip to content

Commit

Permalink
Merge pull request #571 from oist/test-fix-roi-edit
Browse files Browse the repository at this point in the history
pop existing value
  • Loading branch information
ReiHashimoto authored Sep 29, 2023
2 parents e5dd4a9 + 02cf671 commit cf97b3a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
11 changes: 4 additions & 7 deletions studio/app/common/core/rules/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
21 changes: 14 additions & 7 deletions studio/app/optinist/core/nwb/nwb_creater.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit cf97b3a

Please sign in to comment.