Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Use random arrays for memory testing #82

Merged
merged 1 commit into from
Feb 28, 2023
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
33 changes: 12 additions & 21 deletions benchmarks/detect_and_classify.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
from pathlib import Path

import dask.array as da
import numpy as np

from cellfinder_core.main import main
from cellfinder_core.tools.IO import read_with_dask

data_dir = (
Path(__file__).parent
/ ".."
/ "tests"
/ "data"
/ "integration"
/ "detection"
).resolve()
signal_data_path = data_dir / "crop_planes" / "ch0"
background_data_path = data_dir / "crop_planes" / "ch1"

voxel_sizes = [5, 2, 2]

# Read data
signal_array = read_with_dask(str(signal_data_path))
background_array = read_with_dask(str(background_data_path))
# Use random data for signal/background data
repeats = 2
shape = (30 * repeats, 510, 667)

signal_array = da.random.random(shape)
signal_array = (signal_array * 65535).astype(np.uint16)

background_array = da.random.random(shape)
background_array = (signal_array * 65535).astype(np.uint16)

# Artificially increase size of the test data
repeats = 5
signal_array = da.repeat(signal_array, repeats=repeats, axis=0)
background_array = da.repeat(background_array, repeats=repeats, axis=0)
array_size_MB = signal_array.nbytes / 1024 / 1024
print(f"Signal array size = {array_size_MB:.02f} MB")

if __name__ == "__main__":
# Run detection & classification
Expand Down