Skip to content

Commit

Permalink
add method to write in-memory elements from interactive sdata to file
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamaedler committed Feb 14, 2025
1 parent dc29498 commit a28b4a8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/scportrait/pipeline/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,30 @@ def view_sdata(self):
self.interactive = Interactive(self.interactive_sdata)
self.interactive.run()

def _save_interactive_sdata(self):
assert self.interactive_sdata is not None, "No interactive sdata object found."

in_memory_only, _ = self.interactive_sdata._symmetric_difference_with_zarr_store()
print("Writing the following manually added files to the sdata object: {in_memory_only}")

dict_lookup = {}
for elem in in_memory_only:
key, name = elem.split("/")
if key not in dict_lookup:
dict_lookup[key] = []
dict_lookup[key].append(name)
for _, name in dict_lookup.items():
self.interactive_sdata.sdata_interactive.write_element(
name
) # replace with correct function once pulled in from sdata

def close_interactive_viewer(self):
assert self.interactive is not None, "No interactive session found."
self._save_interactive_sdata()
self.interactive._viewer.close()
self.interactive_sdata = None # reset to none value
self.interactive = None

#### Functions to load input data ####
def load_input_from_array(
self, array: np.ndarray, channel_names: list[str] = None, overwrite: bool | None = None, remap: list[int] = None
Expand Down

0 comments on commit a28b4a8

Please sign in to comment.