Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extraction segfault #137

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/scportrait/pipeline/extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ def __init__(self, *args, **kwargs):
self.overwrite_run_path = self.overwrite

def _get_compression_type(self):
self.compression_type = "lzf" if self.compression else None
if (self.compression) or (self.compression == "lzf"):
self.compression_type = "lzf"
return self.compression_type
elif self.compression == "gzip":
self.compression_type = "gzip"
return self.compression_type
self.compression_type = None
return self.compression_type

def _check_config(self):
Expand Down Expand Up @@ -655,18 +661,25 @@ def _transfer_tempmmap_to_hdf5(self):
#self._clear_cache(vars_to_delete=[cell_ids]) # this is not working as expected so we will just delete the variable directly

_, c, x, y = _tmp_single_cell_data.shape
print(_tmp_single_cell_data.shape)
print(self.image_size)
print(keep_index.shape)
single_cell_data = hf.create_dataset(
"single_cell_data",
shape=(len(keep_index), c, x, y),
chunks=(1, 1, self.image_size, self.image_size),
compression=self.compression_type,
# compression=self.compression_type,
compression='gzip', #was lzf, gzip works
dtype=np.float16,
# rdcc_nbytes=5242880000, # 5gb 1024 * 1024 * 5000
# rdcc_w0=1,
# rdcc_nslots=50000,
)

# populate dataset in loop to prevent loading of entire dataset into memory
# this is required to process large datasets to not run into memory issues
for ix, i in enumerate(keep_index):
single_cell_data[ix] = _tmp_single_cell_data[i]
single_cell_data[ix] = _tmp_single_cell_data[i]

self.log("single-cell data created")
del single_cell_data
Expand Down
Loading